aboutsummaryrefslogtreecommitdiffstats
path: root/security/commoncap.c
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2007-08-22 17:01:28 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-08-22 22:52:45 -0400
commit34b4e4aa3c470ce8fa2bd78abb1741b4b58baad7 (patch)
tree91d620288f1aaf63c12dc84ca1015465818601f2 /security/commoncap.c
parentafe1ab4d577892822de2c8e803fbfaed6ec44ba3 (diff)
fix NULL pointer dereference in __vm_enough_memory()
The new exec code inserts an accounted vma into an mm struct which is not current->mm. The existing memory check code has a hard coded assumption that this does not happen as does the security code. As the correct mm is known we pass the mm to the security method and the helper function. A new security test is added for the case where we need to pass the mm and the existing one is modified to pass current->mm to avoid the need to change large amounts of code. (Thanks to Tobias for fixing rejects and testing) Signed-off-by: Alan Cox <alan@redhat.com> Cc: WU Fengguang <wfg@mail.ustc.edu.cn> Cc: James Morris <jmorris@redhat.com> Cc: Tobias Diedrich <ranma+kernel@tdiedrich.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'security/commoncap.c')
-rw-r--r--security/commoncap.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/security/commoncap.c b/security/commoncap.c
index 338606eb7238..7520361663e8 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -315,13 +315,13 @@ int cap_syslog (int type)
315 return 0; 315 return 0;
316} 316}
317 317
318int cap_vm_enough_memory(long pages) 318int cap_vm_enough_memory(struct mm_struct *mm, long pages)
319{ 319{
320 int cap_sys_admin = 0; 320 int cap_sys_admin = 0;
321 321
322 if (cap_capable(current, CAP_SYS_ADMIN) == 0) 322 if (cap_capable(current, CAP_SYS_ADMIN) == 0)
323 cap_sys_admin = 1; 323 cap_sys_admin = 1;
324 return __vm_enough_memory(pages, cap_sys_admin); 324 return __vm_enough_memory(mm, pages, cap_sys_admin);
325} 325}
326 326
327EXPORT_SYMBOL(cap_capable); 327EXPORT_SYMBOL(cap_capable);