From: Luis Chamberlain <mcgrof@kernel.org>
To: Kees Cook <keescook@chromium.org>, Greg KH <gregkh@linuxfoundation.org>
Cc: Christoph Hellwig <hch@lst.de>, Iurii Zaikin <yzaikin@google.com>,
Alexey Dobriyan <adobriyan@gmail.com>,
linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sysctl: Make sure proc handlers can't expose heap memory
Date: Mon, 4 May 2020 21:59:03 +0000 [thread overview]
Message-ID: <20200504215903.GT11244@42.do-not-panic.com> (raw)
In-Reply-To: <202005041329.169799C65D@keescook>
On Mon, May 04, 2020 at 01:32:07PM -0700, Kees Cook wrote:
> On Mon, May 04, 2020 at 07:59:37PM +0000, Luis Chamberlain wrote:
> > On Mon, May 04, 2020 at 12:08:55PM -0700, Kees Cook wrote:
> > > Just as a precaution, make sure that proc handlers don't accidentally
> > > grow "count" beyond the allocated kbuf size.
> > >
> > > Signed-off-by: Kees Cook <keescook@chromium.org>
> > > ---
> > > This applies to hch's sysctl cleanup tree...
> > > ---
> > > fs/proc/proc_sysctl.c | 3 +++
> > > 1 file changed, 3 insertions(+)
> > >
> > > diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> > > index 15030784566c..535ab26473af 100644
> > > --- a/fs/proc/proc_sysctl.c
> > > +++ b/fs/proc/proc_sysctl.c
> > > @@ -546,6 +546,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *ubuf,
> > > struct inode *inode = file_inode(filp);
> > > struct ctl_table_header *head = grab_header(inode);
> > > struct ctl_table *table = PROC_I(inode)->sysctl_entry;
> > > + size_t count_max = count;
> > > void *kbuf;
> > > ssize_t error;
> > >
> > > @@ -590,6 +591,8 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *ubuf,
> > >
> > > if (!write) {
> > > error = -EFAULT;
> > > + if (WARN_ON(count > count_max))
> > > + count = count_max;
> >
> > That would crash a system with panic-on-warn. I don't think we want that?
>
> Eh? None of the handlers should be making this mistake currently and
> it's not a mistake that can be controlled from userspace. WARN() is
> absolutely what's wanted here: report an impossible situation (and
> handle it gracefully for the bulk of users that don't have
> panic_on_warn set).
Alrighty, Greg are you OK with this type of WARN_ON()? You recently
expressed concerns over its use due to panic-on-warn on another patch.
LUis
next prev parent reply other threads:[~2020-05-04 21:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-04 19:08 [PATCH] sysctl: Make sure proc handlers can't expose heap memory Kees Cook
2020-05-04 19:59 ` Luis Chamberlain
2020-05-04 20:32 ` Kees Cook
2020-05-04 21:59 ` Luis Chamberlain [this message]
2020-05-05 6:34 ` Greg KH
2020-05-05 20:41 ` Kees Cook
2020-05-05 22:03 ` Luis Chamberlain
2020-05-05 23:23 ` Kees Cook
2020-05-05 5:58 ` Christoph Hellwig
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=20200504215903.GT11244@42.do-not-panic.com \
--to=mcgrof@kernel.org \
--cc=adobriyan@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hch@lst.de \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=yzaikin@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).