On 11/03/2024 10:28, Amit Daniel Kachhap wrote:
diff --git a/include/linux/user_ptr.h b/include/linux/user_ptr.h index 685586bc0d89..d663c6105d54 100644 --- a/include/linux/user_ptr.h +++ b/include/linux/user_ptr.h @@ -2,6 +2,7 @@ #ifndef _LINUX_USER_PTR_H #define _LINUX_USER_PTR_H +#include <linux/cheri.h> #include <linux/limits.h> #include <linux/typecheck.h> @@ -27,6 +28,8 @@ #ifdef CONFIG_CHERI_PURECAP_UABI +#define user_ptr_perms_t cheri_perms_t
This should really be a typedef. I suppose this should be a separate patch as well.
Note in passing: I was trying quite hard not to include linux/cheri.h in linux/user_ptr.h, because the latter is itself included in linux/kernel.h and therefore everywhere. That's why the builtins are used directly instead of the cheriintrin.h wrappers. However, I can't see an easy to avoid the include if we're going to use cheri_perms_t. I suppose we can live with cheri.h being included everywhere.
Kevin
/**
- uaddr_to_user_ptr() - Convert a user-provided address to a user pointer.
- @addr: The address to set the pointer to.
@@ -109,6 +112,8 @@ bool check_user_ptr_rw(void __user *ptr, size_t len); #else /* CONFIG_CHERI_PURECAP_UABI */ +#define user_ptr_perms_t int
static inline void __user *uaddr_to_user_ptr(ptraddr_t addr) { return as_user_ptr(addr);