[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGXu5j+AZYrnC-fvxseLVJqeJh5ggOiT9=PUXNweZZbmVy7yWQ@mail.gmail.com>
Date: Tue, 14 Jun 2016 11:33:55 -0700
From: Kees Cook <keescook@...omium.org>
To: Heinrich Schuchardt <xypron.glpk@....de>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Don Zickus <dzickus@...hat.com>,
Al Viro <viro@...iv.linux.org.uk>,
Dave Young <dyoung@...hat.com>,
Hugh Dickins <hughd@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>,
Daniel Cashman <dcashman@...gle.com>, Willy Tarreau <w@....eu>,
Alexei Starovoitov <ast@...mgrid.com>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Ilya Dryomov <idryomov@...il.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/1] kernel/sysctl.c: avoid overflow
On Fri, Jun 10, 2016 at 6:33 PM, Heinrich Schuchardt <xypron.glpk@....de> wrote:
> An undetected overflow may occur in do_proc_dointvec_minmax_conv_param.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@....de>
Acked-by: Kees Cook <keescook@...omium.org>
Thanks for the fix!
-Kees
> ---
> kernel/sysctl.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index 35f0dcb..a9e7be3 100644
> --- 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;
> --
> 2.1.4
>
--
Kees Cook
Chrome OS & Brillo Security
Powered by blists - more mailing lists