From: Martin KaFai Lau <martin.lau@linux.dev>
To: Song Liu <song@kernel.org>
Cc: bpf@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org, kernel-team@meta.com,
andrii@kernel.org, eddyz87@gmail.com, ast@kernel.org,
daniel@iogearbox.net, viro@zeniv.linux.org.uk,
brauner@kernel.org, jack@suse.cz, kpsingh@kernel.org,
mattbobrowski@google.com, amir73il@gmail.com, repnop@google.com,
jlayton@kernel.org, josef@toxicpanda.com, mic@digikod.net,
gnoack@google.com
Subject: Re: [PATCH v2 bpf-next 3/4] bpf: Add recursion prevention logic for inode storage
Date: Tue, 12 Nov 2024 15:26:43 -0800 [thread overview]
Message-ID: <c2239508-6d00-4176-b0d6-3e07e06a367f@linux.dev> (raw)
In-Reply-To: <20241112083700.356299-4-song@kernel.org>
On 11/12/24 12:36 AM, Song Liu wrote:
> +static void *__bpf_inode_storage_get(struct bpf_map *map, struct inode *inode,
> + void *value, u64 flags, gfp_t gfp_flags, bool nobusy)
> {
> struct bpf_local_storage_data *sdata;
>
> - WARN_ON_ONCE(!bpf_rcu_lock_held());
> - if (flags & ~(BPF_LOCAL_STORAGE_GET_F_CREATE))
> - return (unsigned long)NULL;
> -
> + /* explicitly check that the inode not NULL */
> if (!inode)
> - return (unsigned long)NULL;
> + return NULL;
>
> sdata = inode_storage_lookup(inode, map, true);
s/true/nobusy/
> if (sdata)
> - return (unsigned long)sdata->data;
> + return sdata->data;
>
> - /* This helper must only called from where the inode is guaranteed
> - * to have a refcount and cannot be freed.
> - */
> - if (flags & BPF_LOCAL_STORAGE_GET_F_CREATE) {
> + /* only allocate new storage, when the inode is refcounted */
> + if (atomic_read(&inode->i_count) &&
> + flags & BPF_LOCAL_STORAGE_GET_F_CREATE) {
(flags & BPF_LOCAL_STORAGE_GET_F_CREATE) && nobusy) {
> sdata = bpf_local_storage_update(
> inode, (struct bpf_local_storage_map *)map, value,
> BPF_NOEXIST, false, gfp_flags);
> - return IS_ERR(sdata) ? (unsigned long)NULL :
> - (unsigned long)sdata->data;
> + return IS_ERR(sdata) ? NULL : sdata->data;
> }
>
> - return (unsigned long)NULL;
> + return NULL;
> +}
next prev parent reply other threads:[~2024-11-12 23:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-12 8:36 [PATCH v2 bpf-next 0/4] Make inode storage available to tracing prog Song Liu
2024-11-12 8:36 ` [PATCH v2 bpf-next 1/4] bpf: lsm: Remove hook to bpf_task_storage_free Song Liu
2024-11-12 8:36 ` [PATCH v2 bpf-next 2/4] bpf: Make bpf inode storage available to tracing program Song Liu
2024-11-12 22:04 ` Alexei Starovoitov
2024-11-12 23:00 ` Martin KaFai Lau
2024-11-12 23:10 ` Song Liu
2024-11-12 8:36 ` [PATCH v2 bpf-next 3/4] bpf: Add recursion prevention logic for inode storage Song Liu
2024-11-12 23:26 ` Martin KaFai Lau [this message]
2024-11-12 8:37 ` [PATCH v2 bpf-next 4/4] selftest/bpf: Test inode local storage recursion prevention Song Liu
2024-11-12 23:46 ` [PATCH v2 bpf-next 0/4] Make inode storage available to tracing prog Martin KaFai Lau
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=c2239508-6d00-4176-b0d6-3e07e06a367f@linux.dev \
--to=martin.lau@linux.dev \
--cc=amir73il@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=gnoack@google.com \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=josef@toxicpanda.com \
--cc=kernel-team@meta.com \
--cc=kpsingh@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mattbobrowski@google.com \
--cc=mic@digikod.net \
--cc=repnop@google.com \
--cc=song@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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