public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Kees Cook <keescook@chromium.org>
Cc: James Morris <jmorris@namei.org>,
	kernel-hardening@lists.openwall.com,
	Al Viro <viro@zeniv.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Eric Paris <eparis@redhat.com>, Matthew Wilcox <matthew@wil.cx>,
	Doug Ledford <dledford@redhat.com>,
	Joe Korty <joe.korty@ccur.com>, Ingo Molnar <mingo@elte.hu>,
	David Howells <dhowells@redhat.com>,
	James Morris <james.l.morris@oracle.com>,
	linux-doc@vger.kernel.org,
	Dan Rosenberg <drosenberg@vsecurity.com>
Subject: Re: [kernel-hardening] [PATCH 1/2] fs: add link restrictions
Date: Mon, 06 Aug 2012 16:55:31 -0700	[thread overview]
Message-ID: <87hasfinik.fsf@xmission.com> (raw)
In-Reply-To: <CAGXu5jKFm3uxwF3hhhzkUJcxJ0zOH89_bAgQGLCEf=g3CpXuHw@mail.gmail.com> (Kees Cook's message of "Fri, 3 Aug 2012 10:01:10 -0700")

Kees Cook <keescook@chromium.org> writes:

> On Thu, Aug 2, 2012 at 9:26 PM, James Morris <jmorris@namei.org> wrote:
>> On Wed, 25 Jul 2012, Kees Cook wrote:
>>
>>> This adds symlink and hardlink restrictions to the Linux VFS.
>>
>> Is Al happy with this now?
>
> Looks like it; thanks for checking. It's in mainline now:
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=800179c9b8a1e796e441674776d11cd4c05d61d7

So there was one trivial little issue with your patch.  You were
directly comparing kuids instead of using uid_eq.  This only practically
matters when user namespaces are enabled which is currently impossible
in 3.6-rc1 :(

I have added the following fixup patch to my for-next branch of
user-namespace.git

From: "Eric W. Biederman" <ebiederm@xmission.com>
Date: Fri, 3 Aug 2012 09:38:08 -0700
Subject: [PATCH] userns:  Fix link restrictions to use uid_eq

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
 fs/namei.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 1b46439..05480a6 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -678,7 +678,7 @@ static inline int may_follow_link(struct path *link, struct nameidata *nd)
 
 	/* Allowed if owner and follower match. */
 	inode = link->dentry->d_inode;
-	if (current_cred()->fsuid == inode->i_uid)
+	if (uid_eq(current_cred()->fsuid, inode->i_uid))
 		return 0;
 
 	/* Allowed if parent directory not sticky and world-writable. */
@@ -687,7 +687,7 @@ static inline int may_follow_link(struct path *link, struct nameidata *nd)
 		return 0;
 
 	/* Allowed if parent directory and link owner match. */
-	if (parent->i_uid == inode->i_uid)
+	if (uid_eq(parent->i_uid, inode->i_uid))
 		return 0;
 
 	path_put_conditional(link, nd);
@@ -757,7 +757,7 @@ static int may_linkat(struct path *link)
 	/* Source inode owner (or CAP_FOWNER) can hardlink all they like,
 	 * otherwise, it must be a safe source.
 	 */
-	if (cred->fsuid == inode->i_uid || safe_hardlink_source(inode) ||
+	if (uid_eq(cred->fsuid, inode->i_uid) || safe_hardlink_source(inode) ||
 	    capable(CAP_FOWNER))
 		return 0;
 
-- 
1.7.5.4


  reply	other threads:[~2012-08-06 23:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-26  0:29 [RESEND][PATCH v2012.5 0/2] fs: add link restrictions Kees Cook
2012-07-26  0:29 ` [PATCH 1/2] " Kees Cook
2012-08-03  4:26   ` [kernel-hardening] " James Morris
2012-08-03 17:01     ` Kees Cook
2012-08-06 23:55       ` Eric W. Biederman [this message]
2012-08-06 23:59         ` Kees Cook
2012-08-08 12:19   ` Vasily Kulikov
2012-08-12  6:34     ` Kees Cook
2012-08-12 19:32       ` Vasily Kulikov
2012-07-26  0:29 ` [PATCH 2/2] fs: add link restriction audit reporting Kees Cook

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=87hasfinik.fsf@xmission.com \
    --to=ebiederm@xmission.com \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=dledford@redhat.com \
    --cc=drosenberg@vsecurity.com \
    --cc=eparis@redhat.com \
    --cc=james.l.morris@oracle.com \
    --cc=jmorris@namei.org \
    --cc=joe.korty@ccur.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew@wil.cx \
    --cc=mingo@elte.hu \
    --cc=viro@zeniv.linux.org.uk \
    /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