* [PATCH] lkdtm: reduce stack size
@ 2009-03-01 20:00 Frank Seidel
2009-03-02 4:11 ` Ankita Garg
0 siblings, 1 reply; 5+ messages in thread
From: Frank Seidel @ 2009-03-01 20:00 UTC (permalink / raw)
To: linux kernel
Cc: akpm, Ankita Garg, Adrian Bunk, Randy Dunlap, Frank Seidel,
Frank Seidel, kernalert.de
From: Frank Seidel <frank@f-seidel.de>
Reduce stack memory footprint of lkdtm
(recursive_loop). From 1024 bytes on i386 down
to <10.
Signed-off-by: Frank Seidel <frank@f-seidel.de>
---
drivers/misc/lkdtm.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
--- a/drivers/misc/lkdtm.c
+++ b/drivers/misc/lkdtm.c
@@ -225,14 +225,24 @@ static int lkdtm_parse_commandline(void)
static int recursive_loop(int a)
{
- char buf[1024];
+ char *buf;
+ int ret;
+
+ buf = kmalloc(1024, GFP_KERNEL);
+ if (!buf) {
+ printk(KERN_ERR "lkdtm : couldn't allocate buffer\n");
+ return -ENOMEM;
+ }
memset(buf,0xFF,1024);
recur_count--;
if (!recur_count)
- return 0;
+ ret = 0;
else
- return recursive_loop(a);
+ ret = recursive_loop(a);
+
+ kfree(buf);
+ return ret;
}
void lkdtm_handler(void)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] lkdtm: reduce stack size
2009-03-01 20:00 [PATCH] lkdtm: reduce stack size Frank Seidel
@ 2009-03-02 4:11 ` Ankita Garg
2009-03-02 8:10 ` Frank Seidel
2009-03-02 9:51 ` Bernd Petrovitsch
0 siblings, 2 replies; 5+ messages in thread
From: Ankita Garg @ 2009-03-02 4:11 UTC (permalink / raw)
To: Frank Seidel
Cc: linux kernel, akpm, Adrian Bunk, Randy Dunlap, Frank Seidel,
kernalert.de
Hi Frank,
On Sun, Mar 01, 2009 at 09:00:14PM +0100, Frank Seidel wrote:
> From: Frank Seidel <frank@f-seidel.de>
>
> Reduce stack memory footprint of lkdtm
> (recursive_loop). From 1024 bytes on i386 down
> to <10.
>
The intention here is infact to trigger a stack overflow. This module is
used to test kernel dumping mechanism like kdump. So the expectation is
that the kernel will dump as soon as the stack overflows.
> Signed-off-by: Frank Seidel <frank@f-seidel.de>
> ---
> drivers/misc/lkdtm.c | 16 +++++++++++++---
> 1 file changed, 13 insertions(+), 3 deletions(-)
>
> --- a/drivers/misc/lkdtm.c
> +++ b/drivers/misc/lkdtm.c
> @@ -225,14 +225,24 @@ static int lkdtm_parse_commandline(void)
>
> static int recursive_loop(int a)
> {
> - char buf[1024];
> + char *buf;
> + int ret;
> +
> + buf = kmalloc(1024, GFP_KERNEL);
> + if (!buf) {
> + printk(KERN_ERR "lkdtm : couldn't allocate buffer\n");
> + return -ENOMEM;
> + }
>
> memset(buf,0xFF,1024);
> recur_count--;
> if (!recur_count)
> - return 0;
> + ret = 0;
> else
> - return recursive_loop(a);
> + ret = recursive_loop(a);
> +
> + kfree(buf);
> + return ret;
> }
>
> void lkdtm_handler(void)
--
Regards,
Ankita Garg (ankita@in.ibm.com)
Linux Technology Center
IBM India Systems & Technology Labs,
Bangalore, India
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] lkdtm: reduce stack size
2009-03-02 4:11 ` Ankita Garg
@ 2009-03-02 8:10 ` Frank Seidel
2009-03-02 9:51 ` Bernd Petrovitsch
1 sibling, 0 replies; 5+ messages in thread
From: Frank Seidel @ 2009-03-02 8:10 UTC (permalink / raw)
To: Ankita Garg
Cc: linux kernel, akpm, Adrian Bunk, Randy Dunlap, Frank Seidel,
kernalert.de
Ankita Garg wrote:
> The intention here is infact to trigger a stack overflow. This module is
> used to test kernel dumping mechanism like kdump. So the expectation is
> that the kernel will dump as soon as the stack overflows.
Oh, i see. Then this patch of course doesn't make sense.
Thanks,
Frank
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] lkdtm: reduce stack size
2009-03-02 4:11 ` Ankita Garg
2009-03-02 8:10 ` Frank Seidel
@ 2009-03-02 9:51 ` Bernd Petrovitsch
2009-03-02 10:12 ` Ankita Garg
1 sibling, 1 reply; 5+ messages in thread
From: Bernd Petrovitsch @ 2009-03-02 9:51 UTC (permalink / raw)
To: Ankita Garg
Cc: Frank Seidel, linux kernel, akpm, Adrian Bunk, Randy Dunlap,
Frank Seidel, kernalert.de
Hi!
On Mon, 2009-03-02 at 09:41 +0530, Ankita Garg wrote:
> Hi Frank,
>
> On Sun, Mar 01, 2009 at 09:00:14PM +0100, Frank Seidel wrote:
> > From: Frank Seidel <frank@f-seidel.de>
> >
> > Reduce stack memory footprint of lkdtm
> > (recursive_loop). From 1024 bytes on i386 down
> > to <10.
> >
>
> The intention here is infact to trigger a stack overflow. This module is
> used to test kernel dumping mechanism like kdump. So the expectation is
> that the kernel will dump as soon as the stack overflows.
That answers why the variable exists at all. It is only zeroed and never
else used.
Hmm, adding the above as a comment makes probably sense.
> > Signed-off-by: Frank Seidel <frank@f-seidel.de>
> > ---
> > drivers/misc/lkdtm.c | 16 +++++++++++++---
> > 1 file changed, 13 insertions(+), 3 deletions(-)
> >
> > --- a/drivers/misc/lkdtm.c
> > +++ b/drivers/misc/lkdtm.c
> > @@ -225,14 +225,24 @@ static int lkdtm_parse_commandline(void)
> >
> > static int recursive_loop(int a)
> > {
> > - char buf[1024];
> > + char *buf;
> > + int ret;
> > +
> > + buf = kmalloc(1024, GFP_KERNEL);
> > + if (!buf) {
> > + printk(KERN_ERR "lkdtm : couldn't allocate buffer\n");
> > + return -ENOMEM;
> > + }
> >
> > memset(buf,0xFF,1024);
> > recur_count--;
> > if (!recur_count)
> > - return 0;
> > + ret = 0;
> > else
> > - return recursive_loop(a);
> > + ret = recursive_loop(a);
> > +
> > + kfree(buf);
> > + return ret;
> > }
> >
> > void lkdtm_handler(void)
Bernd
--
Firmix Software GmbH http://www.firmix.at/
mobil: +43 664 4416156 fax: +43 1 7890849-55
Embedded Linux Development and Services
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] lkdtm: reduce stack size
2009-03-02 9:51 ` Bernd Petrovitsch
@ 2009-03-02 10:12 ` Ankita Garg
0 siblings, 0 replies; 5+ messages in thread
From: Ankita Garg @ 2009-03-02 10:12 UTC (permalink / raw)
To: Bernd Petrovitsch
Cc: Frank Seidel, linux kernel, akpm, Adrian Bunk, Randy Dunlap,
Frank Seidel, kernalert.de
Hi Bernd,
On Mon, Mar 02, 2009 at 10:51:30AM +0100, Bernd Petrovitsch wrote:
> Hi!
>
> On Mon, 2009-03-02 at 09:41 +0530, Ankita Garg wrote:
> > Hi Frank,
> >
> > On Sun, Mar 01, 2009 at 09:00:14PM +0100, Frank Seidel wrote:
> > > From: Frank Seidel <frank@f-seidel.de>
> > >
> > > Reduce stack memory footprint of lkdtm
> > > (recursive_loop). From 1024 bytes on i386 down
> > > to <10.
> > >
> >
> > The intention here is infact to trigger a stack overflow. This module is
> > used to test kernel dumping mechanism like kdump. So the expectation is
> > that the kernel will dump as soon as the stack overflows.
>
> That answers why the variable exists at all. It is only zeroed and never
> else used.
> Hmm, adding the above as a comment makes probably sense.
>
There is some text at the head of the module file that explains what the
module does and the usage, etc. I suppose that would be sufficient ?
--
Regards,
Ankita Garg (ankita@in.ibm.com)
Linux Technology Center
IBM India Systems & Technology Labs,
Bangalore, India
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-03-02 10:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-01 20:00 [PATCH] lkdtm: reduce stack size Frank Seidel
2009-03-02 4:11 ` Ankita Garg
2009-03-02 8:10 ` Frank Seidel
2009-03-02 9:51 ` Bernd Petrovitsch
2009-03-02 10:12 ` Ankita Garg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox