lkdtm: reduce stack size
PATCH 1/1 lkdtm: reduce stack size
From: Frank Seidel <[email protected]>
Reduce stack memory footprint of lkdtm
(recursive_loop). From 1024 bytes on i386 down
to <10.
--- drivers/misc/lkdtm.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/misc/lkdtm.c +13 -3
@@ -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 )
Hi Frank,
Quoted 6 lines · Frank Seidel
From: Frank Seidel <[email protected]>
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.
Quoted 35 lines
Signed-off-by Frank Seidel <[email protected]>--- drivers/misc/lkdtm.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)drivers/misc/lkdtm.c +13
-3@@ -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 )
Signature · 5 lines
Regards, Ankita Garg ([email protected]) Linux Technology Center IBM India Systems & Technology Labs, Bangalore, India
Quoted 3 lines · Ankita Garg
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
Hi!
Quoted 5 lines · Ankita Garg
Hi Frank,
Quoted 2 lines · Frank Seidel
From: Frank Seidel <[email protected]>
Quoted 8 lines
Quoted 4 lines
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.
Quoted 34 lines
Quoted 34 lines
Signed-off-by Frank Seidel <[email protected]>--- drivers/misc/lkdtm.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)drivers/misc/lkdtm.c +13
-3@@ -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; }
Quoted 1 line
drivers/misc/lkdtm.c static int lkdtm_parse_commandline(void) · line 248
Quoted 1 line
drivers/misc/lkdtm.c +0
-0void lkdtm_handler (void )
Bernd
Signature · 3 lines
Firmix Software GmbH http://www.firmix.at/
mobil: +43 664 4416156 fax: +43 1 7890849-55
Embedded Linux Development and ServicesHi Bernd,
Quoted 13 lines · Bernd Petrovitsch
Hi!
Quoted 10 lines · Ankita Garg
Hi Frank,
Quoted 6 lines · Frank Seidel
From: Frank Seidel <[email protected]>
Reduce stack memory footprint of lkdtm
(recursive_loop). From 1024 bytes on i386 down
to <10.
Quoted 8 lines
Quoted 3 lines
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 ?
Signature · 5 lines
Regards, Ankita Garg ([email protected]) Linux Technology Center IBM India Systems & Technology Labs, Bangalore, India