From: Blaisorblade <blaisorblade@yahoo.it>
To: user-mode-linux-devel@lists.sourceforge.net
Cc: Andrew Morton <akpm@osdl.org>, Jeff Dike <jdike@addtoit.com>,
linux-kernel@vger.kernel.org
Subject: Re: [uml-devel] [PATCH 04/11] uml - hostfs: avoid possible escapes from hostfs=.
Date: Mon, 5 Mar 2007 23:59:13 +0100 [thread overview]
Message-ID: <200703052359.13612.blaisorblade@yahoo.it> (raw)
In-Reply-To: <20070305220334.GB7702@ccure.user-mode-linux.org>
On Monday 05 March 2007 23:03, Jeff Dike wrote:
> On Mon, Mar 05, 2007 at 09:49:02PM +0100, Paolo 'Blaisorblade' Giarrusso
wrote:
> > From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
> >
> > Avoid accepting things like -o .., -o dir/../../dir2, -o dir/../.. .
> > This may be considered useless, but YMMV. I consider that this has a
> > limited security value, exactly like disabling module support (in many
> > case it is useful).
>
> Two comments on this one:
> > + return strstr(path, "/../") != NULL ||
> > + strcmp(path, "..") == 0 ||
> > + strncmp(path, "../", strlen("../")) == 0 ||
> > + str_ends_with(path, "/..");
>
> Minor style point - I'd be happier with more parens:
>
> + return (strstr(path, "/../") != NULL) ||
> + (strcmp(path, "..") == 0) ||
> + (strncmp(path, "../", strlen("../")) == 0) ||
> + str_ends_with(path, "/..");
Hmm. Personally I prefer the earlier style, but I haven't the last word on
this.
> C gets operator precedence wrong in one or two cases, so I just put parens
> any place it might matter.
Indeed. For instance this patch is wrong, I did this once in a patch, and I
saw it another time in current Ubuntu kernels:
- a + b / 4
+ a + b >> 2
This is instead needed:
+ a + (b >> 2)
> Second, there is code in externfs which does the same thing without
> parsing paths which you might consider instead.
I must, indeed - your comment points out the symlink issue, which I didn't
think of, and which makes my patch moot.
> It sees whether the
> requested directory is outside the jail by cd-ing to it and then
> repeatedly cd .. until it either reaches / or the jail root.
>
> A copy is below for your reading pleasure.
I gave a look, and it's nice. Except that maybe "escapes_jail" would be a
clearer name (there's confusion about the subject of "escaping").
Also, what about concurrent UML threads caring about current directory? I know
that without SMP/preemption we can't have this problem, but when I see this I
count a future bug unless this is checked (I think I reason mathematically
about correctness, even if not formally).
And I haven't the time to check this - I think your version could be merged
anyway, but I'm not sure.
> Jeff
--
Inform me of my mistakes, so I can add them to my list!
Paolo Giarrusso, aka Blaisorblade
http://www.user-mode-linux.org/~blaisorblade
Chiacchiera con i tuoi amici in tempo reale!
http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
next prev parent reply other threads:[~2007-03-05 22:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-05 20:42 [uml-devel] [PATCH 00/11] Uml simple fixes Paolo 'Blaisorblade' Giarrusso
2007-03-05 20:48 ` [uml-devel] [PATCH 01/11] uml: code convention cleanup of a file Paolo 'Blaisorblade' Giarrusso
2007-03-05 21:55 ` Jeff Dike
2007-03-05 20:49 ` [uml-devel] [PATCH 02/11] uml - hostfs: fix double free Paolo 'Blaisorblade' Giarrusso
2007-03-05 20:49 ` [uml-devel] [PATCH 03/11] uml - hostfs: make hostfs= option work as a jail, as intended Paolo 'Blaisorblade' Giarrusso
2007-03-05 20:49 ` [uml-devel] [PATCH 04/11] uml - hostfs: avoid possible escapes from hostfs= Paolo 'Blaisorblade' Giarrusso
2007-03-05 22:03 ` Jeff Dike
2007-03-05 22:59 ` Blaisorblade [this message]
2007-03-05 23:07 ` Jeff Dike
2007-03-05 20:49 ` [uml-devel] [PATCH 05/11] hostfs: rename some vars for clarity Paolo 'Blaisorblade' Giarrusso
2007-03-05 20:49 ` [uml-devel] [PATCH 06/11] uml: fix a memory leak in the multicast driver Paolo 'Blaisorblade' Giarrusso
2007-03-05 20:49 ` [uml-devel] [PATCH 07/11] uml: remove dead code about os_usr1_signal() and os_usr1_process() Paolo 'Blaisorblade' Giarrusso
2007-03-05 20:49 ` [uml-devel] [PATCH 08/11] uml: mark both consoles as CON_ANYTIME Paolo 'Blaisorblade' Giarrusso
2007-03-05 20:49 ` [uml-devel] [PATCH 09/11] uml: fix confusion irq early reenabling Paolo 'Blaisorblade' Giarrusso
2007-03-05 20:49 ` [uml-devel] [PATCH 10/11] uml - activate_fd: return ENOMEM only when appropriate Paolo 'Blaisorblade' Giarrusso
2007-03-05 20:49 ` [uml-devel] [PATCH 11/11] uml: fix errno usage Paolo 'Blaisorblade' Giarrusso
2007-03-05 22:06 ` [uml-devel] [PATCH 00/11] Uml simple fixes Jeff Dike
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=200703052359.13612.blaisorblade@yahoo.it \
--to=blaisorblade@yahoo.it \
--cc=akpm@osdl.org \
--cc=jdike@addtoit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/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