Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4468573ybc; Tue, 26 Nov 2019 09:23:14 -0800 (PST) X-Google-Smtp-Source: APXvYqy6/KfSsLW/a1IofgUG6+Ni337Zet105SdgNjSe+eTbjCnNd92XHl5hBzzryZHkCJQoUUPc X-Received: by 2002:a17:907:43ef:: with SMTP id ol23mr26409379ejb.264.1574788993856; Tue, 26 Nov 2019 09:23:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574788993; cv=none; d=google.com; s=arc-20160816; b=PCKBTZ89jDnHdsNjLxFxYQX4YGBXHZ/OMqSwx6bfy5+GjiwE7scgPrLKz4w0IAxVvs Yb6hbaK9mafb3APT1ihUl5A4XHGxOcuxxfNR+3Zvb/FpkUTEv29QedvQR50cvSc86ol0 YSx9s/+eThvpGd6MiWsCB7slvOYTWL32PXC3y4oauua0IWobFFnkTH1ouNPB5Md56CcW cLMff6qrDRPDyzKI2fzUMSPLSxs8cxaM9PRw4yeuMpnxPZFXJK+GmNfL6JgbO/UIbPdb 5ECKC8W98E0wz/ExCLNdom62Y5dNkbd+zue60d5VI/W0JwCHsI3UhQH5A2a6vfOLiCPf HAxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:in-reply-to:mime-version:references :mail-followup-to:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=zZMwHV3KrQEfrY5tMKLf1OtDElvXlEV64ghBrb4GlKA=; b=SlkpLpDQUpEzJaPpJl2O7qiPo/hsUEJcNs861P+IuP0F/3ylCQIl7kRzv3hVnYGmJT fN+9RsJeCX0gyHTzdVsS7KZYptNZtOSv6otUl8n5TqFt0ztYl6c4hoqijeZtTGEy0YB9 oPsF3u8isP33KiZURjGOhPkaBNxP0z+hWC5cWtyJWVd1ydE2ykI430nNLy4gcRrNSM+j yXRWXp6gHYTX0BZxxGARZ6CG76l7DBZi8uk2UP0TlDYQbun3ovKqEZBpRraffNwwgP/C LM1zw7ri8dkW8z/KQveXLwtAbRjgkv9TwE/B8CBCD8tQuL1RlUFBLSg5VInKaUVCpO5K n0ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=C6fAN8jt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rs25si7852944ejb.85.2019.11.26.09.22.46; Tue, 26 Nov 2019 09:23:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=C6fAN8jt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728648AbfKZRTK (ORCPT + 99 others); Tue, 26 Nov 2019 12:19:10 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:41796 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728114AbfKZRTK (ORCPT ); Tue, 26 Nov 2019 12:19:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574788748; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zZMwHV3KrQEfrY5tMKLf1OtDElvXlEV64ghBrb4GlKA=; b=C6fAN8jtU+Id4em/X5JRjeqSrpd7/3cVOI/m1uC7yaaLcamJjZKk47I7HUult5eaMZi2jr ef7LYXBp2e2spq2k/5xxvVdk8xCuI/ylU/74F9UjPHjvvM0buTUpg8sPYZc1byc2dDmPW/ zDegyFM9sWq0/nMHFlCWYBm4QuzWXE4= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-196-csp62IwZO962c6CjeTcu-w-1; Tue, 26 Nov 2019 12:19:07 -0500 Received: by mail-pj1-f70.google.com with SMTP id u17so9538111pjy.7 for ; Tue, 26 Nov 2019 09:19:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:reply-to :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=5wVzpglEIAjYehdG9sWNgS3uaz+PIjpeWL9/GEH0Tp4=; b=XWed2B24GyM+HZ3xGStGxN4gk6PDSsGUIe3CG3qHK+0sgAcGRlyKOtIKeQYzaOcWFW RmvhT37YnKdIoIUAMj4VblxY5qWibYoHv1votCpoH7fwpIbqP+zzdmdFao5aDNpkX+uT de6AwxVgACZE12NwrnjB5CT8D5i5DSZE5dyH4XWDLN0Y8p37Peq69Fkh6vQ2JO3WwZn3 NeTn7bp9EGpf4nn44ekBTxj4C669bnMOTw2mQaLh9ffAxvO6vWeUI81UgR7ZwstEEPu6 unwA/3kctqhLaF2axVHzTHbYX9ZSrg8JwuUFN8JlNfITA654a4Z5p43nQ6ei+HpYiFMx +p0g== X-Gm-Message-State: APjAAAWk92/GMfR+UPDjfe0m7BGAtEWY41ctCEKC4CRDmTyq/0wS3IEQ bzxQU7A2iBBcJKs/t45RUilfTSHmNc4jcL43v9zP2ochF0L2p4BYAQlLdizl22D1nXTtsaHhNn8 w71rvnQDYrnbk4WXH/0RGbxJ9 X-Received: by 2002:aa7:8edd:: with SMTP id b29mr42634010pfr.23.1574788746765; Tue, 26 Nov 2019 09:19:06 -0800 (PST) X-Received: by 2002:aa7:8edd:: with SMTP id b29mr42633987pfr.23.1574788746524; Tue, 26 Nov 2019 09:19:06 -0800 (PST) Received: from localhost (ip70-163-223-149.ph.ph.cox.net. [70.163.223.149]) by smtp.gmail.com with ESMTPSA id g30sm12879606pgm.23.2019.11.26.09.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2019 09:19:05 -0800 (PST) Date: Tue, 26 Nov 2019 10:19:04 -0700 From: Jerry Snitselaar To: Eric Auger Cc: eric.auger.pro@gmail.com, joro@8bytes.org, hch@lst.de, cai@lca.pw, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] iommu: fix KASAN use-after-free in iommu_insert_resv_region Message-ID: <20191126171904.tnd27x3mjhdo4dy7@cantor> Reply-To: Jerry Snitselaar Mail-Followup-To: Eric Auger , eric.auger.pro@gmail.com, joro@8bytes.org, hch@lst.de, cai@lca.pw, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org References: <20191126102743.3269-1-eric.auger@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191126102743.3269-1-eric.auger@redhat.com> X-MC-Unique: csp62IwZO962c6CjeTcu-w-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue Nov 26 19, Eric Auger 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 >Reported-by: Qian Cai >Cc: Stable #v5.3+ > Minor nit, but should the comment above list_for_each_entry_safe get updated as well? Other than that, lgtm. Reviewed-by: Jerry Snitselaar >--- > >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, > =09=09phys_addr_t top_end, iter_end =3D iter->start + iter->length - 1; > > =09=09/* no merge needed on elements of different types than @nr */ >-=09=09if (iter->type !=3D nr->type) { >+=09=09if (iter->type !=3D new->type) { > =09=09=09list_move_tail(&iter->list, &stack); > =09=09=09continue; > =09=09} >--=20 >2.20.1 > >_______________________________________________ >iommu mailing list >iommu@lists.linux-foundation.org >https://lists.linuxfoundation.org/mailman/listinfo/iommu >