The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] free pages in remove_arg_zero()
@ 2007-02-20 13:29 Petr Tesařík
  2007-02-21 23:41 ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Petr Tesařík @ 2007-02-20 13:29 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Andrew Morton

[-- Attachment #1: Type: text/plain, Size: 1001 bytes --]

Hello,

I've found a bug when executing scripts:

When a script is loaded, load_script() replaces argv[0] with the
name of the interpreter and the filename passed to the exec syscall.
However, there is no guarantee that the length of the interpreter
name plus the length of the filename is greater than the length of
the original argv[0]. If the difference happens to cross a page boundary,
setup_arg_pages() will call install_arg_page() with an address outside
the VMA.

Therefore, remove_arg_zero() must free all pages which would be unused
after the argument is removed.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>

--- linux-sles9.orig/fs/exec.c
+++ linux-sles9/fs/exec.c
@@ -1000,6 +1000,8 @@ void remove_arg_zero(struct linux_binprm
 				continue;
 			offset = 0;
 			kunmap_atomic(kaddr, KM_USER0);
+			__free_page(page);
+			bprm->page[bprm->p/PAGE_SIZE - 1] = NULL;
 inside:
 			page = bprm->page[bprm->p/PAGE_SIZE];
 			kaddr = kmap_atomic(page, KM_USER0);


[-- Attachment #2: Toto je digitálně podepsaná část zprávy --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-03-07 23:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-20 13:29 [PATCH] free pages in remove_arg_zero() Petr Tesařík
2007-02-21 23:41 ` Andrew Morton
2007-03-07 22:09   ` [PATCH] remove_arg_zero() rewrite Peter Zijlstra
2007-03-07 22:41     ` Andrew Morton
2007-03-07 22:55       ` Peter Zijlstra
2007-03-07 23:05         ` Randy Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox