Check for PCuABI and modify function declarations accordingly, changing user** into * __capability * __capability.
Signed-off-by: Joshua Lant joshualant@gmail.com --- net/bridge/netfilter/ebtables.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index 99d82676f780..091f00bd6b6b 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c @@ -1633,7 +1633,12 @@ static int ebt_compat_match_offset(const struct xt_match *match, return xt_compat_match_offset(match); }
+#ifdef CONFIG_CHERI_PURECAP_UABI +static int compat_match_to_user(struct ebt_entry_match *m, + void *__capability *__capability dstptr, +#else static int compat_match_to_user(struct ebt_entry_match *m, void __user **dstptr, +#endif unsigned int *size) { const struct xt_match *match = m->u.match; @@ -1664,8 +1669,13 @@ static int compat_match_to_user(struct ebt_entry_match *m, void __user **dstptr, return 0; }
+#ifdef CONFIG_CHERI_PURECAP_UABI +static int compat_target_to_user(struct ebt_entry_target *t, + void *__capability *__capability dstptr, +#else static int compat_target_to_user(struct ebt_entry_target *t, void __user **dstptr, +#endif unsigned int *size) { const struct xt_target *target = t->u.target; @@ -1696,15 +1706,25 @@ static int compat_target_to_user(struct ebt_entry_target *t, return 0; }
+#ifdef CONFIG_CHERI_PURECAP_UABI +static int compat_watcher_to_user(struct ebt_entry_watcher *w, + void *__capability *__capability dstptr, +#else static int compat_watcher_to_user(struct ebt_entry_watcher *w, void __user **dstptr, +#endif unsigned int *size) { return compat_target_to_user((struct ebt_entry_target *)w, dstptr, size); }
+#ifdef CONFIG_CHERI_PURECAP_UABI +static int compat_copy_entry_to_user(struct ebt_entry *e, + void *__capability *__capability dstptr, +#else static int compat_copy_entry_to_user(struct ebt_entry *e, void __user **dstptr, +#endif unsigned int *size) { struct ebt_entry_target *t;
On 14/08/2024 10:10, Joshua Lant wrote:
Check for PCuABI and modify function declarations accordingly, changing user** into * __capability * __capability.
Signed-off-by: Joshua Lant joshualant@gmail.com
net/bridge/netfilter/ebtables.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index 99d82676f780..091f00bd6b6b 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c @@ -1633,7 +1633,12 @@ static int ebt_compat_match_offset(const struct xt_match *match, return xt_compat_match_offset(match); } +#ifdef CONFIG_CHERI_PURECAP_UABI +static int compat_match_to_user(struct ebt_entry_match *m,
void *__capability *__capability dstptr,
This is equivalent to void __user * __user * (user pointer to user pointer). What we want is a kernel pointer to a user pointer, so: void * __capability *
+#else static int compat_match_to_user(struct ebt_entry_match *m, void __user **dstptr, +#endif unsigned int *size) { const struct xt_match *match = m->u.match; @@ -1664,8 +1669,13 @@ static int compat_match_to_user(struct ebt_entry_match *m, void __user **dstptr, return 0; } +#ifdef CONFIG_CHERI_PURECAP_UABI +static int compat_target_to_user(struct ebt_entry_target *t,
This line could be out of the #if as well. In fact this could be done in the first and last case too if we move the void __user ** to its own line.
Also nit: better to align the continuation lines with the existing ones.
Kevin
void *__capability *__capability dstptr,
+#else static int compat_target_to_user(struct ebt_entry_target *t, void __user **dstptr, +#endif unsigned int *size) { const struct xt_target *target = t->u.target; @@ -1696,15 +1706,25 @@ static int compat_target_to_user(struct ebt_entry_target *t, return 0; } +#ifdef CONFIG_CHERI_PURECAP_UABI +static int compat_watcher_to_user(struct ebt_entry_watcher *w,
void *__capability *__capability dstptr,
+#else static int compat_watcher_to_user(struct ebt_entry_watcher *w, void __user **dstptr, +#endif unsigned int *size) { return compat_target_to_user((struct ebt_entry_target *)w, dstptr, size); } +#ifdef CONFIG_CHERI_PURECAP_UABI +static int compat_copy_entry_to_user(struct ebt_entry *e,
void *__capability *__capability dstptr,
+#else static int compat_copy_entry_to_user(struct ebt_entry *e, void __user **dstptr, +#endif unsigned int *size) { struct ebt_entry_target *t;
linux-morello@op-lists.linaro.org