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-next>] [day] [month] [year] [list]
Message-ID: <3e789ab9-ebfc-40a2-b90d-b8b55e0cfaac@suswa.mountain>
Date: Mon, 1 Jul 2024 18:30:38 +0200
From: Dan Carpenter <dan.carpenter@...aro.org>
To: oe-kbuild@...ts.linux.dev,
	Ronald Tschalär <ronald@...ovation.ch>
Cc: lkp@...el.com, oe-kbuild-all@...ts.linux.dev,
	linux-kernel@...r.kernel.org,
	Dmitry Torokhov <dmitry.torokhov@...il.com>,
	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: drivers/input/keyboard/applespi.c:1833 applespi_drain_writes() warn:
 mixing irqsave and irq

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   6d6444ba82053c716fb5ac83346202659023044e
commit: 038b1a05eae6666b731920e46f47d8e2332e07ff Input: add Apple SPI keyboard and trackpad driver
config: x86_64-randconfig-161-20240628 (https://download.01.org/0day-ci/archive/20240628/202406280337.1Av9qm8V-lkp@intel.com/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@...el.com>
| Reported-by: Dan Carpenter <dan.carpenter@...aro.org>
| Closes: https://lore.kernel.org/r/202406280337.1Av9qm8V-lkp@intel.com/

smatch warnings:
drivers/input/keyboard/applespi.c:1833 applespi_drain_writes() warn: mixing irqsave and irq
drivers/input/keyboard/applespi.c:1845 applespi_drain_reads() warn: mixing irqsave and irq

vim +1833 drivers/input/keyboard/applespi.c

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.

I suspect that kbuild-bot has a 5 year cut off for warnings and if this
had been a month older then kbuild-bot would have ignored it.  :P

038b1a05eae666 Ronald Tschalär 2019-07-15  1837  }
038b1a05eae666 Ronald Tschalär 2019-07-15  1838  
038b1a05eae666 Ronald Tschalär 2019-07-15  1839  static void applespi_drain_reads(struct applespi_data *applespi)
038b1a05eae666 Ronald Tschalär 2019-07-15  1840  {
038b1a05eae666 Ronald Tschalär 2019-07-15  1841  	unsigned long flags;
038b1a05eae666 Ronald Tschalär 2019-07-15  1842  
038b1a05eae666 Ronald Tschalär 2019-07-15  1843  	spin_lock_irqsave(&applespi->cmd_msg_lock, flags);
038b1a05eae666 Ronald Tschalär 2019-07-15  1844  
038b1a05eae666 Ronald Tschalär 2019-07-15 @1845  	wait_event_lock_irq(applespi->drain_complete, !applespi->read_active,
038b1a05eae666 Ronald Tschalär 2019-07-15  1846  			    applespi->cmd_msg_lock);
038b1a05eae666 Ronald Tschalär 2019-07-15  1847  
038b1a05eae666 Ronald Tschalär 2019-07-15  1848  	applespi->suspended = true;
038b1a05eae666 Ronald Tschalär 2019-07-15  1849  
038b1a05eae666 Ronald Tschalär 2019-07-15  1850  	spin_unlock_irqrestore(&applespi->cmd_msg_lock, flags);
038b1a05eae666 Ronald Tschalär 2019-07-15  1851  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ