From nobody Sun Apr 28 09:33:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1614072484; cv=none; d=zohomail.com; s=zohoarc; b=lITeMHJfQ3YakA2fkavgt6wQXEdLnag4FtKuR+1lDY4mYoW66Z8oNEjlarA+k6J+/Q3acvK2TZiQWynUTLl/ia2X9419b8pDfuMA+A0jiPesn8NBNxhLb8VuFH1yjdoK/Fm5QeYiMiq3NOHaEWd6q0LXszhqv01xyyshHz8UzaA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614072484; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=XEcSqmoWO2KH+v6OgAHswdJ68hd1sfUm3lMSiLKRAUM=; b=RbxLP9dMnHpseUpRF6e/kADpHVfhGJr4it0dcUlmq0/ICK3HjYJH4qHi5rDRnbuYn0NSh/SIUSQRUCUd33zt7TTAPxEfOJyBHCHe7z1E7CSJ54xLyMhlRjgLQFGum/gcW6u/ngJNNbyMeE32wCdZV8NvXVeZ7N3KjlzMCgvO6/I= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1614072483731613.5464929257879; Tue, 23 Feb 2021 01:28:03 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-99-WA8axERZMa-YjI198bhXJg-1; Tue, 23 Feb 2021 04:27:59 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA55180403B; Tue, 23 Feb 2021 09:27:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2754410016F6; Tue, 23 Feb 2021 09:27:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8952857DFA; Tue, 23 Feb 2021 09:27:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11N3hqxr023485 for ; Mon, 22 Feb 2021 22:43:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id E5C73202A439; Tue, 23 Feb 2021 03:43:51 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E13E3202A423 for ; Tue, 23 Feb 2021 03:43:49 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 45B919291A6 for ; Tue, 23 Feb 2021 03:43:49 +0000 (UTC) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-486-Y0Jk6mZ6MeC7LlivjcHrWQ-1; Mon, 22 Feb 2021 22:43:46 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Dl48V541mzMd8J for ; Tue, 23 Feb 2021 11:21:30 +0800 (CST) Received: from localhost (10.174.149.172) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.498.0; Tue, 23 Feb 2021 11:23:21 +0800 X-MC-Unique: WA8axERZMa-YjI198bhXJg-1 X-MC-Unique: Y0Jk6mZ6MeC7LlivjcHrWQ-1 From: Hogan Wang To: Subject: [PATCH python] iothread: fix memory access out of bounds Date: Tue, 23 Feb 2021 11:23:18 +0800 Message-ID: <20210223032318.375-1-hogan.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.149.172] X-CFilter-Loop: Reflected X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 11N3hqxr023485 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Tue, 23 Feb 2021 04:27:49 -0500 Cc: suruifeng@huawei.com, wangxinxin.wang@huawei.com, weidong.huang@huawei.com, hogan.wang@huawei.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: suruifeng When the 'pcpu' is larger then the last 'iothr->cpumap' bits, set the list element to False to avoid out of bounds access 'iothr->cpumap'. Signed-off-by: suruifeng Reviewed-by: Hogan Wang --- libvirt-override.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libvirt-override.c b/libvirt-override.c index 1f55864..b099f51 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -1625,10 +1625,14 @@ libvirt_virDomainGetIOThreadInfo(PyObject *self ATT= RIBUTE_UNUSED, VIR_PY_TUPLE_SET_GOTO(iothrtpl, 1, iothrmap, cleanup); =20 for (pcpu =3D 0; pcpu < cpunum; pcpu++) - VIR_PY_LIST_SET_GOTO(iothrmap, pcpu, - PyBool_FromLong(VIR_CPU_USED(iothr->cpuma= p, - pcpu)), - cleanup); + if (VIR_CPU_MAPLEN(pcpu + 1) > iothr->cpumaplen) { + VIR_PY_LIST_SET_GOTO(iothrmap, pcpu, PyBool_FromLong(0), c= leanup); + } else { + VIR_PY_LIST_SET_GOTO(iothrmap, pcpu, + PyBool_FromLong(VIR_CPU_USED(iothr->c= pumap, + pcpu)), + cleanup); + } } =20 py_retval =3D py_iothrinfo; --=20 2.23.0