From: Matthew Wilcox <willy@debian.org>
To: Linus Torvalds <torvalds@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Better argument size tracking in fs/exec.c
Date: Tue, 12 Aug 2003 22:07:21 +0100 [thread overview]
Message-ID: <20030812210721.GH10015@parcelfarce.linux.theplanet.co.uk> (raw)
Introduce a new variable "arg_size" and set it appropriately in each
arm of the CONFIG_STACK_GROWSUP. This patch fixes a bug for PA-RISC
and makes the code cleaner for everyone.
diff -urpNX dontdiff linus-2.6/fs/exec.c parisc-2.6/fs/exec.c
--- linus-2.6/fs/exec.c Tue Aug 12 13:11:16 2003
+++ parisc-2.6/fs/exec.c Tue Aug 12 13:29:42 2003
@@ -341,6 +341,7 @@ int setup_arg_pages(struct linux_binprm
struct vm_area_struct *mpnt;
struct mm_struct *mm = current->mm;
int i;
+ long arg_size;
#ifdef CONFIG_STACK_GROWSUP
/* Move the argument and environment strings to the bottom of the
@@ -375,6 +376,7 @@ int setup_arg_pages(struct linux_binprm
bprm->p = PAGE_SIZE * i - offset;
stack_base = STACK_TOP - current->rlim[RLIMIT_STACK].rlim_max;
mm->arg_start = stack_base;
+ arg_size = i << PAGE_SHIFT;
/* zero pages that were copied above */
while (i < MAX_ARG_PAGES)
@@ -382,6 +390,7 @@ int setup_arg_pages(struct linux_binprm
#else
stack_base = STACK_TOP - MAX_ARG_PAGES * PAGE_SIZE;
mm->arg_start = bprm->p + stack_base;
+ arg_size = STACK_TOP - (PAGE_MASK & (unsigned long) mm->arg_start);
#endif
bprm->p += stack_base;
@@ -393,7 +402,7 @@ int setup_arg_pages(struct linux_binprm
if (!mpnt)
return -ENOMEM;
- if (security_vm_enough_memory((STACK_TOP - (PAGE_MASK & (unsigned long) bprm->p))>>PAGE_SHIFT)) {
+ if (security_vm_enough_memory(arg_size >> PAGE_SHIFT)) {
kmem_cache_free(vm_area_cachep, mpnt);
return -ENOMEM;
}
--
"It's not Hollywood. War is real, war is primarily not about defeat or
victory, it is about death. I've seen thousands and thousands of dead bodies.
Do you think I want to have an academic debate on this subject?" -- Robert Fisk
reply other threads:[~2003-08-12 21:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030812210721.GH10015@parcelfarce.linux.theplanet.co.uk \
--to=willy@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®