Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp614915pxb; Thu, 14 Jan 2021 14:12:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwvISi6DRrUDXCYt6CCrH7bqKflfFhdeeR96RziundwApsAThu6G79jR/AGSnIIfgMD/dPd X-Received: by 2002:a17:906:cd06:: with SMTP id oz6mr6780420ejb.25.1610662332879; Thu, 14 Jan 2021 14:12:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610662332; cv=none; d=google.com; s=arc-20160816; b=fMi9ICfCR5LywlPjvsTPVgMtvI0gnOiEJExfolRfIJi1XeCyI1eqgytDaAlPLOju2k k5xE81Wqk+ytZk+vcxDniI32ETljiu1mr1+JFBmdgCLZm0YpZrg28m2iT7zHEBBXI5tw S8RiwXf/SepXanlp0HPyw1ti9hV1FNhELURSecrU90f8iaKkbhntG42vVudD3w1e12a5 y0oTnuCujQrwOoZIXGQ0OewyGaK5HYVGwt5+jSYmtnYHVo7NI3h6+vYV1U7tTUyDU3Uk AZathbVUbw0q3tbdKe6T/6qGb/PGh578l+568ypvPwOsoT/Cppl7AK7zsqPzAN4YKD3R MFnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=dwrqn0ayb1xvW9RuyXLTnAGc8Jb5h7BOxmOrDbRfuXw=; b=TRWrQTYM/Iatdc4weEQfEk1vodV04lTguhsN/D60qUVkv5Ghxc2GYuTxUANUxit8dm NBwey3r2dS89iA0oKDs48ktqQ04x+SnEG7zAzGSOKdHPbGCQ0vrgB9Y0jSldqPC1zDe0 n8axeCDkEeuQukqn7x01Z9pySrF4ZlY1j6zK7Q8XsdSZTIV0F2sZm0W5/EA9JDbHI3cv I7aFIwTyk0oArul5dB8UoVJZsEyo4Rgadp1AMa9CilbIoZ1jfg9r6F2v7r8iyHV9q/Ze e7EcLriJTRW8GeL0NxhOepU+nv13Sm9R217/cDJnBIMg2zepKXhHQEsxDqetJRfnDPG7 5vOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l16si2718109ejd.683.2021.01.14.14.11.44; Thu, 14 Jan 2021 14:12:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727116AbhANWLl (ORCPT + 99 others); Thu, 14 Jan 2021 17:11:41 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:46492 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726880AbhANWLl (ORCPT ); Thu, 14 Jan 2021 17:11:41 -0500 Received: from ip5f5af0a0.dynamic.kabel-deutschland.de ([95.90.240.160] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1l0ApP-0007xM-ND; Thu, 14 Jan 2021 22:10:51 +0000 Date: Thu, 14 Jan 2021 23:10:48 +0100 From: Christian Brauner To: Dave Chinner Cc: Alexander Viro , Christoph Hellwig , linux-fsdevel@vger.kernel.org, John Johansen , James Morris , Mimi Zohar , Dmitry Kasatkin , Stephen Smalley , Casey Schaufler , Arnd Bergmann , Andreas Dilger , OGAWA Hirofumi , Geoffrey Thomas , Mrunal Patel , Josh Triplett , Andy Lutomirski , Theodore Tso , Alban Crequy , Tycho Andersen , David Howells , James Bottomley , Seth Forshee , =?utf-8?B?U3TDqXBoYW5l?= Graber , Linus Torvalds , Aleksa Sarai , Lennart Poettering , "Eric W. Biederman" , smbarber@chromium.org, Phil Estes , Serge Hallyn , Kees Cook , Todd Kjos , Paul Moore , Jonathan Corbet , containers@lists.linux-foundation.org, linux-security-module@vger.kernel.org, linux-api@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-integrity@vger.kernel.org, selinux@vger.kernel.org, Christoph Hellwig Subject: Re: [PATCH v5 37/42] xfs: support idmapped mounts Message-ID: <20210114221048.ppf2pfuxrjak4kvm@wittgenstein> References: <20210112220124.837960-1-christian.brauner@ubuntu.com> <20210112220124.837960-38-christian.brauner@ubuntu.com> <20210114205154.GL331610@dread.disaster.area> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210114205154.GL331610@dread.disaster.area> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, Jan 15, 2021 at 07:51:54AM +1100, Dave Chinner wrote: > On Tue, Jan 12, 2021 at 11:01:19PM +0100, Christian Brauner wrote: > > From: Christoph Hellwig > > > > Enable idmapped mounts for xfs. This basically just means passing down > > the user_namespace argument from the VFS methods down to where it is > > passed to helper. > > > > Signed-off-by: Christoph Hellwig > .... > > @@ -654,6 +658,7 @@ xfs_vn_change_ok( > > */ > > static int > > xfs_setattr_nonsize( > > + struct user_namespace *mnt_userns, > > struct xfs_inode *ip, > > struct iattr *iattr) > > { > > @@ -813,7 +818,7 @@ xfs_setattr_nonsize( > > * Posix ACL code seems to care about this issue either. > > */ > > if (mask & ATTR_MODE) { > > - error = posix_acl_chmod(&init_user_ns, inode, inode->i_mode); > > + error = posix_acl_chmod(mnt_userns, inode, inode->i_mode); > > if (error) > > return error; > > } > > @@ -868,7 +873,7 @@ xfs_setattr_size( > > * Use the regular setattr path to update the timestamps. > > */ > > iattr->ia_valid &= ~ATTR_SIZE; > > - return xfs_setattr_nonsize(ip, iattr); > > + return xfs_setattr_nonsize(&init_user_ns, ip, iattr); > > Shouldn't that be passing mnt_userns? Hey Dave, Thanks for taking a look. This is the time updating codepath. xfs_setattr_size(); -> xfs_setattr_nonsize(&init_user_ns); The xfs_setattr_size() helper will assert: ASSERT((iattr->ia_valid & (ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_ATIME_SET| ATTR_MTIME_SET|ATTR_KILL_PRIV|ATTR_TIMES_SET)) == 0); While the xfs_setattr_nonsize() helper will further assert: ASSERT((mask & ATTR_SIZE) == 0); so xfs_setattr_nonsize() in this callpath is only used to update the if (!(iattr->ia_valid & (ATTR_CTIME|ATTR_MTIME))) return 0; so there's no interactions with idmappings in any way. Simply passing mnt_userns might be clearer though. But if this would be using the wrong idmapping the xfstest suite I added would've immediately caught that and failed. But this specific codepath can also be reliably hit from userspace by doing ftruncate(fd, 0) so just to be extra sure I added truncate tests to the xfstests now for both the idmapped and non-idmapped case. Christian