* [PATCH v2 -next] proc: fix task_struct memleak
@ 2011-12-12 11:36 Vasiliy Kulikov
0 siblings, 0 replies; only message in thread
From: Vasiliy Kulikov @ 2011-12-12 11:36 UTC (permalink / raw)
To: Andrew Morton
Cc: Al Viro, Alexey Dobriyan, kernel-hardening, linux-kernel,
Hugh Dickins
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 <hughd@google.com>
Tested-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
---
This is a patch against a hidepid patchset from -mm.
fs/proc/base.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 8caf5cb..c2b38bc 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -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()
--
1.7.0.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2011-12-12 11:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-12 11:36 [PATCH v2 -next] proc: fix task_struct memleak Vasiliy Kulikov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox