BPF List
 help / color / mirror / Atom feed
From: Leon Hwang <leon.hwang@linux.dev>
To: sashiko-reviews@lists.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 22:25:07 +0800	[thread overview]
Message-ID: <eae54df8-e589-4182-8c4f-5f14a8de904e@linux.dev> (raw)
In-Reply-To: <20260514004634.3DA09C19425@smtp.kernel.org>

On 2026/5/14 08:46, sashiko-bot@kernel.org wrote:
[...]
>> +
>> +	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?
> 

Replied in v13
https://lore.kernel.org/bpf/3c9b4ff0-7a62-4053-83c7-23151905c742@linux.dev/.

Thanks,
Leon

[...]


  reply	other threads:[~2026-05-14 14:25 UTC|newest]

Thread overview: 21+ 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-14 14:24     ` Leon Hwang
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
2026-05-14 14:25     ` Leon Hwang [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-14 14:25     ` Leon Hwang
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-14 14:26     ` Leon Hwang
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=eae54df8-e589-4182-8c4f-5f14a8de904e@linux.dev \
    --to=leon.hwang@linux.dev \
    --cc=bpf@vger.kernel.org \
    --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