Re: [PATCH v2 1/2] fcntl: fix potential deadlocks for &fown_struct.lock

From: Greg KH
Date: Wed Jul 07 2021 - 11:06:53 EST


On Wed, Jul 07, 2021 at 09:51:29AM -0400, J. Bruce Fields wrote:
> On Wed, Jul 07, 2021 at 07:40:47AM -0400, Jeff Layton wrote:
> > On Wed, 2021-07-07 at 12:51 +0200, Greg KH wrote:
> > > On Wed, Jul 07, 2021 at 06:44:42AM -0400, Jeff Layton wrote:
> > > > On Wed, 2021-07-07 at 08:05 +0200, Greg KH wrote:
> > > > > On Wed, Jul 07, 2021 at 10:35:47AM +0800, Desmond Cheong Zhi Xi wrote:
> > > > > > + WARN_ON_ONCE(irqs_disabled());
> > > > >
> > > > > If this triggers, you just rebooted the box :(
> > > > >
> > > > > Please never do this, either properly handle the problem and return an
> > > > > error, or do not check for this. It is not any type of "fix" at all,
> > > > > and at most, a debugging aid while you work on the root problem.
> > > > >
> > > > > thanks,
> > > > >
> > > > > greg k-h
> > > >
> > > > Wait, what? Why would testing for irqs being disabled and throwing a
> > > > WARN_ON in that case crash the box?
> > >
> > > If panic-on-warn is enabled, which is a common setting for systems these
> > > days.
> >
> > Ok, that makes some sense.
>
> Wait, I don't get it.
>
> How are we supposed to decide when to use WARN, when to use BUG, and
> when to panic? Do we really want to treat them all as equivalent? And
> who exactly is turning on panic-on-warn?

You never use WARN or BUG, unless the system is so messed up that you
can not possibly recover from the issue. Don't be lazy, handle the
error properly and report it upwards.

thanks,

greg k-h