BPF List
 help / color / mirror / Atom feed
From: Mauricio Faria de Oliveira <mfo@igalia.com>
To: sashiko-reviews@lists.linux.dev
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	bpf@vger.kernel.org, mptcp@lists.linux.dev,
	Vasily Gorbik <gor@linux.ibm.com>,
	linux-s390@vger.kernel.org, Heiko Carstens <hca@linux.ibm.com>
Subject: Re: [PATCH RFC v2 05/13] sysctl, parport: update register_sysctl() callers with template arguments
Date: Wed, 19 Aug 2026 13:25:24 -0300	[thread overview]
Message-ID: <dcc4fc5f41793bdf4133891d566b4b98@igalia.com> (raw)
In-Reply-To: <20260819024411.C41E61F000E9@smtp.kernel.org>

On 2026-08-18 23:44, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> 
> Pre-existing issues:
> - [High] Lockless traversal of the `port->devices` list can lead to a use-after-free if a device is concurrently unregistered.
> --

Pre-existing and apparently acknowledged, per details below.

> 
> --- Patch [5]: [PATCH RFC v2 05/13] sysctl, parport: update register_sysctl() callers with template arguments ---
> commit 511c6de215c54187a5a0e65c0208aa20775855cf
> Author: Mauricio Faria de Oliveira <mfo@igalia.com>
> 
> sysctl, parport: update register_sysctl() callers with template arguments
> 
> Update callers with dynamic table/path to use template arguments.
> 
>> diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
>> index cda3221e386ed..7c048e9a973aa 100644
>> --- a/drivers/parport/procfs.c
>> +++ b/drivers/parport/procfs.c
> 
> [ ... ]
> 
> [Severity: High]
> This isn't a bug introduced by this patch, but could reading the active
> device sysctl lead to a use-after-free if a device is concurrently
> unregistered?
> 
> In drivers/parport/procfs.c:do_active_device(), the port->devices list is
> traversed locklessly:
> 
>     for (dev = port->devices; dev ; dev = dev->next) {
> 
> Concurrently, parport_unregister_device() in drivers/parport/share.c can
> remove a device from this list and free it:
> 
>     device_unregister(&dev->dev);
> 
> Since there is no synchronization (like taking port->pardevice_lock)
> between the sysctl read and device removal, couldn't the lockless traversal
> dereference a freed pardevice pointer?
> 
> This missing locking is also explicitly annotated in another lockless
> traversal in drivers/parport/share.c:parport_release():
> 
>     /* !!! LOCKING IS NEEDED HERE */
>     for (pd = port->devices; !port->cad && pd; pd = pd->next) {
> 
> Could an unprivileged user trigger this by repeatedly reading the sysctl
> while a device is unregistered?

-- 
Mauricio

  reply	other threads:[~2026-08-19 16:25 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-19  2:27 [PATCH RFC v2 00/13] sysctl: add module aliases Mauricio Faria de Oliveira
2026-08-19  2:28 ` [PATCH RFC v2 01/13] keys, pidns, fs/verity, riscv/vector: reorder '#include <linux/sysctl.h>' Mauricio Faria de Oliveira
2026-08-19  2:33   ` sashiko-bot
2026-08-19  2:28 ` [PATCH RFC v2 02/13] proc: add config option SYSCTL_MODULE_ALIASES Mauricio Faria de Oliveira
2026-08-19  2:37   ` sashiko-bot
2026-08-19 16:24     ` Mauricio Faria de Oliveira
2026-08-19  2:28 ` [PATCH RFC v2 03/13] sysctl, mod_devicetable: add macro MODULE_SYSCTL_TABLE Mauricio Faria de Oliveira
2026-08-19  2:40   ` sashiko-bot
2026-08-19 16:26     ` Mauricio Faria de Oliveira
2026-08-19  2:28 ` [PATCH RFC v2 04/13] sysctl: add register_sysctl() wrapper for MODULE_SYSCTL_TABLE Mauricio Faria de Oliveira
2026-08-19  2:44   ` sashiko-bot
2026-08-19 16:25     ` Mauricio Faria de Oliveira
2026-08-19  2:28 ` [PATCH RFC v2 05/13] sysctl, parport: update register_sysctl() callers with template arguments Mauricio Faria de Oliveira
2026-08-19  2:44   ` sashiko-bot
2026-08-19 16:25     ` Mauricio Faria de Oliveira [this message]
2026-08-19  2:28 ` [PATCH RFC v2 06/13] sysctl, net: add register_net_sysctl{_sz}() wrappers for MODULE_SYSCTL_TABLE Mauricio Faria de Oliveira
2026-08-19  2:40   ` sashiko-bot
2026-08-19 16:25     ` Mauricio Faria de Oliveira
2026-08-19  2:28 ` [PATCH RFC v2 07/13] sysctl, net: update register_net_sysctl{_sz}() callers with template arguments Mauricio Faria de Oliveira
2026-08-19  2:48   ` sashiko-bot
2026-08-19 16:25     ` Mauricio Faria de Oliveira
2026-08-19  2:28 ` [PATCH RFC v2 08/13] sysctl, net: update register_net_sysctl_sz(ARRAY_SIZE(table_tmpl)) " Mauricio Faria de Oliveira
2026-08-19  2:36   ` sashiko-bot
2026-08-19  2:28 ` [PATCH RFC v2 09/13] sysctl, ipv6: update register_net_sysctl{_sz}() callers " Mauricio Faria de Oliveira
2026-08-19  2:36   ` sashiko-bot
2026-08-19  2:28 ` [PATCH RFC v2 10/13] sysctl, net: update register_net_sysctl_sz() edge case Mauricio Faria de Oliveira
2026-08-19  2:39   ` sashiko-bot
2026-08-19  2:28 ` [PATCH RFC v2 11/13] sysctl: unrandomize struct ctl_table.procname Mauricio Faria de Oliveira
2026-08-19  2:38   ` sashiko-bot
2026-08-19  2:28 ` [PATCH RFC v2 12/13] modpost: move addend_*_rel() calls into addend_rel() Mauricio Faria de Oliveira
2026-08-19  2:39   ` sashiko-bot
2026-08-19  2:28 ` [PATCH RFC v2 13/13] modpost: handle MODULE_SYSCTL_TABLE symbols Mauricio Faria de Oliveira
2026-08-19  2:48   ` sashiko-bot
2026-08-19 16:29     ` Mauricio Faria de Oliveira

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=dcc4fc5f41793bdf4133891d566b4b98@igalia.com \
    --to=mfo@igalia.com \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=bpf@vger.kernel.org \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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