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] [day] [month] [year] [list]
Message-ID: <CAJF2gTTo2E539HkkPGah-NtAf4U0HFLU_t=6VT0_6S=M1YswzQ@mail.gmail.com>
Date:   Fri, 30 Sep 2022 20:27:57 +0800
From:   Guo Ren <guoren@...nel.org>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     arnd@...db.de, palmer@...osinc.com, tglx@...utronix.de,
        luto@...nel.org, conor.dooley@...rochip.com, heiko@...ech.de,
        jszhang@...nel.org, lazyparser@...il.com, falcon@...ylab.org,
        chenhuacai@...nel.org, apatel@...tanamicro.com,
        atishp@...shpatra.org, palmer@...belt.com,
        paul.walmsley@...ive.com, mark.rutland@....com,
        zouyipeng@...wei.com, bigeasy@...utronix.de,
        David.Laight@...lab.com, linux-arch@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-riscv@...ts.infradead.org,
        Guo Ren <guoren@...ux.alibaba.com>
Subject: Re: [PATCH V5 06/11] entry: Prevent DEBUG_PREEMPT warning

On Tue, Sep 20, 2022 at 9:45 AM Guo Ren <guoren@...nel.org> wrote:
>
> On Mon, Sep 19, 2022 at 7:59 PM Peter Zijlstra <peterz@...radead.org> wrote:
> >
> > On Sun, Sep 18, 2022 at 11:52:41AM -0400, guoren@...nel.org wrote:
> > > From: Guo Ren <guoren@...ux.alibaba.com>
> > >
> > > When DEBUG_PREEMPT=y,
> > >       exit_to_user_mode_prepare
> > >       ->tick_nohz_user_enter_prepare
> > >         ->tick_nohz_full_cpu(smp_processor_id())
> > >           ->smp_processor_id()
> > >             ->debug_smp_processor_id()
> > >               ->check preempt_count() then:
> > >
> > > [    5.717610] BUG: using smp_processor_id() in preemptible [00000000]
> > > code: S20urandom/94
> > > [    5.718111] caller is debug_smp_processor_id+0x24/0x38
> > > [    5.718417] CPU: 1 PID: 94 Comm: S20urandom Not tainted
> > > 6.0.0-rc3-00010-gfd0a0d619c63-dirty #238
> > > [    5.718886] Hardware name: riscv-virtio,qemu (DT)
> > > [    5.719136] Call Trace:
> > > [    5.719281] [<ffffffff800055fc>] dump_backtrace+0x2c/0x3c
> > > [    5.719566] [<ffffffff80ae6cb0>] show_stack+0x44/0x5c
> > > [    5.720023] [<ffffffff80aee870>] dump_stack_lvl+0x74/0xa4
> > > [    5.720557] [<ffffffff80aee8bc>] dump_stack+0x1c/0x2c
> > > [    5.721033] [<ffffffff80af65c0>]
> > > check_preemption_disabled+0x104/0x108
> > > [    5.721538] [<ffffffff80af65e8>] debug_smp_processor_id+0x24/0x38
> > > [    5.722001] [<ffffffff800aee30>] exit_to_user_mode_prepare+0x48/0x178
> > > [    5.722355] [<ffffffff80af5bf4>] irqentry_exit_to_user_mode+0x18/0x30
> > > [    5.722685] [<ffffffff80af5c70>] irqentry_exit+0x64/0xa4
> > > [    5.722953] [<ffffffff80af52f4>] do_page_fault+0x1d8/0x544
> > > [    5.723291] [<ffffffff80003310>] ret_from_exception+0x0/0xb8
> > >
> > > (Above is found in riscv platform with generic_entry)
> > >
> > > The smp_processor_id() needs irqs disable or preempt_disable, so use
> > > preempt dis/in protecting the tick_nohz_user_enter_prepare().
> > >
> > > Signed-off-by: Guo Ren <guoren@...ux.alibaba.com>
> > > Signed-off-by: Guo Ren <guoren@...nel.org>
> > > ---
> > >  kernel/entry/common.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > >
> > > diff --git a/kernel/entry/common.c b/kernel/entry/common.c
> > > index 063068a9ea9b..36e4cd50531c 100644
> > > --- a/kernel/entry/common.c
> > > +++ b/kernel/entry/common.c
> > > @@ -194,8 +194,10 @@ static void exit_to_user_mode_prepare(struct pt_regs *regs)
> > >
> > >       lockdep_assert_irqs_disabled();
> >
> >     Observe ^^^^
> Thanks! I would enable PROVE_LOCKING for test.
It's my bug in page_fault, here is the solution:

@@ -358,6 +358,8 @@ asmlinkage void noinstr do_page_fault(struct pt_regs *regs)

        __do_page_fault(regs);

+       local_irq_disable();
+
        irqentry_exit(regs, state);
 }
 NOKPROBE_SYMBOL(do_page_fault);

>
> >
> > >
> > > +     preempt_disable();
> > >       /* Flush pending rcuog wakeup before the last need_resched() check */
> > >       tick_nohz_user_enter_prepare();
> > > +     preempt_enable();
> >
> > This makes no sense; if IRQs are disabled, check_preemption_disabled()
> > should bail early per:
> >
> >         if (irqs_disabled())
> >                 goto out;
> Ditto.
>
>
> --
> Best Regards
>  Guo Ren



-- 
Best Regards
 Guo Ren

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ