All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: David Laight <David.Laight@aculab.com>
Cc: "'Eric W. Biederman'" <ebiederm@xmission.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"Serge E. Hallyn" <serge@hallyn.com>
Subject: Re: [CFT][PATCH] proc: Update /proc/net to point at the accessing threads network namespace
Date: Sun, 2 Oct 2022 00:11:50 +0100	[thread overview]
Message-ID: <YzjJNnzRTiSpwXHV@ZenIV> (raw)
In-Reply-To: <9bf5e96b383e4a979618cb0f729cb833@AcuMS.aculab.com>

On Fri, Sep 30, 2022 at 09:28:31PM +0000, David Laight wrote:
> > > FWIW I'm pretty sure there a sequence involving unshare() that
> > > can get you out of a chroot - but I've not found it yet.
> > 
> > Out of a chroot is essentially just:
> > 	chdir("/");
> >         chroot("/somedir");
> >         chdir("../../../../../../../../../../../../../../../..");
> 
> A chdir() inside a chroot anchors at the base of the chroot.
> fchdir() will get you out if you have an open fd to a directory
> outside the chroot.
> The 'usual' way out requires a process outside the chroot to
> just use mvdir().
> But there isn't supposed to be a way to get out.

In order of original claims:

* chdir inside a chroot does *NOT* "anchor at the base of the chroot".
What it does is (a) start at the base if the pathname is absolute and
(b) treats .. in the base as ., same as any other syscall.

* correct.

* WTF is "mvdir()"?  Some Unices used to have mvdir(1), but it had never
been a function...  And mv(1) (or rename(2)) is far from being the only
way for assistant outside of jail to let the chrooted process out.

* ability to chroot(2) had always been equivalent to ability to undo
chroot(2).  If you want to prevent getting out of there, you need
(among other things) to prevent the processes to be confined from
further chroot(2).

  reply	other threads:[~2022-10-01 23:12 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-29 15:22 [PATCH 3/4] proc: Point /proc/net at /proc/thread-self/net instead of /proc/self/net David Laight
2022-09-29 18:21 ` Linus Torvalds
2022-09-29 18:50   ` Al Viro
2022-09-29 19:00     ` Al Viro
2022-09-29 19:05       ` Linus Torvalds
2022-09-29 19:34         ` Al Viro
2022-09-29 21:13           ` Linus Torvalds
2022-09-29 21:21             ` Al Viro
2022-09-29 21:27               ` Al Viro
2022-09-29 21:31                 ` Linus Torvalds
2022-09-29 21:15           ` Al Viro
2022-09-29 21:29             ` Linus Torvalds
2022-09-29 22:14               ` Eric W. Biederman
2022-09-29 22:48                 ` [CFT][PATCH] proc: Update /proc/net to point at the accessing threads network namespace Eric W. Biederman
2022-09-29 23:38                   ` Al Viro
2022-09-30  3:19                   ` kernel test robot
2022-09-30  6:07                   ` kernel test robot
2022-09-30  9:30                   ` David Laight
2022-09-30 16:17                     ` Eric W. Biederman
2022-09-30 21:28                       ` David Laight
2022-10-01 23:11                         ` Al Viro [this message]
2022-10-03  9:36                           ` David Laight
2022-10-03 14:03                             ` Al Viro
2022-10-03 17:07                         ` Eric W. Biederman
2022-10-03 18:49                           ` Al Viro
2022-10-04  8:53                           ` David Laight
2022-10-05 13:10                   ` [proc] 5336f1902b: BUG:KASAN:global-out-of-bounds_in_memchr kernel test robot
2022-10-05 13:10                     ` kernel test robot
2022-09-29 19:00     ` [PATCH 3/4] proc: Point /proc/net at /proc/thread-self/net instead of /proc/self/net Linus Torvalds
2022-09-30 14:01 [CFT][PATCH] proc: Update /proc/net to point at the accessing threads network namespace Alexey Dobriyan

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=YzjJNnzRTiSpwXHV@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=David.Laight@aculab.com \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=serge@hallyn.com \
    --cc=torvalds@linux-foundation.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.