]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
proc: fix null pointer deref in proc_pid_permission()
authorXiaotian Feng <xtfeng@gmail.com>
Fri, 13 Jan 2012 01:17:08 +0000 (17:17 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 13 Jan 2012 04:13:02 +0000 (20:13 -0800)
get_proc_task() can fail to search the task and return NULL,
put_task_struct() will then bomb the kernel with following oops:

  BUG: unable to handle kernel NULL pointer dereference at 0000000000000010
  IP: [<ffffffff81217d34>] proc_pid_permission+0x64/0xe0
  PGD 112075067 PUD 112814067 PMD 0
  Oops: 0002 [#1] PREEMPT SMP

This is a regression introduced by commit 0499680a ("procfs: add hidepid=
and gid= mount options").  The kernel should return -ESRCH if
get_proc_task() failed.

Signed-off-by: Xiaotian Feng <dannyfeng@tencent.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Vasiliy Kulikov <segoon@openwall.com>
Cc: Stephen Wilson <wilsons@start.ca>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/proc/base.c

index 8173dfd89cb262ac506e64e475fa5c0cd9742c8e..5485a5388ecb2919ecb5033cbf99d1d22916a72b 100644 (file)
@@ -654,6 +654,8 @@ static int proc_pid_permission(struct inode *inode, int mask)
        bool has_perms;
 
        task = get_proc_task(inode);
+       if (!task)
+               return -ESRCH;
        has_perms = has_pid_permissions(pid, task, 1);
        put_task_struct(task);