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: <CAMRc=MdoG1Ku-hbBWt7Jc+d4=ANfshPWwW3C_G-e2GdyggqG1w@mail.gmail.com>
Date: Wed, 31 Jan 2024 10:28:19 +0100
From: Bartosz Golaszewski <brgl@...ev.pl>
To: paulmck@...nel.org
Cc: Linus Walleij <linus.walleij@...aro.org>, Kent Gibson <warthog618@...il.com>, 
	Alex Elder <elder@...aro.org>, Geert Uytterhoeven <geert+renesas@...der.be>, 
	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>, 
	Wolfram Sang <wsa-dev@...g-engineering.com>, oe-kbuild-all@...ts.linux.dev, 
	linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org, 
	Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: Re: [PATCH 20/22] gpio: protect the pointer to gpio_chip in
 gpio_device with SRCU

On Wed, Jan 31, 2024 at 10:24 AM Paul E. McKenney <paulmck@...nel.org> wrote:
>
> On Wed, Jan 31, 2024 at 10:02:40AM +0100, Bartosz Golaszewski wrote:
> > On Wed, Jan 31, 2024 at 3:21 AM kernel test robot <lkp@...el.com> wrote:
> > >
> > > Hi Bartosz,
> > >
> > > kernel test robot noticed the following build warnings:
> > >
> > > [auto build test WARNING on brgl/gpio/for-next]
> > > [also build test WARNING on linus/master v6.8-rc2 next-20240130]
> > > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > > And when submitting patch, we suggest to use '--base' as documented in
> > > https://git-scm.com/docs/git-format-patch#_base_tree_information]
> > >
> > > url:    https://github.com/intel-lab-lkp/linux/commits/Bartosz-Golaszewski/gpio-protect-the-list-of-GPIO-devices-with-SRCU/20240130-205537
> > > base:   https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next
> > > patch link:    https://lore.kernel.org/r/20240130124828.14678-21-brgl%40bgdev.pl
> > > patch subject: [PATCH 20/22] gpio: protect the pointer to gpio_chip in gpio_device with SRCU
> > > config: x86_64-randconfig-122-20240131 (https://download.01.org/0day-ci/archive/20240131/202401311050.YNdm98Hv-lkp@intel.com/config)
> > > compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240131/202401311050.YNdm98Hv-lkp@intel.com/reproduce)
> > >
> > > 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>
> > > | Closes: https://lore.kernel.org/oe-kbuild-all/202401311050.YNdm98Hv-lkp@intel.com/
> > >
> > > sparse warnings: (new ones prefixed by >>)
> > > >> drivers/gpio/gpiolib.c:444:22: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.c:444:22: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.c:444:22: sparse:    struct gpio_chip *
> > >    drivers/gpio/gpiolib.c:1103:9: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.c:1103:9: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.c:1103:9: sparse:    struct gpio_chip *
> > >    drivers/gpio/gpiolib.c:1182:22: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.c:1182:22: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.c:1182:22: sparse:    struct gpio_chip *
> > >    drivers/gpio/gpiolib.c:2970:14: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.c:2970:14: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.c:2970:14: sparse:    struct gpio_chip *
> > >    drivers/gpio/gpiolib.c:3004:22: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.c:3004:22: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.c:3004:22: sparse:    struct gpio_chip *
> > >    drivers/gpio/gpiolib.c:3585:14: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.c:3585:14: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.c:3585:14: sparse:    struct gpio_chip *
> > >    drivers/gpio/gpiolib.c:4772:14: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.c:4772:14: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.c:4772:14: sparse:    struct gpio_chip *
> > >    drivers/gpio/gpiolib.c:4846:14: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.c:4846:14: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.c:4846:14: sparse:    struct gpio_chip *
> > >    drivers/gpio/gpiolib.c: note: in included file:
> > > >> drivers/gpio/gpiolib.h:202:1: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip *
> > > >> drivers/gpio/gpiolib.h:202:1: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip *
> > > >> drivers/gpio/gpiolib.h:202:1: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip *
> > > >> drivers/gpio/gpiolib.h:202:1: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip *
> > > >> drivers/gpio/gpiolib.h:202:1: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip *
> > > >> drivers/gpio/gpiolib.h:202:1: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip *
> > > >> drivers/gpio/gpiolib.h:202:1: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip *
> > > >> drivers/gpio/gpiolib.h:202:1: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip *
> > > >> drivers/gpio/gpiolib.h:202:1: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip *
> > > >> drivers/gpio/gpiolib.h:202:1: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip *
> > > >> drivers/gpio/gpiolib.h:202:1: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip *
> > > >> drivers/gpio/gpiolib.h:202:1: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip *
> > > >> drivers/gpio/gpiolib.h:202:1: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip *
> > > >> drivers/gpio/gpiolib.h:202:1: sparse: sparse: incompatible types in comparison expression (different address spaces):
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip [noderef] __rcu *
> > >    drivers/gpio/gpiolib.h:202:1: sparse:    struct gpio_chip *
> > >
> > > vim +444 drivers/gpio/gpiolib.c
> > >
> > >    422
> > >    423  /*
> > >    424   * Convert a GPIO name to its descriptor
> > >    425   * Note that there is no guarantee that GPIO names are globally unique!
> > >    426   * Hence this function will return, if it exists, a reference to the first GPIO
> > >    427   * line found that matches the given name.
> > >    428   */
> > >    429  static struct gpio_desc *gpio_name_to_desc(const char * const name)
> > >    430  {
> > >    431          struct gpio_device *gdev;
> > >    432          struct gpio_desc *desc;
> > >    433          struct gpio_chip *gc;
> > >    434
> > >    435          if (!name)
> > >    436                  return NULL;
> > >    437
> > >    438          guard(srcu)(&gpio_devices_srcu);
> > >    439
> > >    440          list_for_each_entry_srcu(gdev, &gpio_devices, list,
> > >    441                                   srcu_read_lock_held(&gpio_devices_srcu)) {
> > >    442                  guard(srcu)(&gdev->srcu);
> > >    443
> > >  > 444                  gc = rcu_dereference(gdev->chip);
> > >    445                  if (!gc)
> > >    446                          continue;
> > >    447
> > >    448                  for_each_gpio_desc(gc, desc) {
> > >    449                          if (desc->name && !strcmp(desc->name, name))
> > >    450                                  return desc;
> > >    451                  }
> > >    452          }
> > >    453
> > >    454          return NULL;
> > >    455  }
> > >    456
> > >
> > > --
> > > 0-DAY CI Kernel Test Service
> > > https://github.com/intel/lkp-tests/wiki
> >
> > Paul,
> >
> > Should I care about these warnings? They seem to be emitted for a lot
> > of RCU code already upstream. I'm not even sure how I'd go about
> > addressing them honestly.
>
> This is maintainer's choice.
>
> The fix would be to apply __rcu to the definition of ->chip.  The benefit
> is that it finds bugs where rcu-protected pointers are used without RCU
> primitives and vice versa.
>
>                                                         Thanx, Paul

Ah, good point. I marked the other RCU-protected fields like
descriptor label but forgot this one.

It also seems like I need to use __rcu for all function arguments
taking an RCU-protected pointer as argument?

Bart

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ