lkml.org 
[lkml]   [2020]   [Jan]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] x86/pkeys: add check for pkey "overflow"
From
Date
On 1/22/20 10:51 AM, Cyrill Gorcunov wrote:
>> + /*
>> + * 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;
> }

I don't feel strongly about it. The reason I didn't do that is to
minimize the chance that this would cause any functional regression.

It's not a huge chance, but I've certainly fat-fingered my share of
off-by-one bugs.

\
 
 \ /
  Last update: 2020-01-22 20:10    [W:0.055 / U:0.824 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site