From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796566060; b=LIO+ZCM3V+U5Eqq/O5z/nXgOP+cWNsvkn3kBLqMJiwcc5EgOzj7zJwTq89o4AQhc+dKN 5AIUNQWBl9ICgHGEpA7/iHqFUk2ggtENEszinMnfZXlxMLBfqR/NZ/0KJLDQFDF81+epF 6fl9FoRE8UqKToKjzRfx5SNrtA9FJ47PhD/kU5jVtFKPBaZj5agT2jiwpVtpPSchcGsoO qNdXYl0j7zc1QnqiB2144UBEo3+uaCERUbH3q4zIlkFGhTdK2ARxKxQY/9KgZj8wkL9v9 IVGGdLKAdkRXV1x3cghti3nezXmiau8jX0c0d56SyN8jfrHgHsaDUBDWcvgi7PisIJw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796566060; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Mime-Version:Content-Type:Date:Message-Id:Subject:From:To:Cc:X-Mailer: References:In-Reply-To; bh=NIfq5wxvt7dtjYXQEsH+V1X5F3RBHOBqcfg7nQ3MWCk=; b=ue9pRIRzDM2B+l/Cp52mNZsOKDpHrfrNlub2nvOOWG95vrumYlWpD/bahznMQz0D+DG/ pe+BedAVH/n4BJcfJRig24R3W5Xa+VIEJfPxJepfcJW1fEisA4oG/2nDOR51yEjESdayM cPciPly6wAGStg/k0vpf16WEDiqyAlrd2RZEoCte2AdxYVZiUBapVb4osYGr43tTu07EE SGd4yO8lNlO0Bpiafpj5oTgJi30W0Urzfrdm7EQpZkVZ3nUY5qrckSzSTKDph2LoDQDUb nRWww8Z5I64nxs6kSlCbMuavQVcXVicLRbyDN8zZJ+D45a24HSTusfe6iIHta7Z4YKQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=jH9OSXEA; arc=none smtp.remote-ip=209.85.221.47 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC578606A682 for ; Sun, 6 Dec 2026 14:07:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DC578606A682 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=jH9OSXEA Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-4ac109a8a12so1356233f8f.3 for ; Sun, 06 Dec 2026 06:07:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796566058; x=1797170858; darn=vger.kernel.org; h=in-reply-to:references:cc:to:from:subject:message-id:date :content-type:mime-version:from:to:cc:subject:date:message-id :reply-to:content-type; bh=NIfq5wxvt7dtjYXQEsH+V1X5F3RBHOBqcfg7nQ3MWCk=; b=jH9OSXEAm6FT2Rhwr08aMXNx/7IXwzQQoY6NzKxHiOqxf2OYGtNZhWWf4LSjdwg+Df Caa4YCinUhUHtdOugaFICFIMNTq3hXO4VgwlF3Jr2KUekOf3tFIUjMi8JC1iioWnDema TDkM6+RZ0obWXJYMwgs4UvI0Z86buHDxXv5hAoQ86ShBTyrEgmDt0XRJDZXS7rpOPTiT LI/qdTF/YJjDaNmM/Y4RJjgqlw0/gcP5jsyFwVS2dashX2SJIL8wODpGrvkN9KXCosMb mYkdgZXPlEnfDNT+I72l/RO/0FFGiJUjP6t4+458vS/48InokUrrVQu8UrF+Ylwvt6JV 54WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796566058; x=1797170858; h=in-reply-to:references:cc:to:from:subject:message-id:date :content-type:mime-version:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=NIfq5wxvt7dtjYXQEsH+V1X5F3RBHOBqcfg7nQ3MWCk=; b=VgzSokwvQy6nSDcaMG2BYnab+7LwOCONc/VNYeyl1z7DnOehvXtx6AHgmbltlN7won aJqHzau/HOaJxgToNo3RKnfoP5Vp2cjUG87HS3up15sMx1/UsgrqZjpcAmRW+hpbhRoZ /m/nhkGYFNRmuZwbGLTHnyWmrN+fEQfwGiKa5cF86nSpoiDqKk05RB1h7EbytZ+xkFs8 mCnd9aA/B/891tvzYP0tiENByTHa0kSHsfMpsDTdSKh8ZSDNsGHz9N3SHDCzq9H40Lyv o6CCh6m+ZeY/CeNW/4hsDpgQ1rShST7pqt2TetO9J9IWbc2wJFuqgFzXZCGFsdkvZR91 3UGA== X-Forwarded-Encrypted: i=1; AL+hErGdwYgI6GhS1ZgvuabcQ5EnF9OIboKOW6AUqyslnWK4hIRIJA/3MNU2hC64Bmu7/g2MAVp0TC9SdoE=@vger.kernel.org X-Gm-Message-State: AB4q+uGXoyFbfasZlbwT4VpC+IwrMGqC+OjSrcThh7M+Hh7to12xt8h8 zfTJ8pLKOsdXkMVtTjCfLH8PWdI7j8cL9WBD2NvWekWVLDGi/WnMfYZG X-Gm-Gg: AZFdTZdru7M23R/MxiZ/zkSS3U7dHfp0CyZdeDWtvD9LfaZqz5xAZBJ/7WjYK1tRiAW eB1ax5fzW84r4Q4z96ENe9IHANqqcMJqlrZ0F+imv5dKitgiMQ0qGmlFwsTDJqmVGplVq0jauBL biAmhzIxcpgJ4/oKZ2IRPux0B6IBGkx6CJnOp+cOsDcFvTAPLUIUANIyCzjT+Tw8X6mwKFfvoA2 bM3/CmXoJky7sbYUv8wQCZV03TPaMrttWv0TYtzK3lavz9TpQbEX7Pe+UDKxg8vEs5wzOEK842A nDEMCMsrgfbtgqjRbXTppkG6bLTtM1nnd+80BbBCMhjJba8TtB1vNzDFIusqfuQH23U+84YAYVd 4uVz6aIeOB/B+LD3W4p2t3CGKx8w1TKdTtafO1fuR1LPgkaGL+AQ+uqawQ8bR7HSHUi5KGmX+iK i5ijA7WhfG/Pgas0MC4tJX3HvX27zrPt8R27li0PKRoY0K5BzaWOzJP3bSMkZRdN3TeFhFcsAMo f6y0g8J8aNH5DRJqI2FC9elqcXNbwIgrgPdq94WCbbW21xj/w+ZjSJCvaK84f+QqPcXzey1KFuX b913NxSM0IoLjx1RwZg1izak/A== X-Received: by 2002:a05:6000:2f87:b0:490:71a7:6f51 with SMTP id ffacd0b85a97d-4d1ea5a8a51mr14871615f8f.45.1796566058225; Sun, 06 Dec 2026 06:07:38 -0800 (PST) Received: from localhost ([2001:b07:5d26:7a6a:365a:60ff:fe0d:cfc6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d17435e021sm16956832f8f.50.2026.12.06.06.07.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 06 Dec 2026 06:07:37 -0800 (PST) X-Mailing-List: linux-api@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 Content-Type: multipart/signed; boundary=0c72347b9d303144d49995b0820c9afee41f71d286bf4f6763a3a1f80d2c; micalg=pgp-sha512; protocol="application/pgp-signature" Date: Sun, 06 Dec 2026 15:07:35 +0100 Message-Id: Subject: Re: [PATCH v5 04/12] fs: switch fileattr_set_prepare() to xflags and refactor projid check From: "koraynilay" To: "Amir Goldstein" , "koraynilay" Cc: "Namjae Jeon" , "Hyunchul Lee" , "Jonathan Corbet" , "Eric Biggers" , "Theodore Y . Ts'o" , "Jaegeuk Kim" , "Alexander Viro" , "Christian Brauner" , "Shuah Khan" , "Randy Dunlap" , "Chuck Lever" , "Jeff Layton" , "Jan Kara" , "Alexander Aring" , "Darrick J . Wong" , "Andrey Albershteyn" , "Miklos Szeredi" , =?utf-8?q?Pali_Roh=C3=A1r?= , "Lauri Gates" , "Christoph Hellwig" , "Dave Chinner" , , , , , , , , , X-Mailer: aerc 0.22.0-0-gc2f86b7abde3 References: <20261205142411.164484-1-koray.fra@gmail.com> <20261205142411.164484-5-koray.fra@gmail.com> In-Reply-To: --0c72347b9d303144d49995b0820c9afee41f71d286bf4f6763a3a1f80d2c Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 On Sun Dec 6, 2026 at 3:04 PM CET, Amir Goldstein wrote: > On Sun, Dec 6, 2026 at 3:00=E2=80=AFPM koraynilay w= rote: >> >> On Sun Dec 6, 2026 at 1:19 PM CET, Amir Goldstein wrote: >> > On Sat, Dec 5, 2026 at 3:24=E2=80=AFPM koraynilay wrote: >> >> >> >> In preparation for the addition of masks to the fileattr API, switch >> >> fileattr_set_prepare() checks from using FS_*_FL flags to FS_XFLAG_* >> >> xflags and refactor project ID value check to be cleaner. >> >> >> >> Signed-off-by: koraynilay >> >> --- >> >> fs/file_attr.c | 30 ++++++++++++++++++++---------- >> >> 1 file changed, 20 insertions(+), 10 deletions(-) >> >> >> >> diff --git a/fs/file_attr.c b/fs/file_attr.c >> >> index 77e2f1bc22ad..c1a0272f1a83 100644 >> >> --- a/fs/file_attr.c >> >> +++ b/fs/file_attr.c >> >> @@ -74,6 +74,14 @@ void fileattr_fill_flags(struct file_kattr *fa, u3= 2 flags) >> >> } >> >> EXPORT_SYMBOL(fileattr_fill_flags); >> >> >> >> +static u32 xflags_to_flags(u32 xflags) >> >> +{ >> >> + struct file_kattr tmp =3D {}; >> >> + >> >> + fileattr_fill_xflags(&tmp, xflags); >> >> + return tmp.flags; >> >> +} >> >> + >> >> /** >> >> * vfs_fileattr_get - retrieve miscellaneous file attributes >> >> * @dentry: the object to retrieve from >> >> @@ -201,17 +209,20 @@ static int fileattr_set_prepare(struct inode *i= node, >> >> const struct file_kattr *old_ma, >> >> struct file_kattr *fa) >> >> { >> >> + u32 changed =3D (fa->fsx_xflags ^ old_ma->fsx_xflags) & FSX_F= SXATTR_MASK; >> >> int err; >> >> >> >> /* >> >> * The IMMUTABLE and APPEND_ONLY flags can only be changed by >> >> * the relevant capability. >> >> */ >> >> - if ((fa->flags ^ old_ma->flags) & (FS_APPEND_FL | FS_IMMUTABL= E_FL) && >> >> + if (changed & (FS_XFLAG_APPEND | FS_XFLAG_IMMUTABLE) && >> >> !capable(CAP_LINUX_IMMUTABLE)) >> >> return -EPERM; >> >> >> >> - err =3D fscrypt_prepare_setflags(inode, old_ma->flags, fa->fl= ags); >> >> + err =3D fscrypt_prepare_setflags(inode, >> >> + xflags_to_flags(old_ma->fsx_xf= lags), >> >> + xflags_to_flags(fa->fsx_xflags= )); >> > >> > Why is this needed? >> > fa->flags and old_ma->flags are kept in sync with fsx_xflags by the >> > VFS in all paths, >> Right, >> > including the masks conversions, >> > and fscrypt only cares about a newly set CASEFOLD flag. >> > I think this hunk can be dropped and xflags_to_flags() can be introduc= ed >> > in the patch that first needs it. >> >> but wouldn't it be better to keep it for consistency, since from now on >> set_prepare should only handle xflags, and not rely on the assumption >> that flags is kept up to date? >> >> Though since right now it is kept up to date in all paths, we would just >> need to be careful in later patches and wait until fscrypt_prepare_setfl= ags >> is switched to xflags (?). >> > > I think it need to be switched to xlags with signature and name change > as we discussed in v2, but for now, I think it is a bit of an overkill, s= o > a simple TODO: comment will do and no need for the xflags_to_flags(). Ok that makes sense, will do that. Thanks, koraynilay > Thanks, > Amir. --0c72347b9d303144d49995b0820c9afee41f71d286bf4f6763a3a1f80d2c Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQSgVimKafU5DQMcjcDmj22qf5IGXAUCaxVsJwAKCRDmj22qf5IG XPMbAP9L29QaPNfMoLPeUMR3NSY0m9o7tENmtYfvuy97RuVsZQD/V7S601zK3WQM y1pfOYONDSndF1xD/5sSi00KrE7XcA8= =+Cwu -----END PGP SIGNATURE----- --0c72347b9d303144d49995b0820c9afee41f71d286bf4f6763a3a1f80d2c--