public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@meta.com>
To: Jiri Olsa <jolsa@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, Martin KaFai Lau <kafai@fb.com>,
	Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
	Florent Revest <revest@chromium.org>
Subject: Re: [PATCHv3 bpf-next 2/3] bpf: Do cleanup in bpf_bprintf_cleanup only when needed
Date: Fri, 16 Dec 2022 16:25:47 -0800	[thread overview]
Message-ID: <e87a43b3-3b8c-cd23-6563-9525f51982c2@meta.com> (raw)
In-Reply-To: <20221215214430.1336195-3-jolsa@kernel.org>



On 12/15/22 1:44 PM, Jiri Olsa wrote:
> Currently we always cleanup/decrement bpf_bprintf_nest_level
> variable in bpf_bprintf_cleanup if it's > 0.
> 
> There's possible scenario where this could cause a problem,
> when bpf_bprintf_prepare does not get bin_args buffer (because
> num_args is 0) and following bpf_bprintf_cleanup call decrements
> bpf_bprintf_nest_level variable, like:
> 
>    in task context:
>      bpf_bprintf_prepare(num_args != 0) increments 'bpf_bprintf_nest_level = 1'
>      -> first irq :
>         bpf_bprintf_prepare(num_args == 0)
>         bpf_bprintf_cleanup decrements 'bpf_bprintf_nest_level = 0'
>      -> second irq:
>         bpf_bprintf_prepare(num_args != 0) bpf_bprintf_nest_level = 1
>         gets same buffer as task context above
> 
> Adding check to bpf_bprintf_cleanup and doing the real cleanup
> only if we got bin_args data in the first place.
> 
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>

Acked-by: Yonghong Song <yhs@fb.com>

  reply	other threads:[~2022-12-17  0:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-15 21:44 [PATCHv3 bpf-next 0/3] bpf: Get rid of trace_printk_lock Jiri Olsa
2022-12-15 21:44 ` [PATCHv3 bpf-next 1/3] bpf: Add struct for bin_args arg in bpf_bprintf_prepare Jiri Olsa
2022-12-17  0:25   ` Yonghong Song
2022-12-15 21:44 ` [PATCHv3 bpf-next 2/3] bpf: Do cleanup in bpf_bprintf_cleanup only when needed Jiri Olsa
2022-12-17  0:25   ` Yonghong Song [this message]
2022-12-15 21:44 ` [PATCHv3 bpf-next 3/3] bpf: Remove trace_printk_lock Jiri Olsa
2022-12-17  0:28   ` Yonghong Song
2022-12-19 21:10 ` [PATCHv3 bpf-next 0/3] bpf: Get rid of trace_printk_lock 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=e87a43b3-3b8c-cd23-6563-9525f51982c2@meta.com \
    --to=yhs@meta.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=revest@chromium.org \
    --cc=sdf@google.com \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /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