iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Auger Eric <eric.auger@redhat.com>
To: Qian Cai <cai@lca.pw>, Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, hch@lst.de,
	iommu@lists.linux-foundation.org, eric.auger.pro@gmail.com
Subject: Re: [PATCH v3] iommu: fix KASAN use-after-free in iommu_insert_resv_region
Date: Mon, 16 Dec 2019 15:35:53 +0100	[thread overview]
Message-ID: <80da76c4-395a-18cc-1ffa-c3a0471921b0@redhat.com> (raw)
In-Reply-To: <0DE725CD-01CD-4E01-B817-9CC7F4768FBC@lca.pw>

Hi,
On 12/16/19 3:24 PM, Qian Cai wrote:
> 
> 
>> On Nov 26, 2019, at 5:27 AM, Eric Auger <eric.auger@redhat.com> wrote:
>>
>> In case the new region gets merged into another one, the nr
>> list node is freed. Checking its type while completing the
>> merge algorithm leads to a use-after-free. Use new->type
>> instead.
>>
>> Fixes: 4dbd258ff63e ("iommu: Revisit iommu_insert_resv_region()
>> implementation")
>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>> Reported-by: Qian Cai <cai@lca.pw>
>> Cc: Stable <stable@vger.kernel.org> #v5.3+
> 
> 
> Looks like Joerg is away for a few weeks. Could Andrew or Linus pick up this 
> use-after-free?
Thanks for the heads up. Indeed I was wondering why it hasn't been taken
yet.

Note the right version to pick up is the v4, reviewed by Jerry:
https://www.mail-archive.com/iommu@lists.linux-foundation.org/msg36226.html

Thanks

Eric
> 
>>
>> ---
>>
>> v2 -> v3:
>> - directly use new->type
>>
>> v1 -> v2:
>> - remove spurious new line
>> ---
>> drivers/iommu/iommu.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
>> index d658c7c6a2ab..285ad4a4c7f2 100644
>> --- a/drivers/iommu/iommu.c
>> +++ b/drivers/iommu/iommu.c
>> @@ -313,7 +313,7 @@ int iommu_insert_resv_region(struct iommu_resv_region *new,
>> 		phys_addr_t top_end, iter_end = iter->start + iter->length - 1;
>>
>> 		/* no merge needed on elements of different types than @nr */
>> -		if (iter->type != nr->type) {
>> +		if (iter->type != new->type) {
>> 			list_move_tail(&iter->list, &stack);
>> 			continue;
>> 		}
>> -- 
>> 2.20.1
>>
> 

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply	other threads:[~2019-12-16 14:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-26 10:27 [PATCH v3] iommu: fix KASAN use-after-free in iommu_insert_resv_region Eric Auger
2019-11-26 17:19 ` Jerry Snitselaar
2019-12-16 14:24 ` Qian Cai
2019-12-16 14:35   ` Auger Eric [this message]
2019-12-16 17:03     ` Linus Torvalds

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=80da76c4-395a-18cc-1ffa-c3a0471921b0@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=cai@lca.pw \
    --cc=eric.auger.pro@gmail.com \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).