mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: 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>, Willy Tarreau <w@1wt.eu>,
	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 13:19:06 -0700	[thread overview]
Message-ID: <20160614131906.4a5a9db55946735fbd57c4f5@linux-foundation.org> (raw)
In-Reply-To: <1465608788-4813-1-git-send-email-xypron.glpk@gmx.de>

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.

  parent reply	other threads:[~2016-06-14 20:19 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 [this message]
2016-06-14 20:41   ` Willy Tarreau
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=20160614131906.4a5a9db55946735fbd57c4f5@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=acme@redhat.com \
    --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=w@1wt.eu \
    --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®