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, 23 Nov 2011 14:46:16 +0100
From:	Michael Holzheu <holzheu@...ux.vnet.ibm.com>
To:	Dave Young <dyoung@...hat.com>
Cc:	heiko.carstens@...ibm.com, kexec@...ts.infradead.org,
	linux-kernel@...r.kernel.org, Simon Horman <horms@...ge.net.au>,
	"Eric W. Biederman" <ebiederm@...ssion.com>,
	schwidefsky@...ibm.com, akpm@...ux-foundation.org,
	Vivek Goyal <vgoyal@...hat.com>
Subject: Re: [PATCH v2] kdump: crashk_res init check for
 /sys/kernel/kexec_crash_size

Hi Dave,

On Wed, 2011-11-23 at 21:34 +0800, Dave Young wrote:
> On 11/23/2011 09:18 PM, Michael Holzheu wrote:
> 
> > From: Michael Holzheu <holzheu@...ux.vnet.ibm.com>
> > 
> > Currently it is possible to set the crash_size via the sysfs
> > /sys/kernel/kexec_crash_size even if no crash kernel memory has
> > been defined with the "crashkernel" parameter. In this case
> > "crashk_res" is not initialized and crashk_res.start = crashk_res.end = 0.
> > Unfortunately resource_size(&crashk_res) returns 1 in this case.
> > This breaks the s390 implementation of crash_(un)map_reserved_pages().
> > 
> > To fix the problem the correct "old_size" is now calculated in
> > crash_shrink_memory(). "old_size is set to "0" if crashk_res is
> > not initialized. With this change crash_shrink_memory() will do nothing,
> > when "crashk_res" is not initialized. It will return "0" for
> > "echo 0 > /sys/kernel/kexec_crash_size" and -EINVAL for
> > "echo [not zero] > /sys/kernel/kexec_crash_size".
> > 
> > In addition to that this patch also simplifies the "ret = -EINVAL"
> > vs. "ret = 0" logic as suggested by Simon Horman.
> > 
> > Cc: Simon Horman <horms@...ge.net.au>
> > Signed-off-by: Michael Holzheu <holzheu@...ux.vnet.ibm.com>
> > ---
> >  kernel/kexec.c |   10 ++++------
> >  1 file changed, 4 insertions(+), 6 deletions(-)
> > 
> > --- a/kernel/kexec.c
> > +++ b/kernel/kexec.c
> > @@ -1131,7 +1131,7 @@ void __weak crash_free_reserved_phys_ran
> >  int crash_shrink_memory(unsigned long new_size)
> >  {
> >  	int ret = 0;
> > -	unsigned long start, end;
> > +	unsigned long start, end, old_size;
> 
> 
> Sorry for jump in a little late, instead of introduce a new variable,
> why not add something like:
> 
> if (!end)
> 	return -EINVAL;

If the crashkernel parameter is not set, "/sys/kernel/kexec_crash_size"
returns zero:

cat /sys/kernel/kexec_crash_size
0

So I think if we set it again to zero we should *not* return -EINVAL:

echo 0 > /sys/kernel/kexec_crash_size
--> Exit code should be zero in this case

Otherwise we would change the current behavior.

And besides of that, I think introducing the "old_size" variable makes
the code more readable.

Michael


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ