[PATCH bpf] bpf: Destroy inode storage after an RCU grace period
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Thu Dec 3 17:25:53 UTC 2026
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] bpf: modified multi-line comments in bpf_inode_storage.c violate
BPF style
--
commit b8ac1197acd3f529720434f8eed1437d3463198b
Author: Chris Mason <mason at kernel.org>
bpf: Destroy inode storage after an RCU grace period
This commit moves BPF inode storage destruction from the
inode_free_security() LSM hook to inode_free_security_rcu() and changes
the storage owner from the struct inode to the LSM blob.
> diff --git a/kernel/bpf/bpf_inode_storage.c b/kernel/bpf/bpf_inode_storage.c
> index f9e81060c1f45..fdae59b25cd34 100644
> --- a/kernel/bpf/bpf_inode_storage.c
> +++ b/kernel/bpf/bpf_inode_storage.c
[ ... ]
> @@ -126,29 +123,35 @@ BPF_CALL_4(bpf_inode_storage_get, struct bpf_map *, map, struct inode *, inode,
> void *, value, u64, flags)
> {
[ ... ]
> - /* explicitly check that the inode_storage_ptr is not
> + if (!inode)
> + return (unsigned long)NULL;
> +
> + /* explicitly check that the blob is not
> * NULL as inode_storage_lookup returns NULL in this case and
> * bpf_local_storage_update expects the owner to have a
> * valid storage pointer.
> */
[ ... ]
> - /* This helper must only called from where the inode is guaranteed
> - * to have a refcount and cannot be freed.
> + /* This helper must only be called from places where the lifetime of the
> + * inode is guaranteed. Either by being refcounted or by being protected
> + * by an RCU read-side critical section.
> */
[ ... ]
> @@ -164,8 +167,9 @@ BPF_CALL_2(bpf_inode_storage_delete,
> if (!inode)
> return -EINVAL;
>
> - /* This helper must only called from where the inode is guaranteed
> - * to have a refcount and cannot be freed.
> + /* This helper must only be called from places where the lifetime of the
> + * inode is guaranteed. Either by being refcounted or by being protected
> + * by an RCU read-side critical section.
> */
> return inode_storage_delete(inode, map);
> }
[Severity: Low]
This isn't a bug, but BPF code uses the modern kernel multi-line comment
style where the opening /* sits on its own line and the comment text starts
on the following line. Could these three modified multi-line comments in
bpf_inode_storage_get() and bpf_inode_storage_delete() be updated to match?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203163706.50213-1-mason@kernel.org?part=1
More information about the Linux-security-module-archive
mailing list