-
- Downloads
netfilter: Replace zero-length array with flexible-array member
[ Upstream commit 6daf1414 ] The current codebase makes use of the zero-length array language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as these ones is a flexible array member[1][2], introduced in C99: struct foo { int stuff; struct boo array[]; }; By making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being inadvertently introduced[3] to the codebase from now on. Also, notice that, dynamic memory allocations won't be affected by this change: "Flexible array members have incomplete type, and so the sizeof operator may not be applied. As a quirk of the original implementation of zero-length arrays, sizeof evaluates to zero."[1] Lastly, fix checkpatch.pl warning WARNING: __aligned(size) is preferred over __attribute__((aligned(size))) in net/bridge/netfilter/ebtables.c This issue was found with the help of Coccinelle. [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html [2] https://github.com/KSPP/linux/issues/21 [3] commit 76497732 ("cxgb3/l2t: Fix undefined behaviour") Signed-off-by:Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by:
Pablo Neira Ayuso <pablo@netfilter.org> Stable-dep-of: 542ed8145e6f ("netfilter: nft_set_hash: unaligned atomic read on struct nft_set_ext") Signed-off-by:
Sasha Levin <sashal@kernel.org>
parent
64e9f54a
No related branches found
No related tags found
Showing
- include/linux/netfilter/ipset/ip_set.h 1 addition, 1 deletioninclude/linux/netfilter/ipset/ip_set.h
- include/linux/netfilter/x_tables.h 4 additions, 4 deletionsinclude/linux/netfilter/x_tables.h
- include/linux/netfilter_arp/arp_tables.h 1 addition, 1 deletioninclude/linux/netfilter_arp/arp_tables.h
- include/linux/netfilter_bridge/ebtables.h 1 addition, 1 deletioninclude/linux/netfilter_bridge/ebtables.h
- include/linux/netfilter_ipv4/ip_tables.h 1 addition, 1 deletioninclude/linux/netfilter_ipv4/ip_tables.h
- include/linux/netfilter_ipv6/ip6_tables.h 1 addition, 1 deletioninclude/linux/netfilter_ipv6/ip6_tables.h
- include/net/netfilter/nf_conntrack_extend.h 1 addition, 1 deletioninclude/net/netfilter/nf_conntrack_extend.h
- include/net/netfilter/nf_conntrack_timeout.h 1 addition, 1 deletioninclude/net/netfilter/nf_conntrack_timeout.h
- include/net/netfilter/nf_tables.h 3 additions, 3 deletionsinclude/net/netfilter/nf_tables.h
- include/uapi/linux/netfilter_bridge/ebt_among.h 1 addition, 1 deletioninclude/uapi/linux/netfilter_bridge/ebt_among.h
- net/bridge/netfilter/ebtables.c 1 addition, 1 deletionnet/bridge/netfilter/ebtables.c
- net/ipv4/netfilter/arp_tables.c 2 additions, 2 deletionsnet/ipv4/netfilter/arp_tables.c
- net/ipv4/netfilter/ip_tables.c 2 additions, 2 deletionsnet/ipv4/netfilter/ip_tables.c
- net/ipv6/netfilter/ip6_tables.c 2 additions, 2 deletionsnet/ipv6/netfilter/ip6_tables.c
- net/netfilter/ipset/ip_set_bitmap_ip.c 1 addition, 1 deletionnet/netfilter/ipset/ip_set_bitmap_ip.c
- net/netfilter/ipset/ip_set_bitmap_ipmac.c 1 addition, 1 deletionnet/netfilter/ipset/ip_set_bitmap_ipmac.c
- net/netfilter/ipset/ip_set_bitmap_port.c 1 addition, 1 deletionnet/netfilter/ipset/ip_set_bitmap_port.c
- net/netfilter/ipset/ip_set_hash_gen.h 2 additions, 2 deletionsnet/netfilter/ipset/ip_set_hash_gen.h
- net/netfilter/nfnetlink_acct.c 1 addition, 1 deletionnet/netfilter/nfnetlink_acct.c
- net/netfilter/xt_hashlimit.c 1 addition, 1 deletionnet/netfilter/xt_hashlimit.c
Loading
Please register or sign in to comment