From: Willy Tarreau Date: Tue, 16 May 2017 17:18:55 +0000 (+0200) Subject: char: lp: fix possible integer overflow in lp_setup() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=66cb32401b6041356f0be44a302cdb42c20de6c2;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git char: lp: fix possible integer overflow in lp_setup() commit 3e21f4af170bebf47c187c1ff8bf155583c9f3b1 upstream. The lp_setup() code doesn't apply any bounds checking when passing "lp=none", and only in this case, resulting in an overflow of the parport_nr[] array. All versions in Git history are affected. Reported-By: Roee Hay Cc: Ben Hutchings Signed-off-by: Willy Tarreau --- diff --git a/drivers/char/lp.c b/drivers/char/lp.c index 0913d79424d3..6b619105dea8 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -857,7 +857,11 @@ static int __init lp_setup (char *str) } else if (!strcmp(str, "auto")) { parport_nr[0] = LP_PARPORT_AUTO; } else if (!strcmp(str, "none")) { - parport_nr[parport_ptr++] = LP_PARPORT_NONE; + if (parport_ptr < LP_NO) + parport_nr[parport_ptr++] = LP_PARPORT_NONE; + else + printk(KERN_INFO "lp: too many ports, %s ignored.\n", + str); } else if (!strcmp(str, "reset")) { reset = 1; }