From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796566060; b=o5oE2CNj+4MORqOx8+9RW6Mtgz58k4q7Q0jwbEKtl+bWDsWs8CJyAzVW5xeUhU6mJzx2 2opT6cVj60staCVxc2938qd06UbQQeiukjqqsVWTLZccz9Xv36ZLG8zHQxmFIUrIS9BoV 5kiEDWE5Dk5oufhlwbeojOd/M07V8YdCrd30HF1g55ngj9C63kibKeIFevrr00hku6Lcv IclDRlKtyRdXAFvMbjeE8b/8i624QylO+Ld8LTgZxMrOJOVkO/Ji1SHWC568IlBP97VTH N7RjqY46lRyYrl2+eroNr72/NXGuC5x07SYa0/4tz5LVIi1YSQNy3ta8dVuFIK5QTNQ== 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=2Qr6ni3unPUgMEo30T1J/k1+Vn8QGURCDZXbSULAcs9A+B49t7Q/6EwqgfJWORd5fSBM pGJjLIcIQQPI597Ke7U5oJot6KfqbTWH0zFwab4PpxGe1Af7S4W/URnz1kZdPUjWsmOHz Q5WUbkgjB38FDZ8RZP5DYJbUoLWcIvgtBipV3CN5vl0UZBpAnpLVr7vD+EQfOYPLY56Wd X2VYq2XWFK+HL9XU9/ZEvNvVJOCrgQRz83KBwA8CGRNchZaRGu0U6rbiYTSmq1A3PrFKj rblL5CN5vpQbnwUX24+R5Jx6ST5hSZrDoDcboV0KQ4cKZwm3Yqn3zrOmktyj5R6TIJA== 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.45 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 E2C13606A33B for ; Sun, 6 Dec 2026 14:07:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E2C13606A33B 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-f45.google.com with SMTP id ffacd0b85a97d-4c8fef0a906so1453217f8f.1 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=lMRROwereyp19rsYPyhvXTVlWz90HZDVsbyfV+PWcjrhrFyyCUpsXBX9zo3Z8b+ebe 6p0jcM87YwFhogYZfoCIKK1PF7h5exjvfQ7SEK1gJf3/7e+ZQ5yQqIYiyup0GNbHGcOe uvfQctrmWZ+b0SbGxGyxlgQ2SYhsRr/HdOXnMlJe9+HizY1Yn54qQbFDdoqtG5Cdshob M1HOhNWrcn0/sQvvuEaVbniQnojIhyUaXl8YKz8tj09003s/pon3BrEV42geanVaGeIv zYimvnnaMPo2VhPrv8etOf1qYnkSppcAqtMEL+hq1Hj9HUtefQ34FnnDYCWkBmVGpvod Z3cQ== X-Forwarded-Encrypted: i=1; AL+hErHCarBKlri7idiZgUXjjH1tkUBeDddVz/O2S0q3f/8MMG3YI29pPN53eDmoYEb28117NLjCRXvRmZ6a9/k=@vger.kernel.org X-Gm-Message-State: AB4q+uFGxeUlhKCcd5kJS83rFcR5ii5IOlpABWr+0aj8Qgn9dwwlBlWy W7N8FNSeVxXBjHTKbIGzm1n1Cz9iBKfwwby0D3Odiu9iJ9I0f22CwKSL X-Gm-Gg: AZFdTZf1xQbYAsw6gWfsjOZ+18dzsuoeaYA27eEEEsHDmLSClXkWMVT1gwsJzJQp3tr XC8h4llMq0cSDRsWCkzsDIm75dcW9T7qDar24xMn8Yt78DYrejEYcpaWnuCRM5hHdKoWBrg5eUZ S54Jx+BgVuZ5QbJ+sE+4L793F4+Tn+7IMYHZdZDZbgO7W2EWiJThWjLTgDPxPcS7k2L6uS7e7hl zAh6jUUCnau88RqTerXbEeOqCXSkOixvTvlhgum90vdGfRmMm6Xi0FhstuDv4F5YJzwZhGxrxtG tUVO2s9pFwLVgLmKiF2wdkrUhuL3v76TES66MWFdfHCtrfx9q0ekC0BEzQ2MnmZAD2evAACeekw D7ghMgyq5LIpv/AJnVbB6u0bDPZSpO4XhfGFWIWl33wXt8pAHSg0LjGJ/W12cxyFqo2n3XM2/TR yuyc4g/tvP7NGwBQ+5NmViEJ5mKZ9+tvNyKgL4kWithMyLE8TlD5kauHV5JPwSkZM0HNYd00mlF q8z+99L0W4NvfbaxteH8YRz+H+CHycGSsW51ev+MYUCi3y6f1LQjbj5jiKptdGPl81uYxtHJxsf p94CVlOJLvmq7rt22sBykm2Gdg== 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-kernel@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--