From: Greg KH <gregkh@linuxfoundation.org>
To: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
Cc: rafael@kernel.org, dakr@kernel.org, driver-core@lists.linux.dev,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] debugfs: fix UAF and double-free in debugfs_str read/write
Date: Sat, 26 Sep 2026 08:53:06 +0200 [thread overview]
Message-ID: <2026092647-ebony-unlatch-d3d0@gregkh> (raw)
In-Reply-To: <20260925175831.3701812-1-qwe.aldo@gmail.com>
On Fri, Sep 25, 2026 at 02:58:27PM -0300, Aldo Ariel Panzardo wrote:
> debugfs_write_file_str() stores the new string via rcu_assign_pointer()
> and frees the old one after synchronize_rcu(). However,
> debugfs_read_file_str() dereferences file->private_data without holding
> an RCU read-side critical section, so synchronize_rcu() in a concurrent
> writer can return—and kfree() the old pointer—before the reader finishes
> using it (use-after-free).
>
> Additionally, two concurrent writers both read the same `old` pointer
> before either calls rcu_assign_pointer(). When both subsequently call
> kfree(old) a double-free results.
>
> Fix both issues:
>
> - Read path: wrap the pointer dereference and string copy inside
> rcu_read_lock()/rcu_read_unlock(), using rcu_dereference() and
> GFP_ATOMIC to keep the allocation within the critical section.
>
> - Write path: serialize concurrent writers with inode_lock(), and use
> rcu_dereference_protected() to read `old` under the held lock. The
> lock is released before synchronize_rcu()+kfree() so readers are not
> blocked during the grace period.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
Did you forget an Assisted-by: tag here?
And how was this found and tested?
And what kernel was tested, debugfs strings were changed a bunch in 7.1,
what bug report are you working off of here?
and shouldn't this be multiple patches as you are doing two different
things?
thanks,
greg k-h
next prev parent reply other threads:[~2026-09-26 6:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 17:58 [PATCH] debugfs: fix UAF and double-free in debugfs_str read/write Aldo Ariel Panzardo
2026-09-26 6:53 ` Greg KH [this message]
2026-09-26 13:47 ` [PATCH v2 0/2] " Aldo Ariel Panzardo
2026-09-27 16:34 ` Greg KH
2026-09-27 20:29 ` Aldo Ariel Panzardo
2026-09-26 13:47 ` [PATCH v2 1/2] debugfs: fix use-after-free in debugfs_read_file_str() Aldo Ariel Panzardo
2026-09-26 13:48 ` [PATCH v2 2/2] debugfs: serialize concurrent writers in debugfs_write_file_str() Aldo Ariel Panzardo
2026-09-26 14:09 ` [PATCH v3 0/2] debugfs: fix UAF and double-free in debugfs_str read/write Aldo Ariel Panzardo
2026-09-26 14:09 ` [PATCH v3 1/2] debugfs: fix use-after-free in debugfs_read_file_str() Aldo Ariel Panzardo
2026-09-26 15:53 ` Danilo Krummrich
2026-09-26 14:09 ` [PATCH v3 2/2] debugfs: serialize concurrent writers in debugfs_write_file_str() Aldo Ariel Panzardo
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=2026092647-ebony-unlatch-d3d0@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=qwe.aldo@gmail.com \
--cc=rafael@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.