From: ebiggers3@gmail.com (Eric Biggers)
To: linux-security-module@vger.kernel.org
Subject: [PATCH] KEYS: fix dereferencing NULL payload with nonzero length
Date: Mon, 3 Apr 2017 14:30:41 -0700 [thread overview]
Message-ID: <20170403213041.GA140817@gmail.com> (raw)
In-Reply-To: <6884.1491247244@warthog.procyon.org.uk>
On Mon, Apr 03, 2017 at 08:20:44PM +0100, David Howells wrote:
> Eric Biggers <ebiggers3@gmail.com> wrote:
>
> > > > - if (_payload) {
> > > > + if (plen) {
> > >
> > > "if (_payload && plen)" would be better.
> > >
> > > David
> >
> > No, that doesn't solve the problem. The problem is that userspace can pass
> > in a NULL payload with nonzero length, causing the kernel to dereference a
> > NULL pointer for some key types. For example:
>
> Okay, in that case, I think there should be an else-statement that clears plen
> if !_payload.
>
> David
I think it's preferable to return EFAULT in the case in question. Most syscalls
work like that, i.e. if you say you have 100 bytes (or any number > 0) at
address NULL you'll get EFAULT.
Also note that anyone doing this before would have been either crashing the
kernel or getting EINVAL. So starting to return EFAULT would be very unlikely
to break anything.
- Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Eric Biggers <ebiggers3@gmail.com>
To: David Howells <dhowells@redhat.com>
Cc: keyrings@vger.kernel.org, linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org, Eric Biggers <ebiggers@google.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] KEYS: fix dereferencing NULL payload with nonzero length
Date: Mon, 3 Apr 2017 14:30:41 -0700 [thread overview]
Message-ID: <20170403213041.GA140817@gmail.com> (raw)
In-Reply-To: <6884.1491247244@warthog.procyon.org.uk>
On Mon, Apr 03, 2017 at 08:20:44PM +0100, David Howells wrote:
> Eric Biggers <ebiggers3@gmail.com> wrote:
>
> > > > - if (_payload) {
> > > > + if (plen) {
> > >
> > > "if (_payload && plen)" would be better.
> > >
> > > David
> >
> > No, that doesn't solve the problem. The problem is that userspace can pass
> > in a NULL payload with nonzero length, causing the kernel to dereference a
> > NULL pointer for some key types. For example:
>
> Okay, in that case, I think there should be an else-statement that clears plen
> if !_payload.
>
> David
I think it's preferable to return EFAULT in the case in question. Most syscalls
work like that, i.e. if you say you have 100 bytes (or any number > 0) at
address NULL you'll get EFAULT.
Also note that anyone doing this before would have been either crashing the
kernel or getting EINVAL. So starting to return EFAULT would be very unlikely
to break anything.
- Eric
next prev parent reply other threads:[~2017-04-03 21:30 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-01 21:34 [PATCH] KEYS: fix dereferencing NULL payload with nonzero length Eric Biggers
2017-04-01 21:34 ` Eric Biggers
2017-04-03 15:46 ` David Howells
2017-04-03 15:46 ` David Howells
2017-04-03 17:59 ` Eric Biggers
2017-04-03 17:59 ` Eric Biggers
2017-04-03 19:20 ` David Howells
2017-04-03 19:20 ` David Howells
2017-04-03 21:30 ` Eric Biggers [this message]
2017-04-03 21:30 ` Eric Biggers
2017-05-31 19:11 ` Eric Biggers
2017-05-31 19:11 ` Eric Biggers
2017-05-31 19:11 ` Eric Biggers
2017-04-17 6:26 ` [LTP] [lkp-robot] [KEYS] bdf7c0f8bf: ltp.add_key02.fail kernel test robot
2017-04-17 6:26 ` kernel test robot
2017-04-17 6:26 ` kernel test robot
2017-04-17 17:29 ` Eric Biggers
2017-04-17 17:29 ` Eric Biggers
2017-04-17 17:29 ` Eric Biggers
2017-04-17 17:29 ` [LTP] " Eric Biggers
2017-04-20 12:57 ` Cyril Hrubis
2017-04-20 12:57 ` Cyril Hrubis
2017-04-20 12:57 ` Cyril Hrubis
2017-04-20 12:57 ` Cyril Hrubis
2017-04-21 4:43 ` Eric Biggers
2017-04-21 4:43 ` Eric Biggers
2017-04-21 4:43 ` Eric Biggers
2017-04-21 4:43 ` Eric Biggers
2017-06-02 13:43 ` David Howells
2017-06-02 13:43 ` David Howells
2017-06-02 13:43 ` David Howells
2017-06-02 13:43 ` David Howells
2017-06-02 13:43 ` David Howells
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=20170403213041.GA140817@gmail.com \
--to=ebiggers3@gmail.com \
--cc=linux-security-module@vger.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.