lkml.org 
[lkml]   [2022]   [Jun]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] char: lp: ensure that index has not exceeded LP_NO
On Fri, Jun 03, 2022 at 06:30:39PM +0530, Shreenidhi Shedi wrote:
> From: Shreenidhi Shedi <sshedi@vmware.com>
>
> After finishing the loop, index value can be equal to LP_NO and lp_table
> array is of size LP_NO, so this can end up in accessing an out of bound
> address in lp_register function.
>
> Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
> ---
> drivers/char/lp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/char/lp.c b/drivers/char/lp.c
> index 0e22e3b0a..d474d02b6 100644
> --- a/drivers/char/lp.c
> +++ b/drivers/char/lp.c
> @@ -972,7 +972,7 @@ static void lp_attach(struct parport *port)
> if (port_num[i] == -1)
> break;
>
> - if (!lp_register(i, port))
> + if (i < LP_NO && !lp_register(i, port))
> lp_count++;

How can this ever be needed? Look at the check further up for the check
of lp_count which prevents this from every going too large.

So how can an address be accessed out of bound here?

thanks,

greg k-h

\
 
 \ /
  Last update: 2022-06-10 15:29    [W:0.112 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site