[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2cb0cd4f-5d78-4b7f-b280-2a3377ffbc21@linux.dev>
Date: Tue, 12 Nov 2024 15:00:48 -0800
From: Martin KaFai Lau <martin.lau@...ux.dev>
To: Song Liu <song@...nel.org>
Cc: bpf@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-security-module@...r.kernel.org,
kernel-team@...a.com, andrii@...nel.org, eddyz87@...il.com, ast@...nel.org,
daniel@...earbox.net, viro@...iv.linux.org.uk, brauner@...nel.org,
jack@...e.cz, kpsingh@...nel.org, mattbobrowski@...gle.com,
amir73il@...il.com, repnop@...gle.com, jlayton@...nel.org,
josef@...icpanda.com, mic@...ikod.net, gnoack@...gle.com
Subject: Re: [PATCH v2 bpf-next 2/4] bpf: Make bpf inode storage available to
tracing program
On 11/12/24 12:36 AM, Song Liu wrote:
> void __destroy_inode(struct inode *inode)
> {
> BUG_ON(inode_has_buffers(inode));
> + bpf_inode_storage_free(inode);
Not sure if this is done in the rcu callback (i.e. after the rcu gp). Please check.
> inode_detach_wb(inode);
> security_inode_free(inode);
> fsnotify_inode_delete(inode);
[ ... ]
> @@ -136,12 +119,7 @@ BPF_CALL_5(bpf_inode_storage_get, struct bpf_map *, map, struct inode *, inode,
> if (flags & ~(BPF_LOCAL_STORAGE_GET_F_CREATE))
> return (unsigned long)NULL;
>
> - /* explicitly check that the inode_storage_ptr 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.
> - */
> - if (!inode || !inode_storage_ptr(inode))
> + if (!inode)
> return (unsigned long)NULL;
There is an atomic_read in this function:
/* only allocate new storage, when the inode is refcounted */
if (atomic_read(&inode->i_count) &&
flags & BPF_LOCAL_STORAGE_GET_F_CREATE) {
If the bpf_inode_storage_free is not done after rcu gp, this will need a
inc_not_zero like how the sk storage does. I think moving the storage_free to
the inode rcu call back may be easier if it is not the case now.
Powered by blists - more mailing lists