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: <b157bed2-2ada-4086-bb67-ae4e6762bd72@suswa.mountain>
Date: Mon, 1 Jul 2024 19:21:11 +0200
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc: oe-kbuild@...ts.linux.dev,
	Ronald Tschalär <ronald@...ovation.ch>,
	lkp@...el.com, oe-kbuild-all@...ts.linux.dev,
	linux-kernel@...r.kernel.org,
	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: Re: drivers/input/keyboard/applespi.c:1833 applespi_drain_writes()
 warn: mixing irqsave and irq

On Mon, Jul 01, 2024 at 10:14:00AM -0700, Dmitry Torokhov wrote:
> > 038b1a05eae666 Ronald Tschalär 2019-07-15  1826  static void applespi_drain_writes(struct applespi_data *applespi)
> > 038b1a05eae666 Ronald Tschalär 2019-07-15  1827  {
> > 038b1a05eae666 Ronald Tschalär 2019-07-15  1828  	unsigned long flags;
> > 038b1a05eae666 Ronald Tschalär 2019-07-15  1829  
> > 038b1a05eae666 Ronald Tschalär 2019-07-15  1830  	spin_lock_irqsave(&applespi->cmd_msg_lock, flags);
> > 
> > _irqsave() sort of implies that potentially the caller has disabled IRQs,
> > otherwise we would use spin_lock_irq() if we knew they hadn't disabled
> > IRQs.
> > 
> > 038b1a05eae666 Ronald Tschalär 2019-07-15  1831  
> > 038b1a05eae666 Ronald Tschalär 2019-07-15  1832  	applespi->drain = true;
> > 038b1a05eae666 Ronald Tschalär 2019-07-15 @1833  	wait_event_lock_irq(applespi->drain_complete, !applespi->write_active,
> > 038b1a05eae666 Ronald Tschalär 2019-07-15  1834  			    applespi->cmd_msg_lock);
> > 
> > This will renable IRQs briefly and then disable them again.
> > 
> > 038b1a05eae666 Ronald Tschalär 2019-07-15  1835  
> > 038b1a05eae666 Ronald Tschalär 2019-07-15  1836  	spin_unlock_irqrestore(&applespi->cmd_msg_lock, flags);
> > 
> > This will set them back to how they were at the start of the function.
> > 
> > The issue is that if the caller really wanted IRQs disabled, then it's
> > not necessarilly a good idea to enable them at all in the
> > wait_event_lock_irq() macro.  I suspect that in real life no callers
> > disable IRQs so it's not an issue.  But anyway, that's what the warning
> > is about.
> 
> applespi_drain_writes() and applespi_drain_reads() are only called from
> the process context with interrupts enabled, so it looks like we should
> simply change spin_lock_irqsave() to spin_lock_irq().
> 
> I am taking patches ;)

Sure.  I can send that.

regards,
dan carpenter


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ