kernel_samsung_a53x/include/net
Gustavo A. R. Silva 7de60845d7 net/ipv4/ipv6: Replace one-element arraya with flexible-array members
[ Upstream commit db243b796439c0caba47865564d8acd18a301d18 ]

There is a regular need in the kernel to provide a way to declare having
a dynamically sized set of trailing elements in a structure. Kernel code
should always use “flexible array members”[1] for these cases. The older
style of one-element or zero-length arrays should no longer be used[2].

Use an anonymous union with a couple of anonymous structs in order to
keep userspace unchanged and refactor the related code accordingly:

$ pahole -C group_filter net/ipv4/ip_sockglue.o
struct group_filter {
	union {
		struct {
			__u32      gf_interface_aux;     /*     0     4 */

			/* XXX 4 bytes hole, try to pack */

			struct __kernel_sockaddr_storage gf_group_aux; /*     8   128 */
			/* --- cacheline 2 boundary (128 bytes) was 8 bytes ago --- */
			__u32      gf_fmode_aux;         /*   136     4 */
			__u32      gf_numsrc_aux;        /*   140     4 */
			struct __kernel_sockaddr_storage gf_slist[1]; /*   144   128 */
		};                                       /*     0   272 */
		struct {
			__u32      gf_interface;         /*     0     4 */

			/* XXX 4 bytes hole, try to pack */

			struct __kernel_sockaddr_storage gf_group; /*     8   128 */
			/* --- cacheline 2 boundary (128 bytes) was 8 bytes ago --- */
			__u32      gf_fmode;             /*   136     4 */
			__u32      gf_numsrc;            /*   140     4 */
			struct __kernel_sockaddr_storage gf_slist_flex[0]; /*   144     0 */
		};                                       /*     0   144 */
	};                                               /*     0   272 */

	/* size: 272, cachelines: 5, members: 1 */
	/* last cacheline: 16 bytes */
};

$ pahole -C compat_group_filter net/ipv4/ip_sockglue.o
struct compat_group_filter {
	union {
		struct {
			__u32      gf_interface_aux;     /*     0     4 */
			struct __kernel_sockaddr_storage gf_group_aux __attribute__((__aligned__(4))); /*     4   128 */
			/* --- cacheline 2 boundary (128 bytes) was 4 bytes ago --- */
			__u32      gf_fmode_aux;         /*   132     4 */
			__u32      gf_numsrc_aux;        /*   136     4 */
			struct __kernel_sockaddr_storage gf_slist[1] __attribute__((__aligned__(4))); /*   140   128 */
		} __attribute__((__packed__)) __attribute__((__aligned__(4)));                     /*     0   268 */
		struct {
			__u32      gf_interface;         /*     0     4 */
			struct __kernel_sockaddr_storage gf_group __attribute__((__aligned__(4))); /*     4   128 */
			/* --- cacheline 2 boundary (128 bytes) was 4 bytes ago --- */
			__u32      gf_fmode;             /*   132     4 */
			__u32      gf_numsrc;            /*   136     4 */
			struct __kernel_sockaddr_storage gf_slist_flex[0] __attribute__((__aligned__(4))); /*   140     0 */
		} __attribute__((__packed__)) __attribute__((__aligned__(4)));                     /*     0   140 */
	} __attribute__((__aligned__(1)));               /*     0   268 */

	/* size: 268, cachelines: 5, members: 1 */
	/* forced alignments: 1 */
	/* last cacheline: 12 bytes */
} __attribute__((__packed__));

This helps with the ongoing efforts to globally enable -Warray-bounds
and get us closer to being able to tighten the FORTIFY_SOURCE routines
on memcpy().

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.10/process/deprecated.html#zero-length-and-one-element-arrays

Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/109
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Stable-dep-of: 5c3be3e0eb44 ("ipmr: fix incorrect parameter validation in the ip_mroute_getsockopt() function")
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 08:44:49 +01:00
..
9p Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bluetooth Bluetooth: Fix bogus check for re-auth no supported with non-ssp 2024-11-18 12:12:38 +01:00
caif Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
iucv Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
netfilter netfilter: nf_tables: fix pointer math issue in nft_byteorder_eval() 2024-11-18 12:13:40 +01:00
netns Revert "xfrm: fix a data-race in xfrm_gen_index()" 2024-11-17 19:38:56 +01:00
nfc Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
phonet Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sctp Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tc_act Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
6lowpan.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
act_api.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
addrconf.h net: ipv6: support reporting otherwise unknown prefix flags in RTM_NEWPREFIX 2024-11-18 12:11:48 +01:00
af_ieee802154.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
af_rxrpc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
af_unix.h af_unix: fix lockdep positive in sk_diag_dump_icons() 2024-11-18 12:13:23 +01:00
af_vsock.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ah.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
arp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
atmclip.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ax25.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ax88796.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bareudp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bond_3ad.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bond_alb.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bond_options.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bonding.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bpf_sk_storage.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
busy_poll.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
calipso.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cfg80211-wext.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cfg80211.h Backport mac80211 patches from linux-6.1.y 2024-06-15 16:29:20 -03:00
cfg802154.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
checksum.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cipso_ipv4.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cls_cgroup.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cnss2.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cnss_nl.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cnss_prealloc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cnss_utils.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
codel.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
codel_impl.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
codel_qdisc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
compat.h net/ipv4/ipv6: Replace one-element arraya with flexible-array members 2024-11-19 08:44:49 +01:00
datalink.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dcbevent.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dcbnl.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
devlink.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dropdump.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dsa.h Backport mac80211 patches from linux-6.1.y 2024-06-15 16:29:20 -03:00
dsfield.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dst.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dst_cache.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dst_metadata.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dst_ops.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
erspan.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
esp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
espintcp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ethoc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
failover.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fib_notifier.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fib_rules.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
firewire.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
flow.h inet: shrink struct flowi_common 2024-11-18 11:43:07 +01:00
flow_dissector.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
flow_offload.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fou.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fq.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fq_impl.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
garp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gen_stats.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
genetlink.h drop_monitor: Require 'CAP_SYS_ADMIN' when joining "events" group 2024-11-18 12:11:46 +01:00
geneve.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gre.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gro_cells.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gtp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gue.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hwbm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
icmp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ieee80211_radiotap.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ieee802154_netdev.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
if_inet6.h net: ipv6: support reporting otherwise unknown prefix flags in RTM_NEWPREFIX 2024-11-18 12:11:48 +01:00
ife.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ila.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inet6_connection_sock.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inet6_hashtables.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inet_common.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inet_connection_sock.h tcp: make sure init the accept_queue's spinlocks once 2024-11-18 12:12:59 +01:00
inet_ecn.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inet_frag.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inet_hashtables.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inet_sock.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inet_timewait_sock.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inetpeer.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ip.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ip6_checksum.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ip6_fib.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ip6_route.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ip6_tunnel.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ip_fib.h ipv4/fib: send notify when delete source address routes 2024-11-08 11:26:17 +01:00
ip_tunnels.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ip_vs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ipcomp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ipconfig.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ipv6.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ipv6_frag.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ipv6_stubs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ipx.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
iw_handler.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kcm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
l3mdev.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lag.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lapb.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lib80211.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
llc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
llc_c_ac.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
llc_c_ev.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
llc_c_st.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
llc_conn.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
llc_if.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
llc_pdu.h llc: Drop support for ETH_P_TR_802_2. 2024-11-18 12:13:00 +01:00
llc_s_ac.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
llc_s_ev.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
llc_s_st.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
llc_sap.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lwtunnel.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mac80211.h Backport mac80211 patches from linux-6.1.y 2024-06-15 16:29:20 -03:00
mac802154.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
macsec.h net: macsec: indicate next pn update when offloading 2024-11-08 11:25:46 +01:00
mip6.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mld.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mpls.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mpls_iptunnel.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mptcp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mrp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ncm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ncsi.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ndisc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
neighbour.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
net_failover.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
net_namespace.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
net_ratelimit.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
netevent.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
netlabel.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
netlink.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
netprio_cgroup.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
netrom.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
nexthop.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
nl802154.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
nsh.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
p8022.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
page_pool.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pie.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ping.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pkt_cls.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pkt_sched.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pptp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
protocol.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
psample.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
psnap.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
raw.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rawv6.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
red.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
regulatory.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
request_sock.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rose.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
route.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rpl.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rsi_91x.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rtnetlink.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rtnh.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sch_generic.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
secure_seq.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
seg6.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
seg6_hmac.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
seg6_local.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
skb_tracer.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
slhc_vj.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
snmp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sock.h net: annotate data-races around sk->sk_dst_pending_confirm 2024-11-18 11:43:12 +01:00
sock_reuseport.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Space.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
stp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
strparser.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
switchdev.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tcp.h mptcp: fix lockless access in subflow ULP diag 2024-11-18 22:25:39 +01:00
tcp_states.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
TEST_MAPPING Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timewait_sock.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tipc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tls.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tls_toe.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
transp_v6.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tso.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tun_proto.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
udp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
udp_tunnel.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
udplite.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
virt_wifi.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vsock_addr.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vxlan.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
wext.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
wimax.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
x25.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
x25device.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
xdp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
xdp_priv.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
xdp_sock.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
xdp_sock_drv.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
xfrm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
xsk_buff_pool.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00