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]
Message-ID: <b735d174-8ad9-4ace-86ee-75dc09852537@paulmck-laptop>
Date: Tue, 23 Apr 2024 15:28:51 -0700
From: "Paul E. McKenney" <paulmck@...nel.org>
To: Z qiang <qiang.zhang1211@...il.com>
Cc: Thomas Gleixner <tglx@...utronix.de>,
	syzbot <syzbot+dce04ed6d1438ad69656@...kaller.appspotmail.com>,
	linux-kernel@...r.kernel.org, peterz@...radead.org,
	syzkaller-bugs@...glegroups.com
Subject: Re: [syzbot] [kernel?] WARNING: suspicious RCU usage in __do_softirq

On Tue, Apr 23, 2024 at 10:20:49AM +0800, Z qiang wrote:
> >
> > On Fri, Apr 19 2024 at 13:50, Z qiang wrote:
> > >> On Thu, Apr 18, 2024 at 05:49:38PM +0800, Z qiang wrote:
> > >  static __init int spawn_ksoftirqd(void)
> > >  {
> > > +       int cpu;
> > > +
> > > +       for_each_possible_cpu(cpu)
> > > +               per_cpu(ksoftirqd_work, cpu) = false;
> >
> > First of all that initialization is pointless, but why making all of
> > this complex as hell?
> >
> > Thanks,
> >
> >         tglx
> > ---
> > diff --git a/kernel/softirq.c b/kernel/softirq.c
> > index b315b21fb28c..e991d735be0d 100644
> > --- a/kernel/softirq.c
> > +++ b/kernel/softirq.c
> > @@ -508,7 +508,7 @@ static inline bool lockdep_softirq_start(void) { return false; }
> >  static inline void lockdep_softirq_end(bool in_hardirq) { }
> >  #endif
> >
> > -asmlinkage __visible void __softirq_entry __do_softirq(void)
> > +static void handle_softirqs(bool kirqd)
> >  {
> >         unsigned long end = jiffies + MAX_SOFTIRQ_TIME;
> >         unsigned long old_flags = current->flags;
> > @@ -563,8 +563,7 @@ asmlinkage __visible void __softirq_entry __do_softirq(void)
> >                 pending >>= softirq_bit;
> >         }
> >
> > -       if (!IS_ENABLED(CONFIG_PREEMPT_RT) &&
> > -           __this_cpu_read(ksoftirqd) == current)
> > +       if (!IS_ENABLED(CONFIG_PREEMPT_RT) && kirqd)
> >                 rcu_softirq_qs();
> >
> >         local_irq_disable();
> > @@ -584,6 +583,11 @@ asmlinkage __visible void __softirq_entry __do_softirq(void)
> >         current_restore_flags(old_flags, PF_MEMALLOC);
> >  }
> >
> > +asmlinkage __visible void __softirq_entry __do_softirq(void)
> > +{
> > +       handle_softirqs(false);
> > +}
> > +
> >  /**
> >   * irq_enter_rcu - Enter an interrupt context with RCU watching
> >   */
> > @@ -921,7 +925,7 @@ static void run_ksoftirqd(unsigned int cpu)
> >                  * We can safely run softirq on inline stack, as we are not deep
> >                  * in the task stack here.
> >                  */
> > -               __do_softirq();
> > +               handle_softirqs(true);
> 
> Thanks, this is good for me :),
> Paul, what do you think?

This looks quite nice to me, especially given that it avoids changing
all the other calls to __do_softirq().  Some architectures might want
to directly call handle_softirqs(), but if so, they can send the patches.

							Thanx, Paul

> Thanks
> Zqiang
> 
> >                 ksoftirqd_run_end();
> >                 cond_resched();
> >                 return;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ