mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Ingo Saitz <Ingo.Saitz@stud.uni-hannover.de>
Cc: Daniel Lezcano <daniel.lezcano@free.fr>,
	"David S. Miller" <davem@davemloft.net>,
	linux-kernel@vger.kernel.org
Subject: Re: PROBLEM: /proc/$pid/ns/ access of zombies dies with null pointer
Date: Wed, 15 Jun 2011 14:44:56 -0700	[thread overview]
Message-ID: <m1wrgmdb1j.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <20110615141948.GA2071@studserv2.stud.uni-hannover.de> (Ingo Saitz's message of "Wed, 15 Jun 2011 16:19:48 +0200")

Ingo Saitz <Ingo.Saitz@stud.uni-hannover.de> writes:

> [1.] One line summary of the problem:
>
> /proc/$pid/ns/ access of zombies dies with null pointer
>
>
> [2.] Full description of the problem/report:
>
> Linux 3.0 introduced /proc/$pid/ns/ directories. The contents of these
> produce a null pointer BUG if the $pid belongs to a zombie process.
>
> This bug can be triggered e.g. by doing a ls in /proc/$pid/ns/ from
> a zombie process.
>
> The kernel switches to a text console and prints the bug on it, and the
> keyboard is not working. But otherwise it seems to run fine, after a
> chvt from a remote login. Only the program accessing the file in proc (ls)
> was killed.

This fixes it for me.  Can you confirm?

>From 793925334f32e9026c22baee5c3c340f47d4ef7e Mon Sep 17 00:00:00 2001
From: "Eric W. Biederman" <ebiederm@xmission.com>
Date: Wed, 15 Jun 2011 12:47:04 -0700
Subject: [PATCH] proc: Fix Oops on stat of /proc/<zombie pid>/ns/net

Don't call iput with the inode half setup to be a namespace filedescriptor.
Instead rearrange the code so that we don't initialize ei->ns_ops until
after I ns_ops->get succeeds, preventing us from invoking ns_ops->put
when ns_ops->get failed.

Reported-by: Ingo Saitz <Ingo.Saitz@stud.uni-hannover.de>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
 fs/proc/namespaces.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index 781dec5..be177f7 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -38,18 +38,21 @@ static struct dentry *proc_ns_instantiate(struct inode *dir,
 	struct inode *inode;
 	struct proc_inode *ei;
 	struct dentry *error = ERR_PTR(-ENOENT);
+	void *ns;
 
 	inode = proc_pid_make_inode(dir->i_sb, task);
 	if (!inode)
 		goto out;
 
+	ns = ns_ops->get(task);
+	if (!ns)
+		goto out_iput;
+
 	ei = PROC_I(inode);
 	inode->i_mode = S_IFREG|S_IRUSR;
 	inode->i_fop  = &ns_file_operations;
 	ei->ns_ops    = ns_ops;
-	ei->ns	      = ns_ops->get(task);
-	if (!ei->ns)
-		goto out_iput;
+	ei->ns	      = ns;
 
 	dentry->d_op = &pid_dentry_operations;
 	d_add(dentry, inode);
-- 
1.7.5.1.217.g4e3aa


  reply	other threads:[~2011-06-15 21:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-15 14:19 Ingo Saitz
2011-06-15 21:44 ` Eric W. Biederman [this message]
2011-06-16  8:49   ` Ingo Saitz

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=m1wrgmdb1j.fsf@fess.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=Ingo.Saitz@stud.uni-hannover.de \
    --cc=daniel.lezcano@free.fr \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    /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