From: sashiko-bot@kernel.org
To: "Leon Hwang" <leon.hwang@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v14 6/8] bpf: Add syscall common attributes support for map_create
Date: Thu, 14 May 2026 00:46:33 +0000 [thread overview]
Message-ID: <20260514004634.3DA09C19425@smtp.kernel.org> (raw)
In-Reply-To: <20260512153157.28382-7-leon.hwang@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Race condition causing unrelated file descriptor closure and resource leakage due to failure after fd_install().
--
commit 37e50113e50fb4d6482363699239289046be6ff2
Author: Leon Hwang <leon.hwang@linux.dev>
bpf: Add syscall common attributes support for map_create
This commit adds common syscall log attributes to map_create(). It creates
a verifier log to report map-creation failure reasons back to userspace,
improving debuggability.
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 2fa05ba8f1619..6600e126fbfb4 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
[ ... ]
> @@ -1611,6 +1632,31 @@ static int map_create(union bpf_attr *attr, bpfptr_t uattr)
> return err;
> }
>
> +static int map_create(union bpf_attr *attr, bpfptr_t uattr, struct bpf_common_attr *attr_common,
> + bpfptr_t uattr_common, u32 size_common)
> +{
> + struct bpf_verifier_log *log;
> + struct bpf_log_attr attr_log;
> + int err, ret;
> +
> + log = bpf_log_attr_create_vlog(&attr_log, attr_common, uattr_common, size_common);
> + if (IS_ERR(log))
> + return PTR_ERR(log);
> +
> + err = __map_create(attr, uattr, log);
> +
> + /* preserve original error even if log finalization is successful */
> + ret = bpf_log_attr_finalize(&attr_log, log);
> + if (ret) {
> + if (err >= 0)
> + close_fd(err);
Since __map_create() has already successfully created the map and installed
the file descriptor via fd_install(), the fd is globally visible to the
process at this point.
If bpf_log_attr_finalize() fails (for example, due to an invalid pointer
for log_true_size), we attempt to roll back by calling close_fd(err) and
returning an error.
Could this race with a concurrent thread?
If another thread closes this fd and opens a new file between fd_install()
and this close_fd() call, wouldn't we erroneously close an unrelated file?
Also, if another thread dups the fd before we close it, wouldn't the BPF
map remain alive and accessible to userspace even though the map_create
syscall returned a failure?
> + err = ret;
> + }
> +
> + kfree(log);
> + return err;
> +}
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260512153157.28382-1-leon.hwang@linux.dev?part=6
next prev parent reply other threads:[~2026-05-14 0:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 15:31 [PATCH bpf-next v14 0/8] bpf: Extend BPF syscall with common attributes support Leon Hwang
2026-05-12 15:31 ` [PATCH bpf-next v14 1/8] " Leon Hwang
2026-05-13 22:48 ` sashiko-bot
2026-05-12 15:31 ` [PATCH bpf-next v14 2/8] libbpf: Add support for extended BPF syscall Leon Hwang
2026-05-12 16:23 ` bot+bpf-ci
2026-05-13 2:10 ` Leon Hwang
2026-05-12 15:31 ` [PATCH bpf-next v14 3/8] bpf: Refactor reporting log_true_size for prog_load Leon Hwang
2026-05-12 15:31 ` [PATCH bpf-next v14 4/8] bpf: Add syscall common attributes support " Leon Hwang
2026-05-13 23:56 ` sashiko-bot
2026-05-12 15:31 ` [PATCH bpf-next v14 5/8] bpf: Add syscall common attributes support for btf_load Leon Hwang
2026-05-12 15:31 ` [PATCH bpf-next v14 6/8] bpf: Add syscall common attributes support for map_create Leon Hwang
2026-05-14 0:46 ` sashiko-bot [this message]
2026-05-12 15:31 ` [PATCH bpf-next v14 7/8] libbpf: " Leon Hwang
2026-05-14 1:08 ` sashiko-bot
2026-05-12 15:31 ` [PATCH bpf-next v14 8/8] selftests/bpf: Add tests to verify map create failure log Leon Hwang
2026-05-14 1:25 ` sashiko-bot
2026-05-12 19:50 ` [PATCH bpf-next v14 0/8] bpf: Extend BPF syscall with common attributes support patchwork-bot+netdevbpf
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=20260514004634.3DA09C19425@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=leon.hwang@linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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