All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Dave Hansen <dave.hansen@intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>,
	linux-kernel@vger.kernel.org, alex.shi@linux.alibaba.com,
	tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	hpa@zytor.com, x86@kernel.org, bigeasy@linutronix.de,
	pankaj.laxminarayan.bharadiya@intel.com,
	aubrey.li@linux.intel.com
Subject: Re: [PATCH] x86/pkeys: add check for pkey "overflow"
Date: Wed, 22 Jan 2020 22:29:44 +0300	[thread overview]
Message-ID: <20200122192944.GL2437@uranus> (raw)
In-Reply-To: <99b572a5-6a98-d22a-01f1-8bab60e96155@intel.com>

On Wed, Jan 22, 2020 at 11:09:47AM -0800, Dave Hansen wrote:
> 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.

OK, I don't mind leaving just WARN_ON_ONCE.

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

Heh :)

  reply	other threads:[~2020-01-22 19:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-22 16:53 [PATCH] x86/pkeys: add check for pkey "overflow" Dave Hansen
2020-01-22 18:51 ` Cyrill Gorcunov
2020-01-22 19:09   ` Dave Hansen
2020-01-22 19:29     ` Cyrill Gorcunov [this message]
2020-02-24 19:38 ` [tip: x86/fpu] x86/pkeys: Add " tip-bot2 for Dave Hansen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200122192944.GL2437@uranus \
    --to=gorcunov@gmail.com \
    --cc=alex.shi@linux.alibaba.com \
    --cc=aubrey.li@linux.intel.com \
    --cc=bigeasy@linutronix.de \
    --cc=bp@alien8.de \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pankaj.laxminarayan.bharadiya@intel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.