On morello architecture, use of kernel pointers in the uapi structures is not permitted, due to different alignment requirements between kernel and userspace. These pointers should be the new type __nf_kptr_t, whose size changes depening on the pc/non-pcUABI. Modify these to use a union which will be accessed in the kernel using the original member pointer, but will actually be of size __nf_kptr_t, avoiding heavy casting needed when using to new type directly.
Signed-off-by: Joshua Lant joshualant@gmail.com --- include/uapi/linux/netfilter/xt_CT.h | 10 +++++++-- include/uapi/linux/netfilter/xt_IDLETIMER.h | 12 +++++++++-- include/uapi/linux/netfilter/xt_RATEEST.h | 6 +++++- include/uapi/linux/netfilter/xt_TEE.h | 6 +++++- include/uapi/linux/netfilter/xt_bpf.h | 12 +++++++++-- include/uapi/linux/netfilter/xt_connlimit.h | 6 +++++- include/uapi/linux/netfilter/xt_hashlimit.h | 24 +++++++++++++++++---- include/uapi/linux/netfilter/xt_limit.h | 6 +++++- include/uapi/linux/netfilter/xt_nfacct.h | 12 +++++++++-- include/uapi/linux/netfilter/xt_quota.h | 6 +++++- include/uapi/linux/netfilter/xt_rateest.h | 9 ++++++-- include/uapi/linux/netfilter/xt_statistic.h | 6 +++++- 12 files changed, 95 insertions(+), 20 deletions(-)
diff --git a/include/uapi/linux/netfilter/xt_CT.h b/include/uapi/linux/netfilter/xt_CT.h index 868fa08e1fbb..3fd5e53d7627 100644 --- a/include/uapi/linux/netfilter/xt_CT.h +++ b/include/uapi/linux/netfilter/xt_CT.h @@ -24,7 +24,10 @@ struct xt_ct_target_info { char helper[16];
/* Used internally by the kernel */ - struct nf_conn *ct __attribute__((aligned(8))); + union { + struct nf_conn *ct __attribute__((aligned(8))); + __nf_kptr_t __ct __attribute__((aligned(8))); + }; };
struct xt_ct_target_info_v1 { @@ -36,7 +39,10 @@ struct xt_ct_target_info_v1 { char timeout[32];
/* Used internally by the kernel */ - struct nf_conn *ct __attribute__((aligned(8))); + union { + struct nf_conn *ct __attribute__((aligned(8))); + __nf_kptr_t __ct __attribute__((aligned(8))); + }; };
#endif /* _XT_CT_H */ diff --git a/include/uapi/linux/netfilter/xt_IDLETIMER.h b/include/uapi/linux/netfilter/xt_IDLETIMER.h index 7bfb31a66fc9..81c3aedaae13 100644 --- a/include/uapi/linux/netfilter/xt_IDLETIMER.h +++ b/include/uapi/linux/netfilter/xt_IDLETIMER.h @@ -25,7 +25,11 @@ struct idletimer_tg_info { char label[MAX_IDLETIMER_LABEL_SIZE];
/* for kernel module internal use only */ - struct idletimer_tg *timer __attribute__((aligned(8))); + /* corresponds to the idletimer_tg struct */ + union { + struct idletimer_tg *timer __attribute__((aligned(8))); + __nf_kptr_t __timer __attribute__((aligned(8))); + }; };
struct idletimer_tg_info_v1 { @@ -37,6 +41,10 @@ struct idletimer_tg_info_v1 { __u8 timer_type;
/* for kernel module internal use only */ - struct idletimer_tg *timer __attribute__((aligned(8))); + /* corresponds to the idletimer_tg struct */ + union { + struct idletimer_tg *timer __attribute__((aligned(8))); + __nf_kptr_t __timer __attribute__((aligned(8))); + }; }; #endif diff --git a/include/uapi/linux/netfilter/xt_RATEEST.h b/include/uapi/linux/netfilter/xt_RATEEST.h index 2b87a71e6266..eae8ea1004a8 100644 --- a/include/uapi/linux/netfilter/xt_RATEEST.h +++ b/include/uapi/linux/netfilter/xt_RATEEST.h @@ -11,7 +11,11 @@ struct xt_rateest_target_info { __u8 ewma_log;
/* Used internally by the kernel */ - struct xt_rateest *est __attribute__((aligned(8))); + /* Corresponds to struct xt_rateest */ + union { + struct xt_rateest *est __attribute__((aligned(8))); + __nf_kptr_t __est __attribute__((aligned(8))); + }; };
#endif /* _XT_RATEEST_TARGET_H */ diff --git a/include/uapi/linux/netfilter/xt_TEE.h b/include/uapi/linux/netfilter/xt_TEE.h index eb854917f828..f46019a1fc03 100644 --- a/include/uapi/linux/netfilter/xt_TEE.h +++ b/include/uapi/linux/netfilter/xt_TEE.h @@ -9,7 +9,11 @@ struct xt_tee_tginfo { char oif[16];
/* used internally by the kernel */ - struct xt_tee_priv *priv __attribute__((aligned(8))); + /* Corresponds to struct xt_tee_priv */ + union { + struct xt_tee_priv *priv __attribute__((aligned(8))); + __nf_kptr_t __priv __attribute__((aligned(8))); + }; };
#endif /* _XT_TEE_TARGET_H */ diff --git a/include/uapi/linux/netfilter/xt_bpf.h b/include/uapi/linux/netfilter/xt_bpf.h index a05adda26d3e..3d2c08de0b08 100644 --- a/include/uapi/linux/netfilter/xt_bpf.h +++ b/include/uapi/linux/netfilter/xt_bpf.h @@ -16,7 +16,11 @@ struct xt_bpf_info { struct sock_filter bpf_program[XT_BPF_MAX_NUM_INSTR];
/* only used in the kernel */ - struct bpf_prog *filter __attribute__((aligned(8))); + /* Corresponds to the bpf_prog* struct */ + union { + struct bpf_prog *filter __attribute__((aligned(8))); + __nf_kptr_t __filter __attribute__((aligned(8))); + }; };
enum xt_bpf_modes { @@ -36,7 +40,11 @@ struct xt_bpf_info_v1 { };
/* only used in the kernel */ - struct bpf_prog *filter __attribute__((aligned(8))); + /* Corresponds to the bpf_prog* struct */ + union { + struct bpf_prog *filter __attribute__((aligned(8))); + __nf_kptr_t __filter __attribute__((aligned(8))); + }; };
#endif /*_XT_BPF_H */ diff --git a/include/uapi/linux/netfilter/xt_connlimit.h b/include/uapi/linux/netfilter/xt_connlimit.h index d4d1943dcd11..57459493d292 100644 --- a/include/uapi/linux/netfilter/xt_connlimit.h +++ b/include/uapi/linux/netfilter/xt_connlimit.h @@ -27,7 +27,11 @@ struct xt_connlimit_info { __u32 flags;
/* Used internally by the kernel */ - struct nf_conncount_data *data __attribute__((aligned(8))); + /* Corresponds to the struct nf_conncount_data * */ + union { + struct nf_conncount_data *data __attribute__((aligned(8))); + __nf_kptr_t __data __attribute__((aligned(8))); + }; };
#endif /* _XT_CONNLIMIT_H */ diff --git a/include/uapi/linux/netfilter/xt_hashlimit.h b/include/uapi/linux/netfilter/xt_hashlimit.h index 721a8de6c5b3..81ee6fd5ae3c 100644 --- a/include/uapi/linux/netfilter/xt_hashlimit.h +++ b/include/uapi/linux/netfilter/xt_hashlimit.h @@ -46,10 +46,14 @@ struct xt_hashlimit_info { struct hashlimit_cfg cfg;
/* Used internally by the kernel */ - struct xt_hashlimit_htable *hinfo; + /* Corresponds to struct xt_hashlimit_htable * */ + __nf_kptr_t hinfo; union { + /* Corresponds to struct xt_hashlimit_info *, or generic void ptr */ void *ptr; + __nf_kptr_t __ptr; struct xt_hashlimit_info *master; + __nf_kptr_t __master; } u; };
@@ -101,7 +105,11 @@ 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 * */ + union { + struct xt_hashlimit_htable *hinfo __attribute__((aligned(8))); + __nf_kptr_t __hinfo __attribute__((aligned(8))); + }; };
struct xt_hashlimit_mtinfo2 { @@ -109,7 +117,11 @@ 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 * */ + union { + struct xt_hashlimit_htable *hinfo __attribute__((aligned(8))); + __nf_kptr_t __hinfo __attribute__((aligned(8))); + }; };
struct xt_hashlimit_mtinfo3 { @@ -117,7 +129,11 @@ 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 * */ + union { + struct xt_hashlimit_htable *hinfo __attribute__((aligned(8))); + __nf_kptr_t __hinfo __attribute__((aligned(8))); + }; };
#endif /* _UAPI_XT_HASHLIMIT_H */ diff --git a/include/uapi/linux/netfilter/xt_limit.h b/include/uapi/linux/netfilter/xt_limit.h index 1d6e4ce9a646..adfe83e6f784 100644 --- a/include/uapi/linux/netfilter/xt_limit.h +++ b/include/uapi/linux/netfilter/xt_limit.h @@ -20,6 +20,10 @@ struct xt_rateinfo { __u32 credit; /* moved to xt_limit_priv */ __u32 credit_cap, cost;
- struct xt_limit_priv *master; + /* Corresponds to the xt_limit_priv* struct */ + union { + struct xt_limit_priv *master; + __nf_kptr_t __master; + }; }; #endif /*_XT_RATE_H*/ diff --git a/include/uapi/linux/netfilter/xt_nfacct.h b/include/uapi/linux/netfilter/xt_nfacct.h index b5123ab8d54a..2ff8c34519b2 100644 --- a/include/uapi/linux/netfilter/xt_nfacct.h +++ b/include/uapi/linux/netfilter/xt_nfacct.h @@ -8,12 +8,20 @@ struct nf_acct;
struct xt_nfacct_match_info { char name[NFACCT_NAME_MAX]; - struct nf_acct *nfacct; + /* Corresponds to the nf_acct* struct */ + union { + struct nf_acct *nfacct; + __nf_kptr_t __nfacct; + }; };
struct xt_nfacct_match_info_v1 { char name[NFACCT_NAME_MAX]; - struct nf_acct *nfacct __attribute__((aligned(8))); + /* Corresponds to the nf_acct* struct */ + union { + struct nf_acct *nfacct __attribute__((aligned(8))); + __nf_kptr_t __nfacct __attribute__((aligned(8))); + }; };
#endif /* _XT_NFACCT_MATCH_H */ diff --git a/include/uapi/linux/netfilter/xt_quota.h b/include/uapi/linux/netfilter/xt_quota.h index f3ba5d9e58b6..6cb962e3806f 100644 --- a/include/uapi/linux/netfilter/xt_quota.h +++ b/include/uapi/linux/netfilter/xt_quota.h @@ -17,7 +17,11 @@ struct xt_quota_info { __aligned_u64 quota;
/* Used internally by the kernel */ - struct xt_quota_priv *master; + /* Corresponds to xt_quota_priv* */ + union { + struct xt_quota_priv *master; + __nf_kptr_t __master; + }; };
#endif /* _XT_QUOTA_H */ diff --git a/include/uapi/linux/netfilter/xt_rateest.h b/include/uapi/linux/netfilter/xt_rateest.h index 52a37bdc1837..4db78e9d887b 100644 --- a/include/uapi/linux/netfilter/xt_rateest.h +++ b/include/uapi/linux/netfilter/xt_rateest.h @@ -32,8 +32,13 @@ struct xt_rateest_match_info { __u32 pps2;
/* Used internally by the kernel */ - struct xt_rateest *est1 __attribute__((aligned(8))); - struct xt_rateest *est2 __attribute__((aligned(8))); + /* Corresponds to struct xt_rateest* */ + union { + struct xt_rateest *est1 __attribute__((aligned(8))); + __nf_kptr_t __est1 __attribute__((aligned(8))); + struct xt_rateest *est2 __attribute__((aligned(8))); + __nf_kptr_t __est2 __attribute__((aligned(8))); + }; };
#endif /* _XT_RATEEST_MATCH_H */ diff --git a/include/uapi/linux/netfilter/xt_statistic.h b/include/uapi/linux/netfilter/xt_statistic.h index bbce6fcb26e3..9d1bfa6ce662 100644 --- a/include/uapi/linux/netfilter/xt_statistic.h +++ b/include/uapi/linux/netfilter/xt_statistic.h @@ -31,7 +31,11 @@ struct xt_statistic_info { __u32 count; /* unused */ } nth; } u; - struct xt_statistic_priv *master __attribute__((aligned(8))); + /* Corresponds to struct xt_statistic_priv * */ + union { + struct xt_statistic_priv *master __attribute__((aligned(8))); + __nf_kptr_t __master __attribute__((aligned(8))); + }; };
#endif /* _XT_STATISTIC_H */