From nobody Fri May 3 22:40:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1578417761; cv=none; d=zohomail.com; s=zohoarc; b=m+SSw50D5xQPrwF2nA+J/4banULHbOmr0ufJxBGlugbDWRAIw4DlqI0BN0QV/SqAli/mii05CPmbFQpzeBEBpsvSkuuJ3uJ1tnGLA7jbz3i/vQkMNwgDm/71qy1ziQdbdGzDH+AJgk3hZEX0ktmYKktn16bNBHlTrhlfWwTaXIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578417761; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=M+XwVTNVKD/n2yyyBB6mdK1L75RDwEr4h1tU7JMf7I4=; b=hIOrJI/6xu+2B25WJR3AbP2K5YSX0Pucg40KbPZZJrCemtX7T1nDa76Gx3gRMHNxxOhQhsqOb1aBOP1VzkqVkGvvF3wIL0cViHXPq3gHnm0xHg+Z4wXNCDda21PfohvFsxHgokXrHd9j0ovBsxaFjuyHGrMRIcoPwyeXy9pfZKA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157841776189422.85027455064335; Tue, 7 Jan 2020 09:22:41 -0800 (PST) Received: from localhost ([::1]:53870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iosYy-0000MO-OK for importer@patchew.org; Tue, 07 Jan 2020 12:22:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52879) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iosUr-0002ae-MV for qemu-devel@nongnu.org; Tue, 07 Jan 2020 12:18:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iosUq-0006Wn-H3 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 12:18:25 -0500 Received: from 9.mo179.mail-out.ovh.net ([46.105.76.148]:37961) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iosUq-0006UU-2I for qemu-devel@nongnu.org; Tue, 07 Jan 2020 12:18:24 -0500 Received: from player798.ha.ovh.net (unknown [10.108.1.15]) by mo179.mail-out.ovh.net (Postfix) with ESMTP id 5290F15343B for ; Tue, 7 Jan 2020 18:18:21 +0100 (CET) Received: from kaod.org (lfbn-tou-1-1227-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player798.ha.ovh.net (Postfix) with ESMTPSA id 62253E1076CB; Tue, 7 Jan 2020 17:18:16 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH 1/2] ppc/pnv: check return value of blk_pwrite() Date: Tue, 7 Jan 2020 18:18:08 +0100 Message-Id: <20200107171809.15556-2-clg@kaod.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200107171809.15556-1-clg@kaod.org> References: <20200107171809.15556-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 13645062448371633126 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrvdehhedgtdeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrhejleekrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedt Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.76.148 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" When updating the PNOR file contents, we should check for a possible failure of blk_pwrite(). Fixes Coverity issue CID 1412228. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Greg Kurz Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/pnv_pnor.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/ppc/pnv_pnor.c b/hw/ppc/pnv_pnor.c index bfb1e92b0392..0e86ae2feae6 100644 --- a/hw/ppc/pnv_pnor.c +++ b/hw/ppc/pnv_pnor.c @@ -33,6 +33,7 @@ static uint64_t pnv_pnor_read(void *opaque, hwaddr addr, = unsigned size) static void pnv_pnor_update(PnvPnor *s, int offset, int size) { int offset_end; + int ret; =20 if (s->blk) { return; @@ -42,8 +43,11 @@ static void pnv_pnor_update(PnvPnor *s, int offset, int = size) offset =3D QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE); offset_end =3D QEMU_ALIGN_UP(offset_end, BDRV_SECTOR_SIZE); =20 - blk_pwrite(s->blk, offset, s->storage + offset, - offset_end - offset, 0); + ret =3D blk_pwrite(s->blk, offset, s->storage + offset, + offset_end - offset, 0); + if (ret < 0) { + error_report("Could not update PNOR: %s", strerror(-ret)); + } } =20 static void pnv_pnor_write(void *opaque, hwaddr addr, uint64_t data, --=20 2.21.1 From nobody Fri May 3 22:40:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1578417609; cv=none; d=zohomail.com; s=zohoarc; b=EEN5vTCbmbczSS7RnaQxykzRkhjQDwLfhfLvcJ8yEBHAVjlNQ1Iuy4IoHUpY/HLcn5E8JxVj2jl50Ej3pn6G3XHnRFb4/gJyQLa1y4E9rlBa6xWQ5kSxNoVOgfTjGLsF4symhEwUsnxD2yuiBgmxArCP7ESXx3Y+t4eKvEHUi9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578417609; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OO/ctQUTZA+X04K8oqyeE3+tiqgaZcBi4UlQ3yL4jFA=; b=NLejOr9V6a4PfoZOHQ5SOl5A7hqMx0i9MJGnKMq5Ggl/Ghu/t27gqsh4YDXkxNnXKi+eg4EXDE3yNc7mVeCz3fC6zbidq9Zm+6mluWV3qWdf5TqgVjJoycAlzPnTp4jlBLIMYqTPBCAN4Fm8OojyeH0fwOy8FFCLMP/gtxd/KM0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578417609215727.875123152508; Tue, 7 Jan 2020 09:20:09 -0800 (PST) Received: from localhost ([::1]:53813 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iosWU-0004dR-IT for importer@patchew.org; Tue, 07 Jan 2020 12:20:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53041) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iosUy-0002q8-Kg for qemu-devel@nongnu.org; Tue, 07 Jan 2020 12:18:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iosUx-0006dM-Kz for qemu-devel@nongnu.org; Tue, 07 Jan 2020 12:18:32 -0500 Received: from 16.mo7.mail-out.ovh.net ([46.105.72.216]:53278) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iosUx-0006ZG-FK for qemu-devel@nongnu.org; Tue, 07 Jan 2020 12:18:31 -0500 Received: from player798.ha.ovh.net (unknown [10.108.35.122]) by mo7.mail-out.ovh.net (Postfix) with ESMTP id 3BAB2149DCF for ; Tue, 7 Jan 2020 18:18:26 +0100 (CET) Received: from kaod.org (lfbn-tou-1-1227-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player798.ha.ovh.net (Postfix) with ESMTPSA id 3EB0DE107721; Tue, 7 Jan 2020 17:18:21 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH 2/2] ppc/pnv: fix check on return value of blk_getlength() Date: Tue, 7 Jan 2020 18:18:09 +0100 Message-Id: <20200107171809.15556-3-clg@kaod.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200107171809.15556-1-clg@kaod.org> References: <20200107171809.15556-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 13646469823285332966 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrvdehhedgtdehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrhejleekrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedt Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.72.216 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" blk_getlength() returns an int64_t but the result is stored in a uint32_t. Errors (negative values) won't be caught by the check in pnv_pnor_realize() and blk_blockalign() will allocate a very large buffer in such cases. Fixes Coverity issue CID 1412226. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Greg Kurz Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/ppc/pnv_pnor.h | 2 +- hw/ppc/pnv_pnor.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/hw/ppc/pnv_pnor.h b/include/hw/ppc/pnv_pnor.h index c3dd28643cae..4f96abdfb402 100644 --- a/include/hw/ppc/pnv_pnor.h +++ b/include/hw/ppc/pnv_pnor.h @@ -23,7 +23,7 @@ typedef struct PnvPnor { BlockBackend *blk; =20 uint8_t *storage; - uint32_t size; + int64_t size; MemoryRegion mmio; } PnvPnor; =20 diff --git a/hw/ppc/pnv_pnor.c b/hw/ppc/pnv_pnor.c index 0e86ae2feae6..b061106d1c0c 100644 --- a/hw/ppc/pnv_pnor.c +++ b/hw/ppc/pnv_pnor.c @@ -111,7 +111,7 @@ static void pnv_pnor_realize(DeviceState *dev, Error **= errp) } =20 static Property pnv_pnor_properties[] =3D { - DEFINE_PROP_UINT32("size", PnvPnor, size, 128 << 20), + DEFINE_PROP_INT64("size", PnvPnor, size, 128 << 20), DEFINE_PROP_DRIVE("drive", PnvPnor, blk), DEFINE_PROP_END_OF_LIST(), }; --=20 2.21.1