From: Kees Cook <kees@kernel.org>
To: Zach Wade <zachwade.k@gmail.com>
Cc: tony.luck@intel.com, gpiccoli@igalia.com,
linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, lixingyang1@qq.com
Subject: Re: [PATCH] pstore: Fix uaf when backend is unregistered
Date: Tue, 8 Oct 2024 10:23:20 -0700 [thread overview]
Message-ID: <202410081019.0E9DE76A@keescook> (raw)
In-Reply-To: <2bf30957-ad04-473a-a72e-8baab648fb56@gmail.com>
On Wed, Oct 09, 2024 at 01:10:14AM +0800, Zach Wade wrote:
> when unload pstore_blk, we will unlink the pstore file and
> set pos->dentry to NULL, but simple_unlink(d_inode(root), pos->dentry)
> may free inode of pos->dentry and free pos by free_pstore_private,
> this may trigger uaf. kasan report:
Thanks for this! I need to double check what happening here a bit more
closely, as maybe some ordering changed after a43e0fc5e913 ("pstore:
inode: Only d_invalidate() is needed")
> @@ -316,9 +316,10 @@ int pstore_put_backend_records(struct pstore_info *psi)
> list_for_each_entry_safe(pos, tmp, &records_list, list) {
> if (pos->record->psi == psi) {
> list_del_init(&pos->list);
> - d_invalidate(pos->dentry);
> - simple_unlink(d_inode(root), pos->dentry);
> + unlink_dentry = pos->dentry;
> pos->dentry = NULL;
> + d_invalidate(unlink_dentry);
> + simple_unlink(d_inode(root), unlink_dentry);
But on the face of it, this does solve the UAF. I'll double-check that
this isn't a result of the mentioned commit.
-Kees
--
Kees Cook
next prev parent reply other threads:[~2024-10-08 17:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-08 17:10 [PATCH] pstore: Fix uaf when backend is unregistered Zach Wade
2024-10-08 17:11 ` kernel test robot
2024-10-08 17:23 ` Kees Cook [this message]
2024-10-09 13:36 ` Zach Wade
2024-10-15 14:45 ` Zach Wade
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=202410081019.0E9DE76A@keescook \
--to=kees@kernel.org \
--cc=gpiccoli@igalia.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lixingyang1@qq.com \
--cc=stable@vger.kernel.org \
--cc=tony.luck@intel.com \
--cc=zachwade.k@gmail.com \
/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