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] [day] [month] [year] [list]
Date:   Thu, 11 Nov 2021 08:22:33 +0800
From:   Baoquan He <bhe@...hat.com>
To:     Heiko Carstens <hca@...ux.ibm.com>
Cc:     Philipp Rudo <prudo@...hat.com>, linux-kernel@...r.kernel.org,
        linux-s390@...r.kernel.org, kexec@...ts.infradead.org,
        dyoung@...hat.com, akpm@...ux-foundation.org
Subject: Re: [PATCH] s390/kexec: fix memory leak of ipl report buffer

On 11/10/21 at 04:18pm, Heiko Carstens wrote:
> On Fri, Oct 29, 2021 at 06:31:32PM +0200, Philipp Rudo wrote:
> > Hi Baoquan,
> > 
> > On Fri, 29 Oct 2021 17:26:35 +0800
> > Baoquan He <bhe@...hat.com> wrote:
> > 
> > > A memory leak is reported by kmemleak scanning:
> ...
> > > The ipl report buffer is allocated via vmalloc, while has no chance to free
> > > if the kexe loading is unloaded. This will cause obvious memory leak
> > > when kexec/kdump kernel is reloaded, manually, or triggered, e.g by
> > > memory hotplug.
> > > 
> > > Here, add struct kimage_arch to s390 to pass out the ipl report buffer
> > > address, and introduce arch dependent function
> > > arch_kimage_file_post_load_cleanup() to free it when unloaded.
> > > 
> > > Signed-off-by: Baoquan He <bhe@...hat.com>
> > 
> > other than a missing
> > 
> > Fixes: 99feaa717e55 ("s390/kexec_file: Create ipl report and pass to
> > next kernel")
> > 
> > the patch looks good to me.
> > 
> > Reviewed-by: Philipp Rudo <prudo@...hat.com>
> ...
> > >  	buf.buffer = ipl_report_finish(data->report);
> > >  	buf.bufsz = data->report->size;
> > >  	buf.memsz = buf.bufsz;
> > > +	image->arch.ipl_buf = buf.buffer;
> 
> This seems (still) to be incorrect: ipl_report_finish() may return
> -ENOMEN, but there is no error checking anywhere, as far as I can
> tell, which would make this:
> 
> > > +int arch_kimage_file_post_load_cleanup(struct kimage *image)
> > > +{
> > > +	kvfree(image->arch.ipl_buf);
> > > +	image->arch.ipl_buf = NULL;
> > > +
> > > +	return kexec_image_post_load_cleanup_default(image);
> > > +}
> 
> most likely not do what we want. That is: if this code is reached at
> all in such a case. I'll check and might add a patch before this to
> fix this also.

Right, we should check the returned value firstly. Thanks a lot for
reivewing, Heiko. I will post v2 to add a patch to check the returned
value as you suggested, and also update this patch to add missing Fixes tag. 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ