[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200122185111.GK2437@uranus>
Date: Wed, 22 Jan 2020 21:51:11 +0300
From: Cyrill Gorcunov <gorcunov@...il.com>
To: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: linux-kernel@...r.kernel.org, alex.shi@...ux.alibaba.com,
tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, hpa@...or.com,
x86@...nel.org, bigeasy@...utronix.de,
pankaj.laxminarayan.bharadiya@...el.com, aubrey.li@...ux.intel.com,
dave.hansen@...el.com
Subject: Re: [PATCH] x86/pkeys: add check for pkey "overflow"
On Wed, Jan 22, 2020 at 08:53:46AM -0800, Dave Hansen wrote:
>
> Alex Shi reported the pkey macros above arch_set_user_pkey_access()
> to be unused. They are unused, and even refer to a nonexistent
> CONFIG option.
>
> @@ -922,6 +920,13 @@ int arch_set_user_pkey_access(struct tas
> if (!boot_cpu_has(X86_FEATURE_OSPKE))
> return -EINVAL;
>
> + /*
> + * This code should only be called with valid 'pkey'
> + * values originating from in-kernel users. Complain
> + * if a bad value is observed.
> + */
> + WARN_ON_ONCE(pkey >= arch_max_pkey());
Should not we rather abort this operation and exit with EINVAL
or something similar instead of calling wrmsr with overflowed
value? IOW,
if (pkey >= arch_max_pkey()) {
WARN_ON_ONCE(1);
return -EINVAL;
}
Powered by blists - more mailing lists