proc: fix task_struct memleak
PATCH v2 1/1 proc: fix task_struct memleak
proc_pid_permission() doesn't put task_struct on every /proc/$pid/ access. A demo from Hugh Dickins:
while :; do ps; grep KernelStack /proc/meminfo; sleep 1; done
Reported-by Hugh Dickins <[email protected]>
Tested-by Hugh Dickins <[email protected]>
Signed-off-by Vasiliy Kulikov <[email protected]>
---
This is a patch against a hidepid patchset from -mm.
fs/proc/base.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
fs/proc/base.c +7 -2
@@ -646,9 +646,14 @@ static bool has_pid_permissions(struct pid_namespace *pid,static int proc_pid_permission (struct inode *inode,int mask) {struct pid_namespace *pid = inode->i_sb->s_fs_info; -struct task_struct *task =get_proc_task (inode); +struct task_struct *task; +bool has_perms; + + task =get_proc_task (inode); + has_perms =has_pid_permissions (pid, task,1 ); +put_task_struct (task); -if (!has_pid_permissions (pid, task,1 )) { +if (!has_perms) {if (pid->hide_pid ==2 ) {/* * Let's make getdents(), stat(), and open()
Signature · 1 line
1.7.0.4