lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 25 Jun 2024 12:32:32 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>
Cc: John Ogness <john.ogness@...utronix.de>, Alexei Starovoitov <ast@...nel.org>, 
	Daniel Borkmann <daniel@...earbox.net>, Andrii Nakryiko <andrii@...nel.org>, 
	Martin KaFai Lau <martin.lau@...ux.dev>, Eduard Zingerman <eddyz87@...il.com>, Song Liu <song@...nel.org>, 
	Yonghong Song <yonghong.song@...ux.dev>, John Fastabend <john.fastabend@...il.com>, 
	KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>, 
	Jiri Olsa <jolsa@...nel.org>, Petr Mladek <pmladek@...e.com>, 
	Steven Rostedt <rostedt@...dmis.org>, Sergey Senozhatsky <senozhatsky@...omium.org>, 
	bpf <bpf@...r.kernel.org>, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] bpf: defer printk() inside __bpf_prog_run()

On Tue, Jun 25, 2024 at 9:05 AM Tetsuo Handa
<penguin-kernel@...ove.sakura.ne.jp> wrote:
>
> On 2024/06/26 0:47, John Ogness wrote:
> > On 2024-06-26, Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp> wrote:
> >> On 2024/06/25 23:17, John Ogness wrote:
> >>> On 2024-06-25, Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp> wrote:
> >>>> syzbot is reporting circular locking dependency inside __bpf_prog_run(),
> >>>> for fault injection calls printk() despite rq lock is already held.
> >>>>
> >>>> Guard __bpf_prog_run() using printk_deferred_{enter,exit}() (and
> >>>> preempt_{disable,enable}() if CONFIG_PREEMPT_RT=n) in order to defer any
> >>>> printk() messages.
> >>>
> >>> Why is the reason for disabling preemption?
> >>
> >> Because since kernel/printk/printk_safe.c uses a percpu counter for deferring
> >> printk(), printk_safe_enter() and printk_safe_exit() have to be called from
> >> the same CPU. preempt_disable() before printk_safe_enter() and preempt_enable()
> >> after printk_safe_exit() guarantees that printk_safe_enter() and
> >> printk_safe_exit() are called from the same CPU.
> >
> > Yes, but we already have cant_migrate(). Are you suggesting there are
> > configurations where cant_migrate() is true but the context can be
> > migrated anyway?
>
> No, I'm not aware of such configuration.
>
> Does migrate_disable() imply preempt_disable() ?
> If yes, we don't need to also call preempt_disable().
> My understanding is that migration is about "on which CPU a process runs"
> and preemption is about "whether a different process runs on this CPU".
> That is, disabling migration and disabling preemption are independent.
>
> Is migrate_disable() alone sufficient for managing a percpu counter?
> If yes, we don't need to also call preempt_disable() in order to manage
> a percpu counter.

If you want to add printk_deferred_enter() it
probably should be in should_fail_ex(). Not here.
We will not be wrapping all bpf progs this way.

pw-bot: cr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ