lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 27 Jul 2022 14:37:10 +0200
From:   Christian Brauner <brauner@...nel.org>
To:     Jeff Layton <jlayton@...nel.org>
Cc:     viro@...iv.linux.org.uk, linux-fsdevel@...r.kernel.org,
        linux-nfs@...r.kernel.org, linux-kernel@...r.kernel.org,
        Yongchen Yang <yoyang@...hat.com>
Subject: Re: [PATCH] vfs: bypass may_create_in_sticky check if task has
 CAP_FOWNER

On Wed, Jul 27, 2022 at 08:30:48AM -0400, Jeff Layton wrote:
> NFS server is exporting a sticky directory (mode 01777) with root
> squashing enabled. Client has protect_regular enabled and then tries to
> open a file as root in that directory. File is created (with ownership
> set to nobody:nobody) but the open syscall returns an error.
> 
> The problem is may_create_in_sticky, which rejects the open even though
> the file has already been created/opened. Bypass the checks in
> may_create_in_sticky if the task has CAP_FOWNER in the given namespace.
> 
> Link: https://bugzilla.redhat.com/show_bug.cgi?id=1976829
> Reported-by: Yongchen Yang <yoyang@...hat.com>
> Suggested-by: Christian Brauner <brauner@...nel.org>
> Signed-off-by: Jeff Layton <jlayton@...nel.org>
> ---
>  fs/namei.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/namei.c b/fs/namei.c
> index 1f28d3f463c3..170c2396ba29 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -1230,7 +1230,8 @@ static int may_create_in_sticky(struct user_namespace *mnt_userns,
>  	    (!sysctl_protected_regular && S_ISREG(inode->i_mode)) ||
>  	    likely(!(dir_mode & S_ISVTX)) ||
>  	    uid_eq(i_uid_into_mnt(mnt_userns, inode), dir_uid) ||
> -	    uid_eq(current_fsuid(), i_uid_into_mnt(mnt_userns, inode)))
> +	    uid_eq(current_fsuid(), i_uid_into_mnt(mnt_userns, inode)) ||
> +	    ns_capable(mnt_userns, CAP_FOWNER))
>  		return 0;

Hm, no. You really want inode_owner_or_capable() here..
You need to verify that you have a mapping for the inode->i_{g,u}id in
question and that you're having CAP_FOWNER in the caller's userns.

I'm pretty sure we should also restrict this to the case were the caller
actually created the file otherwise we introduce a potential issue where
the caller is susceptible to data spoofing. For example, the file was
created by another user racing the caller's O_CREAT.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ