BPF List
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	John Ogness <john.ogness@linutronix.de>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>, Petr Mladek <pmladek@suse.com>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	bpf <bpf@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] bpf: defer printk() inside __bpf_prog_run()
Date: Wed, 26 Jun 2024 12:27:48 -0400	[thread overview]
Message-ID: <20240626122748.065a903b@rorschach.local.home> (raw)
In-Reply-To: <744c9c43-9e4f-4069-9773-067036237bff@I-love.SAKURA.ne.jp>

On Wed, 26 Jun 2024 09:02:22 +0900
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> wrote:

> On 2024/06/26 8:56, Alexei Starovoitov wrote:
> > You are missing the point. The bug has nothing to do with bpf.  
> 
> The bug is caused by calling tracing hooks with rq lock held.
> If tracing hooks do not exist, this bug does not exist.

Could you expand on this. What tracing hooks are called with rq lock
held? You mean the scheduling events?

> 
> > It can happen without any bpf loaded. Exactly the same way.
> > should_fail_usercopy() is called on all user accesses.  
> 
> Not all callers of e.g. should_fail_usercopy() are holding rq lock.

Sorry, but if a function is going to call printk and can be called in
any context that has rq locks held, then it should be doing the printk
deferred and preempt disable logic, and not expect the caller of it to
do that dirty work. Otherwise this will expand out of control.

The same goes with calling spin_lock_irq() vs spin_lock_irqsave(). If a
function is called with interrupts disabled sometimes and sometimes
not, it needs the irqsave() version. We don't make all callers of it
disable interrupts.

-- Steve

  reply	other threads:[~2024-06-26 16:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-25 13:56 [PATCH] bpf: defer printk() inside __bpf_prog_run() Tetsuo Handa
2024-06-25 14:17 ` John Ogness
2024-06-25 15:07   ` Tetsuo Handa
2024-06-25 15:47     ` John Ogness
2024-06-25 16:05       ` Tetsuo Handa
2024-06-25 19:32         ` Alexei Starovoitov
2024-06-25 23:52           ` Tetsuo Handa
2024-06-25 23:56             ` Alexei Starovoitov
2024-06-26  0:02               ` Tetsuo Handa
2024-06-26 16:27                 ` Steven Rostedt [this message]
2024-06-26 22:15                   ` Tetsuo Handa
2024-06-26 22:33                     ` Steven Rostedt
2024-06-26 23:08                       ` Tetsuo Handa
2024-06-26 23:52                         ` Alexei Starovoitov
2024-06-27  0:00                           ` Tetsuo Handa
2024-06-27  0:09                         ` Steven Rostedt
2024-06-27  0:21                           ` Tetsuo Handa
2024-06-27  0:29                             ` Steven Rostedt
2024-06-27 11:10                               ` [PATCH] sched/core: defer printk() while rq lock is held Tetsuo Handa
2024-06-26  8:45             ` [PATCH] bpf: defer printk() inside __bpf_prog_run() Petr Mladek
2024-06-26  8:18       ` Petr Mladek

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=20240626122748.065a903b@rorschach.local.home \
    --to=rostedt@goodmis.org \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=john.ogness@linutronix.de \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=pmladek@suse.com \
    --cc=sdf@fomichev.me \
    --cc=senozhatsky@chromium.org \
    --cc=song@kernel.org \
    --cc=yonghong.song@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