[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202410081019.0E9DE76A@keescook>
Date: Tue, 8 Oct 2024 10:23:20 -0700
From: Kees Cook <kees@...nel.org>
To: Zach Wade <zachwade.k@...il.com>
Cc: tony.luck@...el.com, gpiccoli@...lia.com,
linux-hardening@...r.kernel.org, linux-kernel@...r.kernel.org,
stable@...r.kernel.org, lixingyang1@...com
Subject: Re: [PATCH] pstore: Fix uaf when backend is unregistered
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
Powered by blists - more mailing lists