From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Cc: Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] gpiolib: synchronize updates of descriptor labels
Date: Thu, 5 Nov 2026 16:53:10 +0200 [thread overview]
Message-ID: <auyYVmSaLBS--52n@ashevche-desk.local> (raw)
In-Reply-To: <20261105-gpiolib-set-desc-label-corruption-v1-1-fa84726ceac0@oss.qualcomm.com>
On Thu, Nov 05, 2026 at 02:23:45PM +0100, Bartosz Golaszewski wrote:
> desc_set_label() swaps desc->label with rcu_replace_pointer() but
> without any synchronization of concurrent updates. The swap is a plain
> read + write: two threads can observe the same old label and then call
s/call//
> call_scru() on the same SRCU head corrupting the state of the chain.
>
> Add a spinlock to struct gpio_device - we're using a single spinlock for
> all descriptors as using a per-descriptor lock would unnecessarily bloat
> the size of the desc array with very little chance and no consequences of
> contention - and use it to serialize the pointer update.
...
> - old = rcu_replace_pointer(desc->label, new, 1);
> - if (old)
> - call_srcu(&desc->gdev->desc_srcu, &old->rh, desc_free_label);
> + scoped_guard(spinlock, &desc->gdev->desc_lock) {
> + old = rcu_replace_pointer(desc->label, new,
> + lockdep_is_held(&desc->gdev->desc_lock));
Can lockdep_is_held() return anything except LOCK_STATE_HELD here? Or is it
checked outside of this scoped_guard()?
> + if (old)
> + call_srcu(&desc->gdev->desc_srcu, &old->rh, desc_free_label);
> + }
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-11-05 14:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 13:23 Bartosz Golaszewski
2026-11-05 14:53 ` Andy Shevchenko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=auyYVmSaLBS--52n@ashevche-desk.local \
--to=andriy.shevchenko@linux.intel.com \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=brgl@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®