All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zach Wade <zachwade.k@gmail.com>
To: Kees Cook <kees@kernel.org>
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, 15 Oct 2024 22:45:34 +0800	[thread overview]
Message-ID: <b7b9fba3-819a-411f-9e67-d5eec9e63eaa@gmail.com> (raw)
In-Reply-To: <6077c924-f975-49a0-8ee4-4e481664ac38@gmail.com>



On 2024/10/9 21:36, Zach Wade wrote:
> 
> 
> On 2024/10/9 1:23, Kees Cook wrote:
>> 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.
> 
> Hi Cook,
> 
> However, I think a more appropriate solution to the problem here is to
> check the reference count when uninstalling the mount point.
> 
> At the same time, the test script is attached:
> #!/bin/bash
> modprobe pstore_blk
> blkdev=/dev/sda2
> best_effort=on
> mount -t pstore pstore /sys/fs/pstore
> sleep 2
> umount /sys/fs/pstore
> modprobe -r pstore_blk
> 
> Thanks,
> Zach
> 
>>
> 
>> -Kees
>>
> 

friendly ping.

Hi Cook,

How are you doing? I really hope we can solve this problem.

Thanks,
Zach

  reply	other threads:[~2024-10-15 14:45 UTC|newest]

Thread overview: 8+ 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
2024-10-09 13:36   ` Zach Wade
2024-10-15 14:45     ` Zach Wade [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-09-29 12:43 Li XingYang
2024-09-29 12:47 ` Li XingYang
2024-09-30 13:12 ` Greg KH

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=b7b9fba3-819a-411f-9e67-d5eec9e63eaa@gmail.com \
    --to=zachwade.k@gmail.com \
    --cc=gpiccoli@igalia.com \
    --cc=kees@kernel.org \
    --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 \
    /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.