From nobody Thu Mar 28 11:19:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555339401; cv=none; d=zoho.com; s=zohoarc; b=GZSbsOrsK6/PYbyDiGzcfAIn/RUE2nxdtJwPTmW+ndreDFJi3ljofu+JRPVpXU6GXeZsDuxid1xMsfZcH9JFEwi+g8vgPVzgE6+AUvmoLmn3W42CkE/TTf591Y0p14Z6Javcn6zA1c/+V/0nRHepRCyXzg0cngU35VhMQ4NMXck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555339401; 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:ARC-Authentication-Results; bh=JJlmWpltdFkwEHvU1a8ahilrrZSHVopkxBzzpUsXwwQ=; b=ehfuJIo4x4DpIA0oIcse1ABYZLuKs4VvE6IqCbXV6KdslN4Lmdq9j22APd7T1YvvL3RKyxqOI2/ENfh7WmSwYUZ7yAgrML12kYS8Z3i/ggPg9v5uuNdatjR4VUP1dcavl2hLCzcQDG3IURew6AaXmHHnyUrfCWyF8YvsV+7yZwA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1555339401203734.7089830407681; Mon, 15 Apr 2019 07:43:21 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 884AC4E93D; Mon, 15 Apr 2019 14:43:18 +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 D8C031001DDD; Mon, 15 Apr 2019 14:43:17 +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 C85593FA46; Mon, 15 Apr 2019 14:43:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x3FEhE6s019696 for ; Mon, 15 Apr 2019 10:43:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id C83A960C4E; Mon, 15 Apr 2019 14:43:14 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9000C61082; Mon, 15 Apr 2019 14:43:12 +0000 (UTC) Received: from NAM04-CO1-obe.outbound.protection.outlook.com (mail-eopbgr690049.outbound.protection.outlook.com [40.107.69.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 816B73086212; Mon, 15 Apr 2019 14:43:10 +0000 (UTC) Received: from DM6PR12MB2795.namprd12.prod.outlook.com (20.176.118.96) by DM6PR12MB2809.namprd12.prod.outlook.com (20.176.117.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1792.19; Mon, 15 Apr 2019 14:43:07 +0000 Received: from DM6PR12MB2795.namprd12.prod.outlook.com ([fe80::c08c:8568:fc0b:b4b4]) by DM6PR12MB2795.namprd12.prod.outlook.com ([fe80::c08c:8568:fc0b:b4b4%3]) with mapi id 15.20.1792.018; Mon, 15 Apr 2019 14:43:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zEBb0dd+EkCMNNee4yXl4GmP2Y+5xNLWGTXwAv5Ey1Q=; b=isO68Eox6ZeFF1Wn3c64815hjl0fVy7StAgQX/j5hwFjecxT4OKrX0agvp6fEtzFtzHAS/j66DVieRzIDqr2eYaEJg/CaLoxLXE36SCa4hBVqcEpRSxBWApwjdhuYpEze99ZjbSPQQhY6QEz66w8TtIpAptiBeoely/LW97F6ho= From: "Allen, John" To: "libvir-list@redhat.com" Thread-Topic: [libvirt] [PATCH] Handle copying bitmaps to larger data buffers Thread-Index: AQHU85mK0Xav/HVSokur1gs+fNd3yA== Date: Mon, 15 Apr 2019 14:43:07 +0000 Message-ID: <20190415144245.26992-1-john.allen@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN6PR04CA0075.namprd04.prod.outlook.com (2603:10b6:805:f2::16) To DM6PR12MB2795.namprd12.prod.outlook.com (2603:10b6:5:41::32) authentication-results: spf=none (sender IP is ) smtp.mailfrom=John.Allen@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.77.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: c9e9b4e9-28b8-43c4-15fc-08d6c1b0ac60 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600140)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:DM6PR12MB2809; x-ms-traffictypediagnostic: DM6PR12MB2809: x-microsoft-antispam-prvs: x-forefront-prvs: 000800954F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(39860400002)(376002)(366004)(136003)(346002)(199004)(189003)(6436002)(53936002)(50226002)(97736004)(106356001)(105586002)(478600001)(7736002)(2501003)(6916009)(316002)(1076003)(6486002)(8936002)(66066001)(72206003)(305945005)(2906002)(71200400001)(3846002)(81156014)(6116002)(71190400001)(81166006)(54906003)(8676002)(6512007)(14454004)(4326008)(486006)(102836004)(5640700003)(386003)(6506007)(450100002)(476003)(25786009)(36756003)(68736007)(86362001)(26005)(5660300002)(256004)(52116002)(186003)(2616005)(99286004)(2351001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB2809; H:DM6PR12MB2795.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: teh/PtJPk6BukdC+J6Pr/V0xUXZN7s2hT3ezNgV22e6mfOerxMKEUl5Q1L3Rylt7DrR0OqrcPYbyIIBNJc+49wmEU/I3srwvwkS+6S5HMeNOfApkLlF5yQ6p25B/NcpVXrVQtA87LLDg0+zq5T7qGoY7z6eAlR1oFMM1GWHZ5jwe5noJv/Zx5EvuyeqTUxp9Voh6mBf3xCEQd855DdP9vy1SHkAsndfzl12VPKkOEGPOtJonpG2W4jRPmYxUlciP1ZVMkaHHbMu8FyjZ/HNvb5hQKVnwFxKdj4OMt1sS/2I1CwOSwwo/YGLLH0YV8vfcMWuqBUkHXtshMqo1AQB7PZufHAvsmkDFH6EvajSbxAkGFw7FF8773w8eWY/rKQ1AeSzSUx0KXenSyyvJNTLWw2OQ/hdqiz+KqUNVpiucakc= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: c9e9b4e9-28b8-43c4-15fc-08d6c1b0ac60 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Apr 2019 14:43:07.2458 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2809 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 15 Apr 2019 14:43:11 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 15 Apr 2019 14:43:11 +0000 (UTC) for IP:'40.107.69.49' DOMAIN:'mail-eopbgr690049.outbound.protection.outlook.com' HELO:'NAM04-CO1-obe.outbound.protection.outlook.com' FROM:'John.Allen@amd.com' RCPT:'' X-RedHat-Spam-Score: -0.011 (DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS) 40.107.69.49 mail-eopbgr690049.outbound.protection.outlook.com 40.107.69.49 mail-eopbgr690049.outbound.protection.outlook.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MIME-Autoconverted: from base64 to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id x3FEhE6s019696 X-loop: libvir-list@redhat.com Cc: "Allen, John" , "Singh, Brijesh" , "jtomko@redhat.com" Subject: [libvirt] [PATCH] Handle copying bitmaps to larger data buffers 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 15 Apr 2019 14:43:19 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" If a bitmap of a shorter length than the data buffer is passed to virBitmapToDataBuf, it will read off the end of the bitmap and copy junk into the returned buffer. Add a check to only copy the length of the bitmap to the buffer. The problem can be observed after setting a vcpu affinity using the vcpupin command on a system with a large number of cores: # virsh vcpupin example_domain 0 0 # virsh vcpupin example_domain 0 VCPU CPU Affinity --------------------------- 0 0,192,197-198,202 Signed-off-by: John Allen --- diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index d074f29e54..021174cbb3 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -824,11 +824,15 @@ virBitmapToDataBuf(virBitmapPtr bitmap, unsigned char *bytes, size_t len) { + size_t nbytes =3D bitmap->map_len * (VIR_BITMAP_BITS_PER_UNIT / CHAR_B= IT); unsigned long *l; size_t i, j; =20 memset(bytes, 0, len); =20 + /* If bitmap and buffer differ in size, only fill to the smaller lengt= h */ + len =3D MIN(len, nbytes); + /* htole64 is not provided by gnulib, so we do the conversion by hand = */ l =3D bitmap->map; for (i =3D j =3D 0; i < len; i++, j++) { -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list