lkml.org 
[lkml]   [2017]   [Sep]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC 1/2] proc: Return if nothing to unmount
Date
If a task exits before procfs is mounted, proc_flush_task_mnt will
be called with a NULL mnt parameter. In that case, not only is there
nothing to unhash, but trying to do so will oops the kernel with a
null pointer dereference.

Signed-off-by: Gargi Sharma <gs051095@gmail.com>
---
fs/proc/base.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index e5d89a0..7b83c21 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -3021,6 +3021,10 @@ static void proc_flush_task_mnt(struct vfsmount *mnt, pid_t pid, pid_t tgid)
char buf[PROC_NUMBUF];
struct qstr name;

+ /* procfs is not mounted. There is nothing to unhash. */
+ if (!mnt)
+ return;
+
name.name = buf;
name.len = snprintf(buf, sizeof(buf), "%d", pid);
/* no ->d_hash() rejects on procfs */
--
2.7.4
\
 
 \ /
  Last update: 2017-09-09 17:22    [W:0.074 / U:0.212 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site