Skip to content

Commit a2ef990

Browse files
xtfengtorvalds
authored andcommitted
proc: fix null pointer deref in proc_pid_permission()
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 [raspberrypi#1] PREEMPT SMP This is a regression introduced by commit 0499680 ("procfs: add hidepid= and gid= mount options"). The kernel should return -ESRCH if get_proc_task() failed. Signed-off-by: Xiaotian Feng <[email protected]> Cc: Al Viro <[email protected]> Cc: Vasiliy Kulikov <[email protected]> Cc: Stephen Wilson <[email protected]> Acked-by: David Rientjes <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent bccd172 commit a2ef990

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/proc/base.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,8 @@ static int proc_pid_permission(struct inode *inode, int mask)
654654
bool has_perms;
655655

656656
task = get_proc_task(inode);
657+
if (!task)
658+
return -ESRCH;
657659
has_perms = has_pid_permissions(pid, task, 1);
658660
put_task_struct(task);
659661

0 commit comments

Comments
 (0)