History

netfilter: ebtables: fix fortify warnings in size_entry_mwt()

When compiling with gcc 13 and CONFIG_FORTIFY_SOURCE=y, the following warning appears: In function ‘fortify_memcpy_chk’, inlined from ‘size_entry_mwt’ at net/bridge/netfilter/ebtables.c:2118:2: ./include/linux/fortify-string.h:592:25: error: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror=attribute-warning] 592 | __read_overflow2_field(q_size_field, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The compiler is complaining: memcpy(&offsets[1], &entry->watchers_offset, sizeof(offsets) - sizeof(offsets[0])); where memcpy reads beyong &entry->watchers_offset to copy {watchers,target,next}_offset altogether into offsets[]. Silence the warning by wrapping these three up via struct_group().

GONG, Ruiqi committed 3 years ago

Commit a7ed3461 parent 43c28172 files · +9 −8Browse files

Showing the changes to include/uapi (1 of 2 files). Show all

Unified · Split

include/uapi/linux/netfilter_bridge/ebtables.h+8−6
@@ -182,12 +182,14 @@ struct ebt_entry { · 181 unmodified lines
182 unsigned char sourcemsk[ETH_ALEN];182 unsigned char sourcemsk[ETH_ALEN];
183 unsigned char destmac[ETH_ALEN];183 unsigned char destmac[ETH_ALEN];
184 unsigned char destmsk[ETH_ALEN];184 unsigned char destmsk[ETH_ALEN];
185 /* sizeof ebt_entry + matches */185 __struct_group(/* no tag */, offsets, /* no attrs */,
186 unsigned int watchers_offset;186 /* sizeof ebt_entry + matches */
187 /* sizeof ebt_entry + matches + watchers */187 unsigned int watchers_offset;
188 unsigned int target_offset;188 /* sizeof ebt_entry + matches + watchers */
189 /* sizeof ebt_entry + matches + watchers + target */189 unsigned int target_offset;
190 unsigned int next_offset;190 /* sizeof ebt_entry + matches + watchers + target */
191 unsigned int next_offset;
192 );
191 unsigned char elems[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));193 unsigned char elems[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
192};194};
193 195

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t