Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756933Ab2HFXzx (ORCPT ); Mon, 6 Aug 2012 19:55:53 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:50219 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756561Ab2HFXzu (ORCPT ); Mon, 6 Aug 2012 19:55:50 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Kees Cook Cc: James Morris , kernel-hardening@lists.openwall.com, Al Viro , Andrew Morton , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Eric Paris , Matthew Wilcox , Doug Ledford , Joe Korty , Ingo Molnar , David Howells , James Morris , linux-doc@vger.kernel.org, Dan Rosenberg References: <1343262548-21743-1-git-send-email-keescook@chromium.org> <1343262548-21743-2-git-send-email-keescook@chromium.org> Date: Mon, 06 Aug 2012 16:55:31 -0700 In-Reply-To: (Kees Cook's message of "Fri, 3 Aug 2012 10:01:10 -0700") Message-ID: <87hasfinik.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=;;;mid=;;;hst=in02.mta.xmission.com;;;ip=98.207.153.68;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+Y1b9ga7wykwWjyeHt5SMJUdrdkwemJUU= X-SA-Exim-Connect-IP: 98.207.153.68 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.1 XMSubLong Long Subject * 0.0 T_TM2_M_HEADER_IN_MSG BODY: T_TM2_M_HEADER_IN_MSG * -3.0 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa04 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa04 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Kees Cook X-Spam-Relay-Country: Subject: Re: [kernel-hardening] [PATCH 1/2] fs: add link restrictions X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Fri, 06 Aug 2010 16:31:04 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2410 Lines: 68 Kees Cook writes: > On Thu, Aug 2, 2012 at 9:26 PM, James Morris 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" 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" --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/