On 12/08/2024 16:11, Joshua Lant wrote:
Kernel pointer in uapi struct causes alignment issues moving between user-space and kernel-space. Change this to an unsigned int and make
Nit: s/unsigned int/unsigned long/
kernel accesses explicitly cast back to pointer.
Signed-off-by: Joshua Lant joshualant@gmail.com
include/uapi/linux/netfilter/x_tables.h | 2 +- net/ipv4/netfilter/ip_tables.c | 18 +++++++++--------- net/ipv6/netfilter/ip6_tables.c | 18 +++++++++--------- net/netfilter/x_tables.c | 16 ++++++++-------- net/netfilter/xt_TCPMSS.c | 2 +- 5 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/include/uapi/linux/netfilter/x_tables.h b/include/uapi/linux/netfilter/x_tables.h index 796af83a963a..0122c4624886 100644 --- a/include/uapi/linux/netfilter/x_tables.h +++ b/include/uapi/linux/netfilter/x_tables.h @@ -21,7 +21,7 @@ struct xt_entry_match { __u16 match_size; /* Used inside the kernel */
struct xt_match *match;
} kernel;unsigned long match;
/* Total length */ diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index a54c54d4ba9c..236c2a7abad7 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c @@ -288,7 +288,7 @@ ipt_do_table(void *priv, } xt_ematch_foreach(ematch, e) {
acpar.match = ematch->u.kernel.match;
acpar.match = (const struct xt_match *) ematch->u.kernel.match;
Nit: preferably no space between the cast and the variable.
[...]
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index caf838d56f4d..2e347789593a 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -306,8 +306,8 @@ static int xt_obj_to_user(u16 __user *psize, u16 size, #define XT_OBJ_TO_USER(U, K, TYPE, C_SIZE) \ xt_obj_to_user(&U->u.TYPE##_size, C_SIZE ? : K->u.TYPE##_size, \
U->u.user.name, K->u.kernel.TYPE->name, \
&U->u.user.revision, K->u.kernel.TYPE->revision)
U->u.user.name, ((struct xt_##TYPE *)(K->u.kernel.TYPE))->name, \
&U->u.user.revision, ((struct xt_##TYPE *)(K->u.kernel.TYPE))->revision)
Nit: you can omit the parentheses around the expression to cast, i.e. K->u.kernel.TYPE.
Kevin
[...]