On 02/09/2024 17:02, Joshua Lant wrote:
On morello architecture, use of kernel pointers in the uapi structures is not permitted, due to different alignment requirements. Modify these to be __nf_kptr_t.
Signed-off-by: Joshua Lant joshualant@gmail.com
include/uapi/linux/netfilter/xt_hashlimit.h | 17 +++++++++------ net/netfilter/xt_hashlimit.c | 24 +++++++++++---------- 2 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/include/uapi/linux/netfilter/xt_hashlimit.h b/include/uapi/linux/netfilter/xt_hashlimit.h index 721a8de6c5b3..05794305da1d 100644 --- a/include/uapi/linux/netfilter/xt_hashlimit.h +++ b/include/uapi/linux/netfilter/xt_hashlimit.h @@ -46,10 +46,12 @@ struct xt_hashlimit_info { struct hashlimit_cfg cfg; /* Used internally by the kernel */
- struct xt_hashlimit_htable *hinfo;
- /* Corresponds to struct xt_hashlimit_htable **/
Nit: still a space missing before */ (here and comments below).
Kevin
- __nf_kptr_t hinfo; union {
void *ptr;
struct xt_hashlimit_info *master;
/* Corresponds to struct xt_hashlimit_info *, or generic void ptr*/
__nf_kptr_t ptr;
} u;__nf_kptr_t master;
}; @@ -101,7 +103,8 @@ struct xt_hashlimit_mtinfo1 { struct hashlimit_cfg1 cfg; /* Used internally by the kernel */
- struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
- /* Corresponds to struct xt_hashlimit_htable **/
- __nf_kptr_t hinfo __attribute__((aligned(8)));
}; struct xt_hashlimit_mtinfo2 { @@ -109,7 +112,8 @@ struct xt_hashlimit_mtinfo2 { struct hashlimit_cfg2 cfg; /* Used internally by the kernel */
- struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
- /* Corresponds to struct xt_hashlimit_htable **/
- __nf_kptr_t hinfo __attribute__((aligned(8)));
}; struct xt_hashlimit_mtinfo3 { @@ -117,7 +121,8 @@ struct xt_hashlimit_mtinfo3 { struct hashlimit_cfg3 cfg; /* Used internally by the kernel */
- struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
- /* Corresponds to struct xt_hashlimit_htable **/
- __nf_kptr_t hinfo __attribute__((aligned(8)));
}; #endif /* _UAPI_XT_HASHLIMIT_H */ diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c index 0859b8f76764..2f3e71220fb7 100644 --- a/net/netfilter/xt_hashlimit.c +++ b/net/netfilter/xt_hashlimit.c @@ -798,7 +798,7 @@ static bool hashlimit_mt_v1(const struct sk_buff *skb, struct xt_action_param *par) { const struct xt_hashlimit_mtinfo1 *info = par->matchinfo;
- struct xt_hashlimit_htable *hinfo = info->hinfo;
- struct xt_hashlimit_htable *hinfo = (struct xt_hashlimit_htable *)info->hinfo; struct hashlimit_cfg3 cfg = {}; int ret;
@@ -813,7 +813,7 @@ static bool hashlimit_mt_v2(const struct sk_buff *skb, struct xt_action_param *par) { const struct xt_hashlimit_mtinfo2 *info = par->matchinfo;
- struct xt_hashlimit_htable *hinfo = info->hinfo;
- struct xt_hashlimit_htable *hinfo = (struct xt_hashlimit_htable *)info->hinfo; struct hashlimit_cfg3 cfg = {}; int ret;
@@ -828,7 +828,7 @@ static bool hashlimit_mt(const struct sk_buff *skb, struct xt_action_param *par) { const struct xt_hashlimit_mtinfo3 *info = par->matchinfo;
- struct xt_hashlimit_htable *hinfo = info->hinfo;
- struct xt_hashlimit_htable *hinfo = (struct xt_hashlimit_htable *)info->hinfo;
return hashlimit_mt_common(skb, par, hinfo, &info->cfg, 3); } @@ -912,6 +912,7 @@ static int hashlimit_mt_check_v1(const struct xt_mtchk_param *par) struct xt_hashlimit_mtinfo1 *info = par->matchinfo; struct hashlimit_cfg3 cfg = {}; int ret;
- struct xt_hashlimit_htable *hinfo_tmp = (struct xt_hashlimit_htable *)info->hinfo;
ret = xt_check_proc_name(info->name, sizeof(info->name)); if (ret) @@ -921,8 +922,7 @@ static int hashlimit_mt_check_v1(const struct xt_mtchk_param *par) if (ret) return ret;
- return hashlimit_mt_check_common(par, &info->hinfo,
&cfg, info->name, 1);
- return hashlimit_mt_check_common(par, &hinfo_tmp, &cfg, info->name, 1);
} static int hashlimit_mt_check_v2(const struct xt_mtchk_param *par) @@ -930,6 +930,7 @@ static int hashlimit_mt_check_v2(const struct xt_mtchk_param *par) struct xt_hashlimit_mtinfo2 *info = par->matchinfo; struct hashlimit_cfg3 cfg = {}; int ret;
- struct xt_hashlimit_htable *hinfo_tmp = (struct xt_hashlimit_htable *)info->hinfo;
ret = xt_check_proc_name(info->name, sizeof(info->name)); if (ret) @@ -939,7 +940,7 @@ static int hashlimit_mt_check_v2(const struct xt_mtchk_param *par) if (ret) return ret;
- return hashlimit_mt_check_common(par, &info->hinfo,
- return hashlimit_mt_check_common(par, &hinfo_tmp, &cfg, info->name, 2);
} @@ -947,34 +948,35 @@ static int hashlimit_mt_check(const struct xt_mtchk_param *par) { struct xt_hashlimit_mtinfo3 *info = par->matchinfo; int ret;
- struct xt_hashlimit_htable *hinfo_tmp = (struct xt_hashlimit_htable *)info->hinfo;
ret = xt_check_proc_name(info->name, sizeof(info->name)); if (ret) return ret;
- return hashlimit_mt_check_common(par, &info->hinfo, &info->cfg,
info->name, 3);
- return hashlimit_mt_check_common(par, &hinfo_tmp, &info->cfg,
info->name, 3);
} static void hashlimit_mt_destroy_v2(const struct xt_mtdtor_param *par) { const struct xt_hashlimit_mtinfo2 *info = par->matchinfo;
- htable_put(info->hinfo);
- htable_put((struct xt_hashlimit_htable *)info->hinfo);
} static void hashlimit_mt_destroy_v1(const struct xt_mtdtor_param *par) { const struct xt_hashlimit_mtinfo1 *info = par->matchinfo;
- htable_put(info->hinfo);
- htable_put((struct xt_hashlimit_htable *)info->hinfo);
} static void hashlimit_mt_destroy(const struct xt_mtdtor_param *par) { const struct xt_hashlimit_mtinfo3 *info = par->matchinfo;
- htable_put(info->hinfo);
- htable_put((struct xt_hashlimit_htable *)info->hinfo);
} static struct xt_match hashlimit_mt_reg[] __read_mostly = {