From: Christian Brauner <brauner@kernel.org>
To: Jeff Layton <jlayton@kernel.org>, Jan Kara <jack@suse.com>,
Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>,
Josef Bacik <josef@toxicpanda.com>
Cc: Christian Brauner <brauner@kernel.org>,
Eric Biggers <ebiggers@kernel.org>,
"Theodore Y. Ts'o" <tytso@mit.edu>,
linux-fsdevel@vger.kernel.org, linux-fscrypt@vger.kernel.org,
fsverity@lists.linux.dev
Subject: [PATCH v4 10/15] fs/verity: use accessors
Date: Wed, 23 Jul 2025 12:57:48 +0200 [thread overview]
Message-ID: <20250723-work-inode-fscrypt-v4-10-c8e11488a0e6@kernel.org> (raw)
In-Reply-To: <20250723-work-inode-fscrypt-v4-0-c8e11488a0e6@kernel.org>
Use accessor to get and set the verity info from the filesystem.
They can be removed once all filesystems have been converted to make
room for verity info in their own inodes.
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
fs/verity/open.c | 19 ++++++++++++++++---
fs/verity/verify.c | 2 +-
include/linux/fsverity.h | 12 +++++++++++-
3 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/fs/verity/open.c b/fs/verity/open.c
index fdeb95eca3af..a4d7388e2f71 100644
--- a/fs/verity/open.c
+++ b/fs/verity/open.c
@@ -250,13 +250,20 @@ struct fsverity_info *fsverity_create_info(const struct inode *inode,
void fsverity_set_info(struct inode *inode, struct fsverity_info *vi)
{
+ void *p;
+
/*
* Multiple tasks may race to set ->i_verity_info, so use
* cmpxchg_release(). This pairs with the smp_load_acquire() in
* fsverity_get_info(). I.e., here we publish ->i_verity_info with a
* RELEASE barrier so that other tasks can ACQUIRE it.
*/
- if (cmpxchg_release(&inode->i_verity_info, NULL, vi) != NULL) {
+
+ if (inode->i_sb->s_vop->inode_info_offs)
+ p = cmpxchg_release(fsverity_addr(inode), NULL, vi);
+ else
+ p = cmpxchg_release(&inode->i_verity_info, NULL, vi);
+ if (p != NULL) {
/* Lost the race, so free the fsverity_info we allocated. */
fsverity_free_info(vi);
/*
@@ -402,8 +409,14 @@ EXPORT_SYMBOL_GPL(__fsverity_prepare_setattr);
void __fsverity_cleanup_inode(struct inode *inode)
{
- fsverity_free_info(inode->i_verity_info);
- inode->i_verity_info = NULL;
+ struct fsverity_info **vi;
+
+ if (inode->i_sb->s_vop->inode_info_offs)
+ vi = fsverity_addr(inode);
+ else
+ vi = &inode->i_verity_info;
+ fsverity_free_info(*vi);
+ *vi = NULL;
}
EXPORT_SYMBOL_GPL(__fsverity_cleanup_inode);
diff --git a/fs/verity/verify.c b/fs/verity/verify.c
index 4fcad0825a12..a9c2f5c86991 100644
--- a/fs/verity/verify.c
+++ b/fs/verity/verify.c
@@ -247,7 +247,7 @@ verify_data_blocks(struct folio *data_folio, size_t len, size_t offset,
unsigned long max_ra_pages)
{
struct inode *inode = data_folio->mapping->host;
- struct fsverity_info *vi = inode->i_verity_info;
+ struct fsverity_info *vi = fsverity_get_info(inode);
const unsigned int block_size = vi->tree_params.block_size;
u64 pos = (u64)data_folio->index << PAGE_SHIFT;
diff --git a/include/linux/fsverity.h b/include/linux/fsverity.h
index 85831f36e2f8..75ff6c9c50ef 100644
--- a/include/linux/fsverity.h
+++ b/include/linux/fsverity.h
@@ -129,14 +129,24 @@ struct fsverity_operations {
#ifdef CONFIG_FS_VERITY
+static inline struct fsverity_info **fsverity_addr(const struct inode *inode)
+{
+ return ((void *)inode + inode->i_sb->s_vop->inode_info_offs);
+}
+
static inline struct fsverity_info *fsverity_get_info(const struct inode *inode)
{
+ if (!inode->i_sb->s_vop)
+ return NULL;
+
/*
* Pairs with the cmpxchg_release() in fsverity_set_info().
* I.e., another task may publish ->i_verity_info concurrently,
* executing a RELEASE barrier. We need to use smp_load_acquire() here
* to safely ACQUIRE the memory the other task published.
*/
+ if (inode->i_sb->s_vop->inode_info_offs)
+ return smp_load_acquire(fsverity_addr(inode));
return smp_load_acquire(&inode->i_verity_info);
}
@@ -165,7 +175,7 @@ void __fsverity_cleanup_inode(struct inode *inode);
*/
static inline void fsverity_cleanup_inode(struct inode *inode)
{
- if (inode->i_verity_info)
+ if (IS_VERITY(inode))
__fsverity_cleanup_inode(inode);
}
--
2.47.2
next prev parent reply other threads:[~2025-07-23 10:58 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <fhppu2rnsykr5obrib3btw7wemislq36wufnbl67salvoguaof@kkxaosrv3oho>
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 00/13] Move fscrypt and fsverity out of struct inode Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 01/13] fs: add fscrypt offset Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 02/13] fs/crypto: use accessors Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 03/13] ext4: move fscrypt to filesystem inode Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 04/13] ubifs: " Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 05/13] f2fs: " Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 06/13] ceph: " Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 07/13] fs: drop i_crypt_info from struct inode Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 08/13] fs: add fsverity offset Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 09/13] fs/verity: use accessors Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 10/13] btrfs: move fsverity to filesystem inode Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 11/13] ext4: " Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 12/13] f2fs: " Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 13/13] fs: drop i_verity_info from struct inode Christian Brauner
2025-07-22 13:09 ` [PATCH RFC DRAFT v2 00/13] Move fscrypt and fsverity out of " Christian Brauner
2025-07-22 19:27 ` [PATCH v3 " Christian Brauner
2025-07-22 19:27 ` [PATCH v3 01/13] fs: add fscrypt offset Christian Brauner
2025-07-22 20:02 ` Eric Biggers
2025-07-23 7:48 ` Christian Brauner
2025-07-23 3:49 ` Al Viro
2025-07-22 19:27 ` [PATCH v3 02/13] fs/crypto: use accessors Christian Brauner
2025-07-22 19:27 ` [PATCH v3 03/13] ext4: move fscrypt to filesystem inode Christian Brauner
2025-07-22 20:07 ` Eric Biggers
2025-07-23 8:59 ` Christian Brauner
2025-07-22 19:27 ` [PATCH v3 04/13] ubifs: " Christian Brauner
2025-07-22 19:27 ` [PATCH v3 05/13] f2fs: " Christian Brauner
2025-07-22 19:27 ` [PATCH v3 06/13] ceph: " Christian Brauner
2025-07-22 20:14 ` Eric Biggers
2025-07-23 8:58 ` Christian Brauner
2025-07-22 19:27 ` [PATCH v3 07/13] fs: drop i_crypt_info from struct inode Christian Brauner
2025-07-22 20:19 ` Eric Biggers
2025-07-23 8:52 ` Christian Brauner
2025-07-22 19:27 ` [PATCH v3 08/13] fs: add fsverity offset Christian Brauner
2025-07-23 3:53 ` Al Viro
2025-07-22 19:27 ` [PATCH v3 09/13] fs/verity: use accessors Christian Brauner
2025-07-22 20:25 ` Eric Biggers
2025-07-23 8:55 ` Christian Brauner
2025-07-22 19:27 ` [PATCH v3 10/13] btrfs: move fsverity to filesystem inode Christian Brauner
2025-07-22 19:27 ` [PATCH v3 11/13] ext4: " Christian Brauner
2025-07-22 19:27 ` [PATCH v3 12/13] f2fs: " Christian Brauner
2025-07-22 19:27 ` [PATCH v3 13/13] fs: drop i_verity_info from struct inode Christian Brauner
2025-07-23 10:57 ` [PATCH v4 00/15] Move fscrypt and fsverity out of " Christian Brauner
2025-07-23 10:57 ` [PATCH v4 01/15] fs: add fscrypt offset Christian Brauner
2025-07-23 10:57 ` [PATCH v4 02/15] fs/crypto: use accessors Christian Brauner
2025-07-25 0:29 ` Eric Biggers
2025-07-25 4:01 ` Eric Biggers
2025-07-23 10:57 ` [PATCH v4 03/15] ext4: move fscrypt to filesystem inode Christian Brauner
2025-07-25 0:32 ` Eric Biggers
2025-07-23 10:57 ` [PATCH v4 04/15] ubifs: " Christian Brauner
2025-07-23 10:57 ` [PATCH v4 05/15] f2fs: " Christian Brauner
2025-07-23 10:57 ` [PATCH v4 06/15] ceph: " Christian Brauner
2025-07-25 0:34 ` Eric Biggers
2025-07-25 8:15 ` Christian Brauner
2025-07-23 10:57 ` [PATCH v4 07/15] fs: drop i_crypt_info from struct inode Christian Brauner
2025-07-25 0:38 ` Eric Biggers
2025-07-23 10:57 ` [PATCH v4 08/15] fscrypt: rephrase documentation and comments Christian Brauner
2025-07-25 0:35 ` Eric Biggers
2025-07-23 10:57 ` [PATCH v4 09/15] fs: add fsverity offset Christian Brauner
2025-07-25 0:45 ` Eric Biggers
2025-07-23 10:57 ` Christian Brauner [this message]
2025-07-23 10:57 ` [PATCH v4 11/15] btrfs: move fsverity to filesystem inode Christian Brauner
2025-07-23 10:57 ` [PATCH v4 12/15] ext4: " Christian Brauner
2025-07-23 10:57 ` [PATCH v4 13/15] f2fs: " Christian Brauner
2025-07-23 10:57 ` [PATCH v4 14/15] fs: drop i_verity_info from struct inode Christian Brauner
2025-07-25 0:43 ` Eric Biggers
2025-07-23 10:57 ` [PATCH v4 15/15] fsverity: rephrase documentation and comments Christian Brauner
2025-07-22 13:50 ` [PATCH RFC DRAFT v2 00/13] Move fscrypt and fsverity out of struct inode Jeff Layton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250723-work-inode-fscrypt-v4-10-c8e11488a0e6@kernel.org \
--to=brauner@kernel.org \
--cc=axboe@kernel.dk \
--cc=ebiggers@kernel.org \
--cc=fsverity@lists.linux.dev \
--cc=hch@lst.de \
--cc=jack@suse.com \
--cc=jlayton@kernel.org \
--cc=josef@toxicpanda.com \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).