Re: [PATCH 3/6] PKEY: Apply PKEY_ENFORCE_API to mprotect

From: Dave Hansen
Date: Tue May 16 2023 - 19:19:20 EST


On 5/15/23 06:05, jeffxu@xxxxxxxxxxxx wrote:
> /*
> * pkey==-1 when doing a legacy mprotect()
> + * syscall==true if this is called by syscall from userspace.
> + * Note: this is always true for now, added as a reminder in case that
> + * do_mprotect_pkey is called directly by kernel in the future.
> + * Also it is consistent with __do_munmap().
> */
> static int do_mprotect_pkey(unsigned long start, size_t len,
> - unsigned long prot, int pkey)
> + unsigned long prot, int pkey, bool syscall)
> {

The 'syscall' seems kinda silly (and a bit confusing). It's easy to
check if the caller is a kthread or has a current->mm==NULL. If you
*really* want a warning, I'd check for those rather than plumb a
apparently unused argument in here.

BTW, this warning is one of those things that will probably cause some
amount of angst. I'd move it to the end of the series or just axe it
completely.