Re: [PATCH 1/3] char: lp: ensure that index has not exceeded LP_NO
From: Greg KH
Date: Fri Jun 03 2022 - 08:44:27 EST
On Fri, Jun 03, 2022 at 05:32:25PM +0530, Shreenidhi Shedi wrote:
> On 03/06/22 5:27 pm, Shreenidhi Shedi wrote:
> > On 15/05/22 1:24 pm, Shreenidhi Shedi wrote:
> >> 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@xxxxxxxxxx>
> >> ---
> >> 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 bd95aba1f..e61060f3c 100644
> >> --- a/drivers/char/lp.c
> >> +++ b/drivers/char/lp.c
> >> @@ -971,7 +971,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++;
> >> break;
> >>
> >
> > Hi Greg and Arnd Bergmann,
> >
> > Please review the above changes. Ignore second patch.
> >
> > --
> > Shedi
>
> Sorry, not the second patch. Ignore the 3rd patch which fixes checkspec.pl warnings.
I have no way to do that, please fix up and resend the correct series,
our tools can not pick and choose from a series easily.
Also remember this is the middle of the merge window and we can not do
anything at the moment.
greg k-h