lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 14 Sep 2022 08:43:13 +0200
From:   Rolf Eike Beer <eike-kernel@...tec.de>
To:     Li zeming <zeming@...china.com>,
        James.Bottomley@...senpartnership.com, Helge Deller <deller@....de>
Cc:     linux-parisc@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] parisc: Increase the usage check of kmalloc allocated object a

Am Mittwoch, 14. September 2022, 08:18:19 CEST schrieb Helge Deller:
> On 9/14/22 08:04, Li zeming wrote:
> > In the case of memory allocation failure, no alignment operation is
> > required.
> > 
> > Signed-off-by: Li zeming <zeming@...china.com>
> > ---
> > 
> >   drivers/parisc/iosapic.c | 4 +++-
> >   1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c
> > index 3a8c98615634..33de438916d3 100644
> > --- a/drivers/parisc/iosapic.c
> > +++ b/drivers/parisc/iosapic.c
> > @@ -229,7 +229,9 @@ static struct irt_entry *iosapic_alloc_irt(int
> > num_entries)> 
> >   	 * 4-byte alignment on 32-bit kernels
> >   	 */
> >   	
> >   	a = (unsigned long)kmalloc(sizeof(struct irt_entry) * num_entries 
+ 8,
> >   	GFP_KERNEL);> 
> > -	a = (a + 7UL) & ~7UL;
> > +	if (a)
> > +		a = (a + 7UL) & ~7UL;
> > +
> 
> As you said, the adjustment isn't required, but it's still ok.
> So I think the additional "if" isn't necessary and so I'm not
> applying your patch.
> 
> Anyway, thanks for your help to try to improve the code!

I was about to say the same, but from looking at the code I don't think what 
is in there is correct either. The comment seems outdated, because 
__assume_kmalloc_alignment, which is __alignof__(unsigned long long). This 
code is untouched for the entire git history, so maybe we can just change the 
whole thing to

  return kcalloc(num_entries, sizeof(struct irt_entry))

now?

And these functions end up propagating an allocation error in this file and it 
will never reach kernel/setup.c, which seems bad. But I guess the only point 
where this really can go wrong if the PDC returns an absurdly large number of 
entries.

Eike
Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ