mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mikulas Patocka <mpatocka@redhat.com>
To: Hou Tao <houtao1@huawei.com>
Cc: Li Lingfeng <lilingfeng3@huawei.com>,
	dm-devel@lists.linux.dev,  agk@redhat.com, snitzer@kernel.org,
	tusharsu@linux.microsoft.com,  colin.i.king@gmail.com,
	linux-kernel@vger.kernel.org, yi.zhang@huawei.com,
	 yangerkun@huawei.com, yukuai3@huawei.com,
	chengzhihao1@huawei.com,  lilingfeng@huaweicloud.com
Subject: Re: [PATCH] dm: introduce spinlocks to prevent concurrent usage and release of device_metadata and hash
Date: Thu, 17 Jul 2025 20:45:00 +0200 (CEST)	[thread overview]
Message-ID: <5be1fab4-192d-8327-b541-bb92d53313cc@redhat.com> (raw)
In-Reply-To: <5a29db22-13a9-f3ea-dbf2-13ce7f7aa649@huawei.com>



On Thu, 17 Jul 2025, Hou Tao wrote:

> Hi,
> 
> On 7/17/2025 10:07 PM, Li Lingfeng wrote:
> > There is a window between freeing md->ima.active_table.hash and setting
> > md->ima.active_table.hash to NULL in dm_ima_measure_on_device_resume().
> > If dm_ima_measure_on_device_remove() accesses md->ima.active_table.hash
> > concurrently during this window, it could lead to a double free or UAF,
> > as shown below:
> 
> The UAF is a problem. However, I think the order of
> dm_ima_measure_on_device_remove() and dm_ima_measure_on_device_resume is
> bigger problem. Is it possible to order these two invocations properly
> by using suspend_lock ?

That's a good point. The patch just papers over the problem. It will fix 
the UAF warning, but it won't fix the fact that 
dm_ima_measure_on_device_resume can race with 
dm_ima_measure_on_device_remove.

The real fix would be to make sure that dm_ima_measure_* calls are never 
called concurrently on the same table - we should use existing device 
mapper locks for that.

Mikukas


  reply	other threads:[~2025-07-17 18:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-17 14:07 Li Lingfeng
2025-07-17  9:43 ` Hou Tao
2025-07-17 18:45   ` Mikulas Patocka [this message]
2025-07-18  1:28     ` Li Lingfeng

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=5be1fab4-192d-8327-b541-bb92d53313cc@redhat.com \
    --to=mpatocka@redhat.com \
    --cc=agk@redhat.com \
    --cc=chengzhihao1@huawei.com \
    --cc=colin.i.king@gmail.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=houtao1@huawei.com \
    --cc=lilingfeng3@huawei.com \
    --cc=lilingfeng@huaweicloud.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=snitzer@kernel.org \
    --cc=tusharsu@linux.microsoft.com \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.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

all inboxes | Powered by JetHome®