From: ebiederm@xmission.com (Eric W. Biederman)
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, Paul Jackson <pj@sgi.com>
Subject: [PATCH] proc: task_mmu bug fix.
Date: Wed, 01 Mar 2006 00:26:06 -0700 [thread overview]
Message-ID: <m1u0aiocc1.fsf_-_@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <20060228212501.25464659.pj@sgi.com> (Paul Jackson's message of "Tue, 28 Feb 2006 21:25:01 -0800")
This should fix the big bug that has been crashing kernels when
fuser is called. At least it is the bug I observed here. It seems
you need the right access pattern on /proc/<pid>/maps to trigger this.
seq_operations ->stop is only called once per start making it safe to
call put_task_struct there. However m_next was calling m_stop which
totally messed me up.
Technically the task_struct needs to be held for the duration, so
split m_stop into two functions such that only vma_stop is called
multiple times per start.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
fs/proc/task_mmu.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
4217fed6dbbf2b5615d8a498b39aad5ee28d3e5f
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 4772543..f299538 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -363,17 +363,13 @@ out:
return priv->tail_vma;
}
-static void m_stop(struct seq_file *m, void *v)
+static void vma_stop(struct proc_maps_private *priv, struct vm_area_struct *vma)
{
- struct proc_maps_private *priv = m->private;
- struct vm_area_struct *vma = v;
if (vma && vma != priv->tail_vma) {
struct mm_struct *mm = vma->vm_mm;
up_read(&mm->mmap_sem);
mmput(mm);
}
- if (priv->task)
- put_task_struct(priv->task);
}
static void *m_next(struct seq_file *m, void *v, loff_t *pos)
@@ -385,10 +381,20 @@ static void *m_next(struct seq_file *m,
(*pos)++;
if (vma && (vma != tail_vma) && vma->vm_next)
return vma->vm_next;
- m_stop(m, v);
+ vma_stop(priv, vma);
return (vma != tail_vma)? tail_vma: NULL;
}
+static void m_stop(struct seq_file *m, void *v)
+{
+ struct proc_maps_private *priv = m->private;
+ struct vm_area_struct *vma = v;
+
+ vma_stop(priv, vma);
+ if (priv->task)
+ put_task_struct(priv->task);
+}
+
static struct seq_operations proc_pid_maps_op = {
.start = m_start,
.next = m_next,
--
1.2.2.g709a-dirty
next prev parent reply other threads:[~2006-03-01 7:32 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200603010120.k211KqVP009559@shell0.pdx.osdl.net>
2006-03-01 2:18 ` + proc-dont-lock-task_structs-indefinitely-cpuset-fix-2.patch added to -mm tree Paul Jackson
2006-03-01 2:36 ` Andrew Morton
2006-03-01 3:45 ` Paul Jackson
2006-03-01 4:10 ` Paul Jackson
2006-03-01 5:05 ` Eric W. Biederman
2006-03-01 5:25 ` Paul Jackson
2006-03-01 6:11 ` Eric W. Biederman
2006-03-01 6:15 ` Eric W. Biederman
2006-03-01 7:20 ` [PATCH] proc: Reference couting fix Eric W. Biederman
2006-03-01 7:26 ` Eric W. Biederman [this message]
2006-03-01 7:46 ` [PATCH] proc: task_mmu bug fix Andrew Morton
2006-03-01 12:49 ` Eric W. Biederman
2006-03-01 13:14 ` Hugh Dickins
2006-03-01 13:15 ` Rafael J. Wysocki
2006-03-01 18:33 ` Paul Jackson
2006-03-01 7:48 ` + proc-dont-lock-task_structs-indefinitely-cpuset-fix-2.patch added to -mm tree Paul Jackson
2006-03-01 8:26 ` Andrew Morton
2006-03-01 8:39 ` Paul Jackson
2006-03-01 9:53 ` Paul Jackson
2006-03-01 10:02 ` Andrew Morton
2006-03-01 10:14 ` Paul Jackson
2006-03-01 10:11 ` Paul Jackson
2006-03-01 10:31 ` Paul Jackson
2006-03-01 19:21 ` Greg KH
2006-03-01 20:58 ` Paul Jackson
2006-03-01 21:30 ` Greg KH
2006-03-01 22:26 ` Andrew Morton
2006-03-01 22:50 ` Greg KH
2006-03-01 23:20 ` Paul Jackson
2006-03-01 23:40 ` Andrew Morton
2006-03-02 0:10 ` Paul Jackson
2006-03-02 0:35 ` Paul Jackson
2006-03-01 23:10 ` Paul Jackson
2006-03-01 23:40 ` Paul Jackson
2006-03-02 4:20 ` Andrew Morton
2006-03-02 6:14 ` Paul Jackson
2006-03-02 7:42 ` Andrew Morton
2006-03-02 19:12 ` Paul Jackson
2006-03-02 21:52 ` Andrew Morton
2006-03-03 6:33 ` Paul Jackson
2006-03-03 6:44 ` Andrew Morton
2006-03-01 4:31 ` Eric W. Biederman
2006-03-01 4:58 ` Paul Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1u0aiocc1.fsf_-_@ebiederm.dsl.xmission.com \
--to=ebiederm@xmission.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pj@sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®