Gustavo A. R. Silva
415edd2d66
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-03-26 18:21:53 -04:00
..
2020-12-30 11:54:09 +01:00
2020-07-15 20:34:11 -07:00
2023-11-08 17:30:50 +01:00
2019-06-05 10:55:30 -04:00
2020-01-21 11:41:36 +01:00
2020-08-22 10:53:12 +01:00
2019-09-07 17:44:25 +02:00
2020-05-28 11:22:14 +02:00
2024-02-23 08:42:20 +01:00
2019-10-04 14:25:17 -07:00
2023-09-23 11:01:06 +02:00
2019-10-04 14:25:17 -07:00
2019-10-04 14:25:17 -07:00
2019-09-10 09:26:33 -04:00
2020-07-21 22:05:32 -07:00
2019-06-24 19:23:46 +02:00
2020-06-15 16:03:38 +01:00
2020-10-03 17:28:45 -07:00
2023-03-11 16:40:17 +01:00
2019-12-18 18:07:31 +01:00
2019-06-26 20:14:13 -04:00
2023-07-27 08:44:02 +02:00
2018-11-19 19:03:43 -07:00
2019-04-25 19:33:34 +02:00
2020-07-13 17:01:44 -07:00
2022-12-02 17:39:57 +01:00
2023-07-27 08:44:12 +02:00
2019-03-07 18:32:01 -08:00
2020-06-26 10:36:30 +02:00
2020-06-26 10:37:11 +02:00
2021-01-12 20:18:25 +01:00
2019-01-04 13:13:47 -08:00
2019-03-07 18:32:01 -08:00
2023-08-11 11:57:38 +02:00
2024-01-25 14:37:43 -08:00
2019-07-25 11:05:10 +02:00
2020-01-10 17:20:07 +01:00
2020-10-07 12:13:23 +02:00
2024-02-23 08:41:58 +01:00
2019-11-05 12:44:34 +01:00
2022-11-16 09:57:10 +01:00
2020-10-02 17:58:52 -06:00
2019-10-07 07:55:17 -03:00
2019-10-01 17:19:41 -03:00
2019-10-09 22:31:14 -04:00
2020-06-17 00:07:38 +02:00
2019-07-16 19:23:23 -07:00
2019-09-25 17:51:39 -07:00
2023-05-17 11:47:58 +02:00
2020-09-17 18:46:04 +02:00
2019-08-02 14:44:02 +10:00
2019-11-15 14:38:29 +01:00
2019-10-28 13:41:01 -07:00
2020-12-30 11:53:58 +01:00
2020-05-04 11:30:15 -05:00
2020-10-01 15:03:40 -04:00
2022-05-25 09:17:56 +02:00
2019-12-17 21:37:40 +05:30
2018-10-04 09:40:52 -07:00
2020-09-10 09:10:06 +02:00
2019-03-20 21:11:22 -04:00
2020-09-04 12:46:07 +01:00
2020-07-19 19:20:22 -07:00
2021-11-18 14:04:25 +01:00
2021-07-19 09:44:51 +02:00
2023-01-04 11:39:24 +01:00
2021-05-19 10:13:00 +02:00
2020-07-27 23:24:00 +02:00
2020-06-24 21:34:11 +02:00
2020-05-14 16:44:25 +02:00
2020-05-12 19:34:57 +03:00
2020-05-12 19:34:52 +03:00
2020-06-05 16:19:28 -07:00
2020-04-20 15:45:41 -06:00
2019-03-27 13:30:07 -07:00
2020-07-06 21:37:08 -07:00
2020-05-28 22:09:47 -04:00
2020-12-26 16:02:43 +01:00
2019-08-12 19:33:50 -07:00
2020-09-18 15:17:40 +02:00
2019-11-05 18:20:55 -08:00
2020-10-03 14:18:29 -07:00
2020-06-05 20:19:20 +02:00
2020-10-28 15:46:47 +01:00
2019-09-04 12:43:54 +02:00
2023-11-08 17:30:43 +01:00
2018-11-16 14:09:40 +08:00
2019-12-11 15:31:52 +01:00
2020-07-27 12:20:40 -07:00
2020-07-23 17:55:20 +00:00
2020-07-19 19:20:22 -07:00
2020-10-31 13:16:02 -07:00
2023-01-14 10:16:04 +01:00
2018-09-05 22:27:11 -07:00
2020-12-26 16:02:45 +01:00
2020-05-04 11:30:15 -05:00
2018-09-21 19:22:32 -07:00
2019-12-26 13:09:37 -08:00
2020-09-23 13:24:34 -07:00
2020-04-27 11:40:25 -07:00
2018-10-15 21:46:06 -07:00
2020-09-17 17:58:13 -07:00
2020-03-16 01:42:31 -07:00
2021-05-14 09:50:38 +02:00
2020-08-22 12:44:37 -07:00
2019-03-21 13:19:15 -07:00
2018-12-19 15:58:01 -08:00
2019-04-19 13:58:17 -07:00
2020-05-01 12:24:40 -07:00
2020-07-13 15:32:56 -07:00
2020-04-20 12:43:24 -07:00
2019-01-22 17:18:09 -08:00
2020-07-24 17:12:41 -07:00
2024-03-26 18:21:53 -04:00
2020-09-03 15:17:28 -07:00
2022-03-08 19:09:38 +01:00
2019-12-13 15:00:36 -08:00
2023-01-04 11:39:23 +01:00
2020-10-01 14:52:46 +02:00
2019-07-04 02:29:49 +02:00
2023-02-15 17:22:24 +01:00
2019-07-25 11:05:10 +02:00
2020-09-15 09:57:45 -05:00
2023-10-25 11:54:14 +02:00
2020-07-27 16:34:12 +03:00
2019-08-22 17:24:51 +02:00
2018-07-26 17:04:37 -07:00
2020-01-04 13:55:09 -08:00
2019-03-05 21:07:14 -08:00
2021-01-06 14:56:51 +01:00
2019-09-08 15:37:04 +02:00
2020-05-19 15:19:06 +01:00
2020-08-31 14:40:29 -04:00
2019-07-02 18:56:01 +02:00
2020-10-21 17:36:32 -04:00
2021-03-17 17:06:11 +01:00
2021-01-06 14:56:51 +01:00
2019-03-07 18:31:59 -08:00
2019-04-22 13:02:53 -04:00
2020-05-21 08:20:35 -06:00
2020-03-29 22:30:57 -07:00
2020-05-27 11:10:05 +02:00
2020-08-12 10:57:59 -07:00
2020-07-19 18:05:49 -07:00
2020-03-20 09:01:16 +01:00
2019-06-21 16:45:38 -04:00
2020-08-18 15:44:44 +02:00
2020-09-25 14:23:27 +02:00
2018-10-05 16:32:04 -07:00
2020-05-06 17:45:45 -07:00
2020-09-15 22:13:31 +10:00
2020-08-27 16:06:47 -04:00
2020-07-09 12:38:41 -07:00
2021-01-06 14:56:51 +01:00
2020-09-10 12:25:51 -07:00
2020-07-14 13:46:42 -07:00
2019-01-04 13:13:47 -08:00
2019-11-15 14:38:29 +01:00
2018-11-17 21:09:49 -08:00
2020-07-25 19:34:47 -06:00
2021-08-18 08:59:13 +02:00
2020-05-04 11:30:15 -05:00
2018-11-27 16:20:20 -08:00
2020-03-29 22:32:36 -07:00
2018-07-29 12:37:06 -07:00
2018-10-25 10:25:22 +02:00
2018-12-01 12:38:32 +01:00
2018-12-01 12:38:32 +01:00
2020-10-14 20:28:05 -07:00
2023-06-21 15:45:38 +02:00
2020-05-22 14:00:38 -07:00
2022-01-05 12:40:32 +01:00
2020-10-16 09:28:43 -04:00
2020-07-13 17:52:46 -04:00
2019-04-25 14:18:14 -04:00
2020-10-02 09:37:41 -04:00
2019-07-12 11:05:40 -07:00
2020-09-22 13:58:40 +02:00
2020-09-28 15:07:41 +02:00
2019-11-06 06:17:38 +09:00
2023-01-04 11:39:17 +01:00
2020-11-27 11:03:06 -08:00
2022-08-21 15:16:18 +02:00
2020-04-02 17:57:10 +01:00
2023-12-13 18:27:04 +01:00
2019-10-02 20:32:27 -06:00
2020-09-04 12:34:50 +02:00
2021-03-07 12:34:07 +01:00
2021-09-22 12:28:05 +02:00
2019-01-22 10:21:45 +01:00
2019-07-30 20:34:34 +02:00
2019-12-01 14:00:59 -08:00
2019-10-23 17:23:47 +02:00
2020-09-04 12:46:07 +01:00
2021-03-30 14:31:53 +02:00
2019-04-16 23:05:21 +02:00
2020-04-30 15:19:33 +10:00
2020-07-19 19:22:56 -07:00
2020-12-21 13:30:06 +01:00
2020-01-07 16:07:01 -05:00
2020-07-10 14:50:51 +02:00
2020-06-25 16:26:25 -07:00
2020-08-04 20:16:37 -07:00
2019-11-15 14:38:29 +01:00
2020-03-29 22:30:57 -07:00
2021-02-03 23:28:43 +01:00
2022-04-08 14:40:03 +02:00
2020-05-11 16:04:35 +02:00
2020-07-02 14:19:15 -07:00
2020-10-05 16:35:57 +01:00
2019-12-04 19:44:12 -08:00
2020-02-12 17:57:51 -05:00
2019-11-08 14:18:32 -08:00
2020-07-14 16:29:42 -07:00
2019-11-04 07:11:31 -07:00
2020-08-03 17:57:40 -07:00
2019-11-15 14:38:29 +01:00
2020-07-06 14:06:08 +02:00
2021-09-18 13:40:22 +02:00
2018-10-02 13:38:55 -07:00
2020-03-24 15:59:34 -07:00
2019-11-15 14:38:29 +01:00
2018-10-07 21:06:28 -07:00
2020-09-24 20:15:45 -07:00
2020-02-27 18:50:19 -08:00
2019-08-03 11:02:46 -07:00
2019-04-19 14:07:40 -07:00
2020-12-03 10:03:14 -08:00
2024-02-23 08:42:18 +01:00
2023-01-14 10:16:04 +01:00
2020-01-15 11:00:39 -06:00
2023-09-19 12:20:18 +02:00
2021-01-06 14:56:51 +01:00
2020-07-28 22:25:30 -04:00
2019-12-18 18:07:31 +01:00
2021-11-26 10:39:14 +01:00
2020-08-21 08:55:13 +02:00
2021-09-12 08:58:27 +02:00
2020-07-07 15:55:21 +02:00
2019-12-18 18:07:33 +01:00
2020-02-21 11:22:15 -08:00
2019-12-18 18:07:33 +01:00
2019-10-04 14:25:17 -07:00
2020-09-18 13:58:37 -07:00
2020-09-18 13:58:37 -07:00
2019-08-31 23:44:28 -07:00
2021-05-14 09:50:18 +02:00
2020-08-12 10:57:59 -07:00
2018-09-03 13:29:38 +02:00
2019-12-09 09:59:07 +01:00
2020-03-29 23:29:08 +02:00
2019-05-22 10:36:35 -07:00
2019-08-14 16:52:13 +02:00
2020-04-07 10:43:39 -07:00
2019-11-15 14:38:29 +01:00
2023-03-11 16:40:16 +01:00
2018-11-20 13:22:40 -05:00
2020-09-14 15:39:42 +02:00
2020-09-26 10:22:29 +02:00
2021-01-30 13:55:18 +01:00
2020-07-10 13:45:32 +02:00
2020-07-10 13:45:32 +02:00
2020-06-03 11:27:43 +02:00
2020-10-07 14:23:44 -06:00
2020-10-12 11:41:02 -06:00
2020-10-23 11:55:28 -04:00
2020-10-23 11:55:28 -04:00
2023-07-27 08:44:03 +02:00
2020-08-05 09:30:19 -04:00
2020-08-05 09:30:20 -04:00
2020-08-05 11:08:39 -04:00
2020-08-03 16:11:42 -04:00
2020-08-05 11:08:39 -04:00
2024-01-25 14:37:41 -08:00
2020-09-10 11:39:22 +02:00
2020-08-18 14:14:25 +02:00
2020-06-04 15:36:52 -04:00
2020-08-05 11:08:40 -04:00
2020-08-05 11:08:40 -04:00
2020-08-05 11:08:40 -04:00
2020-09-10 10:05:58 +02:00
2020-08-05 11:08:41 -04:00
2020-09-10 10:05:58 +02:00
2020-08-05 11:08:40 -04:00
2020-06-02 02:45:13 -04:00
2020-08-05 11:08:40 -04:00
2019-12-11 15:01:23 -08:00
2019-07-25 11:05:10 +02:00
2019-08-01 21:49:46 +02:00
2020-05-19 15:19:06 +01:00
2019-12-16 19:22:22 -08:00
2020-07-31 09:24:23 +02:00
2019-07-25 11:05:10 +02:00
2020-06-12 13:23:34 -04:00
2020-07-13 15:32:56 -07:00
2022-05-25 09:18:02 +02:00