public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kernel/fork.c: VM accounting bugfix (2.6.11-rc3-bk5)
@ 2005-02-09  3:48 Mark F. Haigh
  0 siblings, 0 replies; 7+ messages in thread
From: Mark F. Haigh @ 2005-02-09  3:48 UTC (permalink / raw)
  To: chrisw; +Cc: linux-security-module, linux-kernel

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


Unless I'm missing something, in kernel/fork.c, dup_mmap():

			if (security_vm_enough_memory(len))
				goto fail_nomem;
/* ... */
fail_nomem:
	retval = -ENOMEM;
	vm_unacct_memory(charge);
/* ... */

If security_vm_enough_memory() fails there, then we vm_unacct_memory() 
that we never accounted (if security_vm_enough_memory() fails, no memory 
is accounted).

If it is in fact a bug, a simple but largely untested patch (against 
2.6.11-rc3-bk5) is included.


Mark F. Haigh
Mark.Haigh@spirentcom.com


[-- Attachment #2: fork-patch --]
[-- Type: text/plain, Size: 526 bytes --]

--- linux-2.6.11-rc3-bk5/kernel/fork.c.orig	2005-02-08 19:12:26.254589504 -0800
+++ linux-2.6.11-rc3-bk5/kernel/fork.c	2005-02-08 19:16:30.756419576 -0800
@@ -193,8 +193,10 @@
 		charge = 0;
 		if (mpnt->vm_flags & VM_ACCOUNT) {
 			unsigned int len = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
-			if (security_vm_enough_memory(len))
-				goto fail_nomem;
+			if (security_vm_enough_memory(len)) {
+				retval = -ENOMEM;
+				goto out;
+			}
 			charge = len;
 		}
 		tmp = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [PATCH] kernel/fork.c: VM accounting bugfix (2.6.11-rc3-bk5)
@ 2005-02-09  3:51 Mark F. Haigh
  2005-02-09  7:04 ` Chris Wright
  0 siblings, 1 reply; 7+ messages in thread
From: Mark F. Haigh @ 2005-02-09  3:51 UTC (permalink / raw)
  To: chrisw; +Cc: linux-security-module, linux-kernel

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

[Aargh!  Missing Signed-off-by.]

Unless I'm missing something, in kernel/fork.c, dup_mmap():

			if (security_vm_enough_memory(len))
				goto fail_nomem;
/* ... */
fail_nomem:
	retval = -ENOMEM;
	vm_unacct_memory(charge);
/* ... */

If security_vm_enough_memory() fails there, then we vm_unacct_memory()
that we never accounted (if security_vm_enough_memory() fails, no memory
is accounted).

If it is in fact a bug, a simple but largely untested patch (against
2.6.11-rc3-bk5) is included.


Mark F. Haigh
Mark.Haigh@spirentcom.com

Signed-off-by: Mark F. Haigh  <Mark.Haigh@spirentcom.com>


[-- Attachment #2: fork-patch --]
[-- Type: text/plain, Size: 527 bytes --]

--- linux-2.6.11-rc3-bk5/kernel/fork.c.orig	2005-02-08 19:12:26.254589504 -0800
+++ linux-2.6.11-rc3-bk5/kernel/fork.c	2005-02-08 19:16:30.756419576 -0800
@@ -193,8 +193,10 @@
 		charge = 0;
 		if (mpnt->vm_flags & VM_ACCOUNT) {
 			unsigned int len = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
-			if (security_vm_enough_memory(len))
-				goto fail_nomem;
+			if (security_vm_enough_memory(len)) {
+				retval = -ENOMEM;
+				goto out;
+			}
 			charge = len;
 		}
 		tmp = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);


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

end of thread, other threads:[~2005-02-09 20:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-09  3:48 [PATCH] kernel/fork.c: VM accounting bugfix (2.6.11-rc3-bk5) Mark F. Haigh
  -- strict thread matches above, loose matches on Subject: below --
2005-02-09  3:51 Mark F. Haigh
2005-02-09  7:04 ` Chris Wright
2005-02-09 12:30   ` Hugh Dickins
2005-02-09 19:28     ` Chris Wright
2005-02-09 19:46       ` Hugh Dickins
2005-02-09 20:04   ` Mark F. Haigh

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