mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Amerigo Wang <amwang@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	WANG Cong <xiyou.wangcong@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Eric B Munson <emunson@mgebm.net>,
	David Rientjes <rientjes@google.com>,
	Dave Hansen <dave@linux.vnet.ibm.com>, Mel Gorman <mel@csn.ul.ie>
Subject: [Patch] proc: check error pointer returned by m_start()
Date: Mon, 28 Mar 2011 11:46:38 +0800	[thread overview]
Message-ID: <1301284006-18808-1-git-send-email-amwang@redhat.com> (raw)
In-Reply-To: <20110327175203.GA15862@fibrous.localdomain>

Anca reported a bug:

[15117.080119] BUG: unable to handle kernel paging request at fffffffffffffff3
[15117.080152] IP: [<ffffffff811b4989>] vma_stop+0x19/0x40

Linus did the initial analysis, and found this was caused
by commit ec6fd8a4355c ("report errors in /proc/*/*map*
sanely"), which replaces NULL with various ERR_PTR() cases.

This is true, that commit changed the return value of m_start(),
which will return an error pointer on failure, but Al forgot
to check the error pointer in m_stop() which will be called
when m_start() fails. This patches fixes it.

Reported-by: Anca Emanuel <anca.emanuel@gmail.com>
Tested-by: Anca Emanuel <anca.emanuel@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>

---
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 7c708a4..6b82632 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -90,7 +90,7 @@ static void pad_len_spaces(struct seq_file *m, int len)
 
 static void vma_stop(struct proc_maps_private *priv, struct vm_area_struct *vma)
 {
-	if (vma && vma != priv->tail_vma) {
+	if (vma && !IS_ERR(vma) && vma != priv->tail_vma) {
 		struct mm_struct *mm = vma->vm_mm;
 		up_read(&mm->mmap_sem);
 		mmput(mm);

  reply	other threads:[~2011-03-28  3:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-27  9:16 BUG: unable to handle kernel paging request Anca Emanuel
2011-03-27 15:37 ` Linus Torvalds
2011-03-27 16:00   ` Américo Wang
2011-03-27 17:44     ` Anca Emanuel
2011-03-27 17:52     ` Stephen Wilson
2011-03-28  3:46       ` Amerigo Wang [this message]
2011-03-28  3:58         ` [Patch] proc: check error pointer returned by m_start() Linus Torvalds
2011-03-28  5:02           ` Cong Wang
2011-03-28  5:26           ` [Patch V2] " Amerigo Wang
2011-03-28  5:45             ` Cong Wang
2011-03-28  7:07               ` [PATCH 1/2] proc: Use IS_ERR_OR_NULL() helper Amerigo Wang
2011-03-28  7:07                 ` [PATCH 2/2] proc: do cleanup in m_start() rather than m_stop() Amerigo Wang
2011-03-28  7:15                 ` [PATCH 1/2] proc: Use IS_ERR_OR_NULL() helper Mike Frysinger
2011-03-28  5:46             ` [Patch V2] proc: check error pointer returned by m_start() Anca Emanuel
2011-03-28  5:49               ` Cong Wang

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=1301284006-18808-1-git-send-email-amwang@redhat.com \
    --to=amwang@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave@linux.vnet.ibm.com \
    --cc=emunson@mgebm.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mel@csn.ul.ie \
    --cc=rientjes@google.com \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=xiyou.wangcong@gmail.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

Powered by JetHome