All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: John Johansen <john.johansen@canonical.com>
Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org
Subject: Re: [PATCH] Remove use of mnt_ns->root and fix a couple of bugs in d_namespace_path
Date: Sun, 4 Dec 2011 22:10:20 +0000	[thread overview]
Message-ID: <20111204221020.GB2203@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1323034020-28780-1-git-send-email-john.johansen@canonical.com>

On Sun, Dec 04, 2011 at 01:27:00PM -0800, John Johansen wrote:
> +	/* is the path a sysctl? */
> +	if (path->dentry->d_sb->s_magic == PROC_SUPER_MAGIC &&
> +	    strncmp(*name, "/sys/", 5) == 0) {
> +		/* TODO: convert over to using a per namespace
> +		 * control instead of hard coded /proc
> +		 */
> +		error = prepend(name, *name - buf, "/proc", 5);
> +	}

Um?  What if some joker mounts procfs under /sys/<something> or
on /mnt/sys/something (with /mnt being mountpoint as well) and
you race with umount -l /mnt?  Because you *can* race with it
and get tmp pointing to (already freed) root of whatever had been
mounted on /mnt, with name being e.g. /sys/1/stat...  Your check
will happily assume that it's a sysctl, even though /proc/sys/1/stat
had never existed and operation was not done to it at all (it was
to /mnt/sys/1/stat, which would be the same thing as /proc/1/stat in
this setup).

> +	if ((tmp.dentry == root.dentry && tmp.mnt == root.mnt) &&
> +	    !(flags & PATH_CONNECT_PATH)) {
> +		/* disconnected path, don't return pathname starting
> +		 * with '/'
> +		 */
> +		error = -EACCES;
> +		if (*res == '/')
> +			*name = res + 1;

That's not equivalent to what it used to do and I'm not sure that it
makes much sense (not that the original had...)  Note that it will
_always_ fail with -EACCES if you have chroot environment and pass
neither PATH_CHROOT_REL nor PATH_CONNECT_PATH - in that case you'll
certainly not stop at the root of chroot jail, so the comparison will
fail.

  reply	other threads:[~2011-12-04 22:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-04 21:27 [PATCH] Remove use of mnt_ns->root and fix a couple of bugs in d_namespace_path John Johansen
2011-12-04 22:10 ` Al Viro [this message]
2011-12-05  3:27   ` [RFC] __d_path() API change (was Re: [PATCH] Remove use of mnt_ns->root and fix a couple of bugs in d_namespace_path) Al Viro
2011-12-06  2:34     ` John Johansen
2011-12-06  3:58       ` Al Viro
2011-12-06  4:41         ` Tetsuo Handa
2011-12-06  5:20           ` Al Viro
2011-12-06  6:45             ` Tetsuo Handa
2011-12-06 15:49               ` Al Viro
2011-12-06  7:07         ` James Morris

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=20111204221020.GB2203@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=john.johansen@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.