mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Kees Cook <keescook@chromium.org>,
	Don Zickus <dzickus@redhat.com>,
	Al Viro <viro@zeniv.linux.org.uk>, Dave Young <dyoung@redhat.com>,
	Hugh Dickins <hughd@google.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Daniel Cashman <dcashman@google.com>,
	Alexei Starovoitov <ast@plumgrid.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Ilya Dryomov <idryomov@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] kernel/sysctl.c: avoid overflow
Date: Tue, 14 Jun 2016 22:41:49 +0200	[thread overview]
Message-ID: <20160614204149.GA2723@1wt.eu> (raw)
In-Reply-To: <20160614131906.4a5a9db55946735fbd57c4f5@linux-foundation.org>

On Tue, Jun 14, 2016 at 01:19:06PM -0700, Andrew Morton wrote:
> On Sat, 11 Jun 2016 03:33:08 +0200 Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
> 
> > An undetected overflow may occur in do_proc_dointvec_minmax_conv_param.
> > 
> > ...
> >
> > --- a/kernel/sysctl.c
> > +++ b/kernel/sysctl.c
> > @@ -2313,7 +2313,17 @@ static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
> >  {
> >  	struct do_proc_dointvec_minmax_conv_param *param = data;
> >  	if (write) {
> > -		int val = *negp ? -*lvalp : *lvalp;
> > +		int val;
> > +
> > +		if (*negp) {
> > +			if (*lvalp > (unsigned long) INT_MAX + 1)
> > +				return -EINVAL;
> > +			val = -*lvalp;
> > +		} else {
> > +			if (*lvalp > (unsigned long) INT_MAX)
> > +				return -EINVAL;
> > +			val = *lvalp;
> > +		}
> >  		if ((param->min && *param->min > val) ||
> >  		    (param->max && *param->max < val))
> >  			return -EINVAL;
> 
> hm.
> 
> What happens if someone does
> 
> 	echo -1 > /proc/foo
> 
> expecting to get 0xffffffff?  That's a reasonable shorthand, and if we
> change that to spit out EINVAL then people's stuff may break.

I'd go even further, I don't see anymore how it becomes possible
to actually *write* 0xffffffff at all! This function is used by
proc_dointvec_minmax() which is used with extra1=&zero and extra2
not set with some unsigned ints to allow the full range to be
configured (eg: dirty_expire_interval is the first I found by a
quick random look).

So for me this change is bogus.

Willy

  reply	other threads:[~2016-06-14 20:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-11  1:33 Heinrich Schuchardt
2016-06-14 18:33 ` Kees Cook
2016-06-14 20:19 ` Andrew Morton
2016-06-14 20:41   ` Willy Tarreau [this message]
2016-06-15  8:33     ` Dave Young
2016-06-15  8:40       ` Willy Tarreau
2016-06-15  8:50         ` Dave Young
2016-06-14 21:05   ` Kees Cook

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=20160614204149.GA2723@1wt.eu \
    --to=w@1wt.eu \
    --cc=acme@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=ast@plumgrid.com \
    --cc=dcashman@google.com \
    --cc=dyoung@redhat.com \
    --cc=dzickus@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=hughd@google.com \
    --cc=idryomov@gmail.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    --cc=xypron.glpk@gmx.de \
    /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

all inboxes | Powered by JetHome®