Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796230668; b=gsbUxbA6fUykNN3n/Y3ynEp1+S31+H793hg6KV7jrkHCLGV+OsnEOBHrrRUU6Ruxb135 MZWpB2xNLw66nO0aJUeDsp2MI4EcBMMCzVxTQvABhVqaZ+ZuhKEBDUYPJSLCH4O2Tfl9S AFhIu3SiMJAAi2eTwrG1nludx8ZK77BTwAIOdHUfd+HAnHNWgFKv+OFjTs8dZghLVXLhP FuugajAYEkMvfQu8GxBDkfvQ3Kz16VSZ0xhAa5KtVxnz8MxuWZgZF0nixTy/RoGX6b+Yd QDYO028Dv4VJV5pgKTmdVexI6tHu3K8juxso3oyvgrivG/OqC9/++qkSOdJoSoKtQ5g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796230668; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=xk08TN5cx7UCzeDWHSRQhpAIAEjsXPjfy4zmotELzwo=; b=074JYCuRwI3715CWhOGQ3aw2LaEBm/MXAZdDBnsdrcJ23dUQZPpIb0dYyKVtGchLE0Hr haaA09hZviqaR2f82xY/woNcnyCqd+jhPyiWRJVThr861TBl2PQ2An4SnP2KXl8QoFzwn L3XuHouQ6kYOQUdz6NwHFJu7JRDXsc9Yxu0F+uDCRKRZTsfvZttkhbuwty+os96nu/1Ug 7byJeFxeoHuLXS5tcH7L20VQeRsKEP4CBwkVOF/1Q7jvzHAnze32SuFjaI+5Br5ib3oJj spxwc+N6LxwxlglECbDvFCraNufDsmBo9SqeCvBfQrXmaTtT64Uxh5ZghYHAxKwpydA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WbEZhCxR; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E651606A323; Wed, 2 Dec 2026 16:57:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WbEZhCxR Received: by smtp.kernel.org (Postfix) with ESMTPSA id 908CC1F0089B; Wed, 2 Dec 2026 16:57:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796230667; bh=xk08TN5cx7UCzeDWHSRQhpAIAEjsXPjfy4zmotELzwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WbEZhCxRGzacaIHaW4wDUp65TrDloa1x4Zk59dgMIL3b4+8Ex2qRWKZl9gHZaXaJS A8L6ApJ+N3iISu/Xqlu62quGNkil/Yf0v9YYqez6XFnMpp9ouMwy7IQYRh9++VWbG3 Mb7Vr7n2R06mV31L7JUYLb7hpWQ5Vaadw8sqo7IvDsu1D7HKcR24afpYrzQUIA6oG2 bf0MWeOq4tSAPObVQCvaVJT4R1lcJ0wd8oqSYfDifixQzEg3+5r2KS5VtCC5JyDeST +z/kqSN4NXBcnNLR6NEAKjVrdpBvFt1AeobWhZ+Svr+wwWzsjog+Z1Y2frMqc8Lgc1 BuZxiDJUHeadw== From: Andrey Albershteyn To: "fsdevel" , "linux-ext4" , "linux-btrfs" , "linux-f2fs" , "Eric Biggers" , "Christoph Hellwig" , "Carlos Maiolino" , "fsverity" , "linux-xfs" Cc: "Christian Brauner" , Andrey Albershteyn , david@fromorbit.com, Boris Burkov , David Sterba Subject: [PATCH v20 02/23] fs: strip FS_VERITY_FL from FS_IOC_SETFLAGS Date: Wed, 2 Dec 2026 17:56:32 +0100 Message-ID: <20261202165653.767961-3-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261202165653.767961-1-aalbersh@kernel.org> References: <20261202165653.767961-1-aalbersh@kernel.org> X-Mailing-List: fsverity@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The common use of FS_IOC_GETFLAGS/SETFLAGS is get-modify-set loop. Filesystems could return verity status with GETFLAGS, attempting to then pass FS_VERITY_FL to SETFLAGS is not allowed. The ext4 and f2fs already treat FS_VERITY_FL in the set path as no-op, however, BTRFS returns -EOPNOTSUPP. So, the modification of other flags doesn't work on BTRFS for fsverity inodes. Make FS_VERITY_FL be silently ignored if it's attempted to be set on a file that didn't have it before. This fixes get-modify-set loop for BTRFS and anyone else, the ext4 and f2fs masking becomes no-op. The file_get/setattr() path is fine here as this flag is cleared right before fileattr_set_prepare(). The future fsverity support in XFS would also need it. Cc: Boris Burkov Cc: David Sterba Fixes: 146054090b08 ("btrfs: initial fsverity support") Signed-off-by: Andrey Albershteyn Reviewed-by: Christoph Hellwig --- fs/file_attr.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/file_attr.c b/fs/file_attr.c index 833e03810b24..81bf55f9b255 100644 --- a/fs/file_attr.c +++ b/fs/file_attr.c @@ -199,6 +199,16 @@ static int fileattr_set_prepare(struct inode *inode, if (err) return err; + /* + * FS_VERITY_FL is settable only via FS_IOC_ENABLE_VERITY; never through + * fileattr + * + * Treat it as a no-op so the FS_IOC_GETFLAGS/SETFLAGS round-trip + * doesn't break for other flags + */ + fa->flags &= ~FS_VERITY_FL; + fa->fsx_xflags &= ~FS_XFLAG_VERITY; + /* * Project Quota ID state is only allowed to change from within the init * namespace. Enforce that restriction only if we are trying to change -- 2.54.0