From nobody Wed May 22 02:53:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1695759476; cv=none; d=zohomail.com; s=zohoarc; b=YNmUvR1AfqkYZt0DC1wUqQ2uWtahKsnUCQgGg4OdHU7fCZcdun2wEgDnzuC44/O5M4ZTUgZ8WraRtovy/ZtjLitoM6ff0LzEXxtaeYOYVjW0w3POQpVQ4UjLJH8CnoA4Kvi7zlKpPQPYKXkwK9DF5BpAr8em6N7+rtGaBQAEpY4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695759476; h=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=jAvh0KaFeV113hpG3Sjju5klfyFefoMWGI2I5yIG3zw=; b=do7a7jJS+DP8LSv2AKpbT3Zf1Cp0Orr0PTw+y6A/knrsX8GhM2b24jJuMLVRpwGKlzLxjjaj9sVbCKGMwON1y/j5bIUaQZANLsfCMgwM/QvEZ+Rf9WvZ3aB2pgCR1RzayQk/H9QFoPELrFYldKqijUIMlTsC0uS4mut6Fb0pIhw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169575947677157.513583244646725; Tue, 26 Sep 2023 13:17:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlETa-0000Y6-0d; Tue, 26 Sep 2023 16:16:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qlETX-0000Wx-MZ for qemu-devel@nongnu.org; Tue, 26 Sep 2023 16:16:07 -0400 Received: from forwardcorp1c.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qlETS-0002gw-FL for qemu-devel@nongnu.org; Tue, 26 Sep 2023 16:16:07 -0400 Received: from mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:550b:0:640:d49b:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTP id D06A660B81; Tue, 26 Sep 2023 23:15:55 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6b8:b081:b41d::1:39]) by mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ZFWwvr0Oc0U0-5hDZfIZL; Tue, 26 Sep 2023 23:15:55 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1695759355; bh=jAvh0KaFeV113hpG3Sjju5klfyFefoMWGI2I5yIG3zw=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=g8iwTxPXVsH+ai1czxf9XXDj3gEIKGHKy+as3DnaI+14TWFvh5XYwQwTjOfBVLJ3x DxJJGK7z76tqu0LRnIJ5ltAltPSfjKC/LPFbjT8paPuQBwULvMf//S71iB3MBsEGtl u0tsYvaPwGNByi82wHIj6cIeeNqhId/CxWBzU2/s= Authentication-Results: mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, vsementsov@yandex-team.ru, peter.maydell@linaro.org, yc-core@yandex-team.ru, davydov-max@yandex-team.ru, "Michael S. Tsirkin" , Peter Xu , Jason Wang , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost Subject: [PATCH v2 1/8] hw/i386/intel_iommu: vtd_slpte_nonzero_rsvd(): assert no overflow Date: Tue, 26 Sep 2023 23:15:25 +0300 Message-Id: <20230926201532.221152-2-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230926201532.221152-1-vsementsov@yandex-team.ru> References: <20230926201532.221152-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1695759479501100003 Content-Type: text/plain; charset="utf-8" We support only 3- and 4-level page-tables, which is firstly checked in vtd_decide_config(), then setup in vtd_init(). Than level fields are checked by vtd_is_level_supported(). So here we can't have level out from 1..4 inclusive range. Let's assert it. That also explains Coverity that we are not going to overflow the array. CID: 1487158, 1487186 Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Maksim Davydov Reviewed-by: Peter Maydell --- hw/i386/intel_iommu.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index c0ce896668..3b68183b78 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -1027,18 +1027,35 @@ static dma_addr_t vtd_get_iova_pgtbl_base(IntelIOMM= UState *s, * Rsvd field masks for spte: * vtd_spte_rsvd 4k pages * vtd_spte_rsvd_large large pages + * + * We support only 3-level and 4-level page tables (see vtd_init() which + * sets only VTD_CAP_SAGAW_39bit and maybe VTD_CAP_SAGAW_48bit bits in s->= cap). */ -static uint64_t vtd_spte_rsvd[5]; -static uint64_t vtd_spte_rsvd_large[5]; +#define VTD_SPTE_RSVD_LEN 5 +static uint64_t vtd_spte_rsvd[VTD_SPTE_RSVD_LEN]; +static uint64_t vtd_spte_rsvd_large[VTD_SPTE_RSVD_LEN]; =20 static bool vtd_slpte_nonzero_rsvd(uint64_t slpte, uint32_t level) { - uint64_t rsvd_mask =3D vtd_spte_rsvd[level]; + uint64_t rsvd_mask; + + /* + * We should have caught a guest-mis-programmed level earlier, + * via vtd_is_level_supported. + */ + assert(level < VTD_SPTE_RSVD_LEN); + /* + * Zero level doesn't exist. The smallest level is VTD_SL_PT_LEVEL=3D1= and + * checked by vtd_is_last_slpte(). + */ + assert(level); =20 if ((level =3D=3D VTD_SL_PD_LEVEL || level =3D=3D VTD_SL_PDP_LEVEL) && (slpte & VTD_SL_PT_PAGE_SIZE_MASK)) { /* large page */ rsvd_mask =3D vtd_spte_rsvd_large[level]; + } else { + rsvd_mask =3D vtd_spte_rsvd[level]; } =20 return slpte & rsvd_mask; --=20 2.34.1 From nobody Wed May 22 02:53:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1695759483; cv=none; d=zohomail.com; s=zohoarc; b=esz7+vD2jD1slrOLr49yUGFEfrq1Ns4MrG2ACtm+IxjqN4Un43Pf1hhH2gYTah7CWboMe6fUgN89pkb8V0lVx13S3yd3joAzw4BWhd1oj69U/QehD24qguqIFjlBnfjRXps8nbWMZhS0Ni+3u3JGg1sHKN6IjX8XU4c+A+md1sY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695759483; h=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=wvUasXlWa6y9/1/CgE5+CmyIWRY2KP5PRQL2MGutOgg=; b=Nd+L89KdaNItDxiVRaS92ly5C1JMmJrB3J3HjkOyuzFqcnFUlbCdhbRarTTKMqpTznFiualkixqNIKazsk6onBbsUbQslUDU59k7qA2mCKiZT0tY76vFkS73tJL2yoOFw1h0izAzSYB6GF0Qd1e2E3sRVIxftdtMiMgft29Edco= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695759483929421.0417192156631; Tue, 26 Sep 2023 13:18:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlETZ-0000Xn-OJ; Tue, 26 Sep 2023 16:16:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qlETX-0000Wh-8l for qemu-devel@nongnu.org; Tue, 26 Sep 2023 16:16:07 -0400 Received: from forwardcorp1b.mail.yandex.net ([2a02:6b8:c02:900:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qlETR-0002h2-Pd for qemu-devel@nongnu.org; Tue, 26 Sep 2023 16:16:07 -0400 Received: from mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:550b:0:640:d49b:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id 956E56079A; Tue, 26 Sep 2023 23:15:56 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6b8:b081:b41d::1:39]) by mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ZFWwvr0Oc0U0-DGo0cj3F; Tue, 26 Sep 2023 23:15:56 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1695759356; bh=wvUasXlWa6y9/1/CgE5+CmyIWRY2KP5PRQL2MGutOgg=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=y0gXSfiKetMq0xgii1aqk35pMW9rV2weQ2Qo1vtYVyRLkmtK52Y163nClBW0EVKZ7 IPTmRTqULjYyLHpeE0lNdE6KKrtp5POS3mBsqgrEfGCDgtuX97vy2jk/kB/EJV4p0N BBvEPYohzRbRInUTs4reo8ygIISDtj6XD7LStQg4= Authentication-Results: mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, vsementsov@yandex-team.ru, peter.maydell@linaro.org, yc-core@yandex-team.ru, davydov-max@yandex-team.ru, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v2 2/8] util/filemonitor-inotify: qemu_file_monitor_watch(): assert no overflow Date: Tue, 26 Sep 2023 23:15:26 +0300 Message-Id: <20230926201532.221152-3-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230926201532.221152-1-vsementsov@yandex-team.ru> References: <20230926201532.221152-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a02:6b8:c02:900:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1695759485047100001 Content-Type: text/plain; charset="utf-8" Prefer clear assertions instead of [im]possible array overflow. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Maksim Davydov Reviewed-by: Peter Maydell --- util/filemonitor-inotify.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/util/filemonitor-inotify.c b/util/filemonitor-inotify.c index 2c45f7f176..2121111f38 100644 --- a/util/filemonitor-inotify.c +++ b/util/filemonitor-inotify.c @@ -81,16 +81,25 @@ static void qemu_file_monitor_watch(void *arg) =20 /* Loop over all events in the buffer */ while (used < len) { - struct inotify_event *ev =3D - (struct inotify_event *)(buf + used); - const char *name =3D ev->len ? ev->name : ""; - QFileMonitorDir *dir =3D g_hash_table_lookup(mon->idmap, - GINT_TO_POINTER(ev->wd)= ); - uint32_t iev =3D ev->mask & - (IN_CREATE | IN_MODIFY | IN_DELETE | IN_IGNORED | - IN_MOVED_TO | IN_MOVED_FROM | IN_ATTRIB); + const char *name; + QFileMonitorDir *dir; + uint32_t iev; int qev; gsize i; + struct inotify_event *ev =3D (struct inotify_event *)(buf + used); + + /* + * We trust the kenel to provide valid buffer with complete event + * records. + */ + assert(len - used >=3D sizeof(struct inotify_event)); + assert(len - used - sizeof(struct inotify_event) >=3D ev->len); + + name =3D ev->len ? ev->name : ""; + dir =3D g_hash_table_lookup(mon->idmap, GINT_TO_POINTER(ev->wd)); + iev =3D ev->mask & + (IN_CREATE | IN_MODIFY | IN_DELETE | IN_IGNORED | + IN_MOVED_TO | IN_MOVED_FROM | IN_ATTRIB); =20 used +=3D sizeof(struct inotify_event) + ev->len; =20 --=20 2.34.1 From nobody Wed May 22 02:53:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1695759448; cv=none; d=zohomail.com; s=zohoarc; b=k2AwT9BsKe9UuC/QZtlAGPw6DUJuxt7r3PV3/M8+cvgmWwWWHZkUaR1E4q7sSl68/9wlqoqeEILFI+1KkgHl3KTxgl0GQ69Jss4IhXhnDuIb7+HQVEFFCBsx3Q7vwnGmPYTqoPEIu6nD2orpXVJIUdPRxwaNDW/F46iqSs88ShQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695759448; h=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=APD63jVjpKGyXrrj8bpH2G86emsF9emrRj2IUL6CpiU=; b=TfH8agPQhls/x+oSTlPZNRKqv/HPj8tehtsTZ5j64MmcxxJ9AOXRjKY447Ao1JtWE9jkb3r3S+Xc+aE8shKxjfz6kRXmMeVoqmR9lUovNSk0kbBTx64beX8vinaBgnZbIdHGJ+3A0cvxdPciR+U2bl43O+Gf9ymoP/zVOlEwa0o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695759448007494.49304560789335; Tue, 26 Sep 2023 13:17:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlETk-0000aq-5r; Tue, 26 Sep 2023 16:16:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qlETc-0000ZZ-Jh for qemu-devel@nongnu.org; Tue, 26 Sep 2023 16:16:13 -0400 Received: from forwardcorp1c.mail.yandex.net ([2a02:6b8:c03:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qlETR-0002hE-Pc for qemu-devel@nongnu.org; Tue, 26 Sep 2023 16:16:11 -0400 Received: from mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:550b:0:640:d49b:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTP id 66C7060B72; Tue, 26 Sep 2023 23:15:57 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6b8:b081:b41d::1:39]) by mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ZFWwvr0Oc0U0-NKbQtG43; Tue, 26 Sep 2023 23:15:56 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1695759356; bh=APD63jVjpKGyXrrj8bpH2G86emsF9emrRj2IUL6CpiU=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=oo3C88nKCjN3Ji0lvH0+9qdAPAtc/i8ltal3/vMacyKT+5nqSKEP0RYTIPiLbj+vK BLyFVchnCDDnawg8blMqmHLRrTvq51YDBJDc8BLzvtdedK7g+r479tf7JXIuhyOxsL tSusOeWrYbad6qhuFGxJDCtwDgPvIZXXLLOpTP48= Authentication-Results: mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, vsementsov@yandex-team.ru, peter.maydell@linaro.org, yc-core@yandex-team.ru, davydov-max@yandex-team.ru, "Michael S. Tsirkin" Subject: [PATCH v2 3/8] libvhost-user.c: add assertion to vu_message_read_default Date: Tue, 26 Sep 2023 23:15:27 +0300 Message-Id: <20230926201532.221152-4-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230926201532.221152-1-vsementsov@yandex-team.ru> References: <20230926201532.221152-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a02:6b8:c03:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1695759450395100010 Content-Type: text/plain; charset="utf-8" Explain Coverity that we are not going to overflow vmsg->fds. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Maksim Davydov --- subprojects/libvhost-user/libvhost-user.c | 1 + 1 file changed, 1 insertion(+) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index 0469a50101..49b57c7ef4 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -322,6 +322,7 @@ vu_message_read_default(VuDev *dev, int conn_fd, VhostU= serMsg *vmsg) if (cmsg->cmsg_level =3D=3D SOL_SOCKET && cmsg->cmsg_type =3D=3D S= CM_RIGHTS) { fd_size =3D cmsg->cmsg_len - CMSG_LEN(0); vmsg->fd_num =3D fd_size / sizeof(int); + assert(fd_size < VHOST_MEMORY_BASELINE_NREGIONS); memcpy(vmsg->fds, CMSG_DATA(cmsg), fd_size); break; } --=20 2.34.1 From nobody Wed May 22 02:53:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1695759454; cv=none; d=zohomail.com; s=zohoarc; b=QHSWGFP08gRioa+kGJWzRg/N+1OU92XKiYY1mlNGEwHOttX+/frrPwY4Jei09N49PM3hdvvHzd3fhrFgjY2OBmb/QCToSQsn3CUw8RF74gQQYSGcyQsletM0m9Yt5ZBr2/1h7Yz69VD/RnNw5onKRsA9qoltLUuyKxId/h2D8vc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695759454; h=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=EQA1Z1L3Ok0Pzqy4RW7FAhRw60+o+EX06kmlfEGLGIE=; b=cA3wKrX09OOr0lb8m/kZxpIyaj0AW0sTh2dFU1Kzm2/j0A5/WiRnrJZ/0qiapsp3k5BzdPY0tIxDW+rYOw+WTxR76niFpgmB343sgl3KszlaaqA5ZhpVAokC0pQlSqed23MHcvH1fvpCZloPRnZT21ASWJAY9QhRAf/Ag901rRE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695759454383304.8100829877578; Tue, 26 Sep 2023 13:17:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlETa-0000YP-Kh; Tue, 26 Sep 2023 16:16:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qlETX-0000Wi-Br for qemu-devel@nongnu.org; Tue, 26 Sep 2023 16:16:07 -0400 Received: from forwardcorp1c.mail.yandex.net ([2a02:6b8:c03:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qlETR-0002hP-Rj for qemu-devel@nongnu.org; Tue, 26 Sep 2023 16:16:07 -0400 Received: from mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:550b:0:640:d49b:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTP id 4174560B95; Tue, 26 Sep 2023 23:15:58 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6b8:b081:b41d::1:39]) by mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ZFWwvr0Oc0U0-8UOl5cvu; Tue, 26 Sep 2023 23:15:57 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1695759357; bh=EQA1Z1L3Ok0Pzqy4RW7FAhRw60+o+EX06kmlfEGLGIE=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=iuXBz6kljqjxWUQmRyaGaErXV8Cu9hApa9lzUeGGFU0KVpi8SJf85Ea3iO7zBWBpA TfE4nVzMMkuX/ZKnnmvSeOajtNjLLXoutfEfKUoFm9eiiZLct++xCUlxLrgxClSba2 4znIbHGTSoiJ7+PdeRBbCtaq2whHYE6fsBsmDXBQ= Authentication-Results: mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, vsementsov@yandex-team.ru, peter.maydell@linaro.org, yc-core@yandex-team.ru, davydov-max@yandex-team.ru, "Michael S. Tsirkin" Subject: [PATCH v2 4/8] mc146818rtc: rtc_set_time(): initialize tm to zeroes Date: Tue, 26 Sep 2023 23:15:28 +0300 Message-Id: <20230926201532.221152-5-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230926201532.221152-1-vsementsov@yandex-team.ru> References: <20230926201532.221152-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a02:6b8:c03:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1695759455255100001 Content-Type: text/plain; charset="utf-8" set_time() function doesn't set all the fields, so it's better to initialize tm structure. And Coverity will be happier about it. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Maksim Davydov Reviewed-by: Peter Maydell --- hw/rtc/mc146818rtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c index c27c362db9..2d391a8396 100644 --- a/hw/rtc/mc146818rtc.c +++ b/hw/rtc/mc146818rtc.c @@ -599,7 +599,7 @@ static void rtc_get_time(MC146818RtcState *s, struct tm= *tm) =20 static void rtc_set_time(MC146818RtcState *s) { - struct tm tm; + struct tm tm =3D {}; g_autofree const char *qom_path =3D object_get_canonical_path(OBJECT(s= )); =20 rtc_get_time(s, &tm); --=20 2.34.1 From nobody Wed May 22 02:53:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1695759449; cv=none; d=zohomail.com; s=zohoarc; b=HsAcWUVQzm/on/IBh4gMnplIKkBYvTbNdcPifHBmgFKdBopWDXFKs/gA67D/o/erQG7OX8gHPEAwpZmwtOX3j9NjahRNMST/saPKj3wxYX0kiLyYu9fs87YUK730Xb8w+bSkPib1ZNfbwx8KJoMI7R+Cw67pQh7Ex66IFaeuEXg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695759449; h=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=3bfRsX2bcaRNysuZopQT1GUhW00NrecV1SjNahVWt/I=; b=icBGK2q4BnWePcdgjZEbiJK18C0bzn0EsREmJZJDmb87gsGsI8isRkoDnoWyGbinW/ppzKJCwcNFDNJTnRbx3kLUoDJZhol7iT60HdXfiw+XqoiTJCYBTS/Z4mvNkpi66S7KGOqTXc3TM+BfF4LM3r/v8raKd2QixCND+Svnr4E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169575944997685.08837817758308; Tue, 26 Sep 2023 13:17:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlETd-0000ZO-49; Tue, 26 Sep 2023 16:16:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qlETY-0000X9-Gm for qemu-devel@nongnu.org; Tue, 26 Sep 2023 16:16:08 -0400 Received: from forwardcorp1c.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qlETT-0002hU-Bx for qemu-devel@nongnu.org; Tue, 26 Sep 2023 16:16:08 -0400 Received: from mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:550b:0:640:d49b:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTP id 0951760B97; Tue, 26 Sep 2023 23:15:59 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6b8:b081:b41d::1:39]) by mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ZFWwvr0Oc0U0-7te6I8Sr; Tue, 26 Sep 2023 23:15:58 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1695759358; bh=3bfRsX2bcaRNysuZopQT1GUhW00NrecV1SjNahVWt/I=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=Uvq89eCVs2AlGuqW58Q5O5sBr+wyhPW8wK2SIlegWEQW5GH5Oqt4iythFeRZ4qrj6 e3MPIh2GmUHYa5mxqhr77EHPgWNrq09dxznlyziC/heoNkflZETVke7w49h2LfdFgv paZr0BAs3BfEKhDYwYapHxJ97DZFaa4lmLk3SFLs= Authentication-Results: mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, vsementsov@yandex-team.ru, peter.maydell@linaro.org, yc-core@yandex-team.ru, davydov-max@yandex-team.ru, "Michael S. Tsirkin" , Marcel Apfelbaum Subject: [PATCH v2 5/8] pcie_sriov: unregister_vfs(): fix error path Date: Tue, 26 Sep 2023 23:15:29 +0300 Message-Id: <20230926201532.221152-6-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230926201532.221152-1-vsementsov@yandex-team.ru> References: <20230926201532.221152-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1695759451037100017 Content-Type: text/plain; charset="utf-8" local_err must be NULL before calling object_property_set_bool(), so we must clear it on each iteration. Let's also use more convenient error_reportf_err(). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Maksim Davydov --- hw/pci/pcie_sriov.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index 76a3b6917e..5ef8950940 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -196,19 +196,16 @@ static void register_vfs(PCIDevice *dev) =20 static void unregister_vfs(PCIDevice *dev) { - Error *local_err =3D NULL; uint16_t num_vfs =3D dev->exp.sriov_pf.num_vfs; uint16_t i; =20 trace_sriov_unregister_vfs(dev->name, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), num_vfs); for (i =3D 0; i < num_vfs; i++) { + Error *err =3D NULL; PCIDevice *vf =3D dev->exp.sriov_pf.vf[i]; - object_property_set_bool(OBJECT(vf), "realized", false, &local_err= ); - if (local_err) { - fprintf(stderr, "Failed to unplug: %s\n", - error_get_pretty(local_err)); - error_free(local_err); + if (!object_property_set_bool(OBJECT(vf), "realized", false, &err)= ) { + error_reportf_err(err, "Failed to unplug: "); } object_unparent(OBJECT(vf)); object_unref(OBJECT(vf)); --=20 2.34.1 From nobody Wed May 22 02:53:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1695759448; cv=none; d=zohomail.com; s=zohoarc; b=AAVzDgFlu168lWFgd4c5kwtKrEZsFk4SA9z4d1m6xM6z2W6eRG7PxhWnBEt1jJ0W20kpghpQiNe8YZ4jnvps6Bj/R495s/3rOKA37zJD2CSkNGtYniZroAqq9yrIkg5wab6J2uWEZZ7UWeQJicL7lv2x93p7vc4tleWAYo5/wLA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695759448; h=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=Qr88yzO2svS1+rGVJi/Il3bOpU2quKc+o4WQ98vjCDU=; b=AVvEsjiG2Zw2nDwp/Gxgqw7EGKBQGYfYLq/eb8/V79kEPSOqf5R02pOPhEZMfHJmoViFffcFN3Hjg8/0ZaEOdWfbeewZnCDVR/+lJbRycqBxuIvxmaUKjgh8zBxRnjqbJl10DimIyRPGwXCEtkKGh8HF++R0Iswa6+aK18ihKfc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169575944835922.073349520981083; Tue, 26 Sep 2023 13:17:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlETb-0000Yj-2K; Tue, 26 Sep 2023 16:16:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qlETY-0000XG-PW; Tue, 26 Sep 2023 16:16:08 -0400 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qlETT-0002hc-N1; Tue, 26 Sep 2023 16:16:08 -0400 Received: from mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:550b:0:640:d49b:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id 7B269607AC; Tue, 26 Sep 2023 23:16:00 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6b8:b081:b41d::1:39]) by mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ZFWwvr0Oc0U0-s9ITwPhm; Tue, 26 Sep 2023 23:15:59 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1695759359; bh=Qr88yzO2svS1+rGVJi/Il3bOpU2quKc+o4WQ98vjCDU=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=OMdfoqqRbClO+a0Lxh+qA555LExXZUz1kW+44v3ZJ6KtgLi6YzFWGFWeNU6+OCaRZ KtKvYYC94GKbUSshOBe1sSPCHkYSbunGVoQQrznHHhJBKWYQ/3hPXPH7pE2ZgT49ll yUlYqzMF0EpP071m+W9PNJEQgkAYrT0gMtF5j0ec= Authentication-Results: mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, vsementsov@yandex-team.ru, peter.maydell@linaro.org, yc-core@yandex-team.ru, davydov-max@yandex-team.ru, stefanha@redhat.com, alex.chen@huawei.com, euler.robot@huawei.com, Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org (open list:NVMe Block Driver) Subject: [PATCH v2 6/8] block/nvme: nvme_process_completion() fix bound for cid Date: Tue, 26 Sep 2023 23:15:30 +0300 Message-Id: <20230926201532.221152-7-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230926201532.221152-1-vsementsov@yandex-team.ru> References: <20230926201532.221152-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=178.154.239.136; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1695759450395100011 Content-Type: text/plain; charset="utf-8" NVMeQueuePair::reqs has length NVME_NUM_REQS, which less than NVME_QUEUE_SIZE by 1. Fixes: 1086e95da17050 ("block/nvme: switch to a NVMeRequest freelist") Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Maksim Davydov Reviewed-by: Stefan Hajnoczi --- Cc: stefanha@redhat.com Cc: alex.chen@huawei.com Cc: euler.robot@huawei.com Note, that there was similar patch in the past: https://patchew.org/QEMU/20201208144452.91172-1-alex.chen@huawei.com/ I still think, that using NVME_NUM_REQS is better here. block/nvme.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index b6e95f0b7e..0faedf3072 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -416,9 +416,10 @@ static bool nvme_process_completion(NVMeQueuePair *q) q->cq_phase =3D !q->cq_phase; } cid =3D le16_to_cpu(c->cid); - if (cid =3D=3D 0 || cid > NVME_QUEUE_SIZE) { - warn_report("NVMe: Unexpected CID in completion queue: %"PRIu3= 2", " - "queue size: %u", cid, NVME_QUEUE_SIZE); + if (cid =3D=3D 0 || cid > NVME_NUM_REQS) { + warn_report("NVMe: Unexpected CID in completion queue: %" PRIu= 32 + ", should be within: 1..%u inclusively", cid, + NVME_NUM_REQS); continue; } trace_nvme_complete_command(s, q->index, cid); --=20 2.34.1 From nobody Wed May 22 02:53:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1695759471; cv=none; d=zohomail.com; s=zohoarc; b=IYD2zNQCstT7sdc+q2MaOnNUClyvNhguAt9oaFAry84sbYImBz69mJMt/uqKtFyCRgDUSK0hBPxvu10QAk8EDIsxoLDMdhmhhGlWjoZNeLvaiHdb1IqRpZMjAOdl1o/Eb/4vgf7U4+O/+xi3vH/mrp0mJnggENkwyt+rBE9daNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695759471; h=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=aaCfmklaWkmNL0irOMq48CDnwFy1cEsXeQY8stTazm4=; b=WkqXq/cKye9sZ4y52ircbgmUnEY8hvQPrM0tAAy8BhG4cNEFP5i96CYcOYC1WcHMgFMTHrhAqOXTuFOhMdPdVe5Xo07JvE+sSSe3b1LhfpLR7mEDnGYGihpFkAw72ASWSrP0YVv8lmQkXk1z5FL5k267lWNCNqMrB13uDJHgBXA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695759471540778.635022215083; Tue, 26 Sep 2023 13:17:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlETj-0000aW-8p; Tue, 26 Sep 2023 16:16:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qlETY-0000XK-Ut for qemu-devel@nongnu.org; Tue, 26 Sep 2023 16:16:09 -0400 Received: from forwardcorp1c.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qlETU-0002hu-DR for qemu-devel@nongnu.org; Tue, 26 Sep 2023 16:16:08 -0400 Received: from mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:550b:0:640:d49b:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTP id A6F9860BA1; Tue, 26 Sep 2023 23:16:01 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6b8:b081:b41d::1:39]) by mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ZFWwvr0Oc0U0-0B4CWWb9; Tue, 26 Sep 2023 23:16:01 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1695759361; bh=aaCfmklaWkmNL0irOMq48CDnwFy1cEsXeQY8stTazm4=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=ZFlBfPUI2qSLgfvq6dfyaEwPs5uEqP3PqZtdEJ2l8dVzYaRJ00kU/nrKp0DWVu0/v TdzCKNSGGgfzMUDFVG44bTxsdK5sTxtFOAiXDeRvgv8FC4iTKyKcuRwu5t4flkJHdH PUdEtvgTAbFkcG0FdRUIIkjLn92KN2rWduHy1kxI= Authentication-Results: mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, vsementsov@yandex-team.ru, peter.maydell@linaro.org, yc-core@yandex-team.ru, davydov-max@yandex-team.ru, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Thomas Huth , Richard Henderson , Emilio Cota Subject: [PATCH v2 7/8] hw/core/loader: gunzip(): initialize z_stream Date: Tue, 26 Sep 2023 23:15:31 +0300 Message-Id: <20230926201532.221152-8-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230926201532.221152-1-vsementsov@yandex-team.ru> References: <20230926201532.221152-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1695759473250100002 Content-Type: text/plain; charset="utf-8" Coverity signals that variable as being used uninitialized. And really, when work with external APIs that's better to zero out the structure, where we set some fields by hand. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Maksim Davydov Reviewed-by: Peter Maydell --- hw/core/loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/core/loader.c b/hw/core/loader.c index 4dd5a71fb7..b7bb44b7f7 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -558,7 +558,7 @@ static void zfree(void *x, void *addr) =20 ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src, size_t srclen) { - z_stream s; + z_stream s =3D {}; ssize_t dstbytes; int r, i, flags; =20 --=20 2.34.1 From nobody Wed May 22 02:53:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1695759448; cv=none; d=zohomail.com; s=zohoarc; b=f+yDnUPmahjORV7fiqqY9oGb+W/7Y1nHh50jDWUBJOYxOdlacKoCGbVglvuP4R1Sa8Z1t3Ho32xO5FZjGv+qU66OmiJElwPGAUju/eUMBaWp7p/DwlQGgMwyu/t3soN+ZZ+w5qZTHzcXCJ4w34kKbavqUrV7WjzPqDKOthruSdk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695759448; h=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=ou8GZudm1QVqrgm1YLFWVUTc0Kur2k7RwKAHeFH0CfY=; b=JLwCZHlZyU5OyZfM8p/bK2tXFLlgdkGkm9nP9DP9IDoATuxoBRkLj9VSv+ATdlYWFbz4QmeJ3wqv+9OOnZhZV4xVVcCGUsgU9rs3zSprTjszcPlP4SCKHTTcodf61qcKboAS5p8w2VSx58lxlJ6REFaYOs3Kmo8vY0uC235pj+k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695759448401520.6510203861453; Tue, 26 Sep 2023 13:17:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlETe-0000Zf-Du; Tue, 26 Sep 2023 16:16:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qlETZ-0000Y4-NT for qemu-devel@nongnu.org; Tue, 26 Sep 2023 16:16:09 -0400 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qlETU-0002jI-VX for qemu-devel@nongnu.org; Tue, 26 Sep 2023 16:16:09 -0400 Received: from mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:550b:0:640:d49b:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id 7D9F96071F; Tue, 26 Sep 2023 23:16:02 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6b8:b081:b41d::1:39]) by mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ZFWwvr0Oc0U0-y1u5B3CV; Tue, 26 Sep 2023 23:16:01 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1695759361; bh=ou8GZudm1QVqrgm1YLFWVUTc0Kur2k7RwKAHeFH0CfY=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=mZM5/tXe7cjK24YfsmPSl0eoQ+fJXBWeooqSuTBntaZeseLzWaLyIw/1JpMuuPqPv Ko18HD7wMSIy37ebpf4jxS4/3w89kZAph3dMYITZIrzrVDqZxZi6DsQZ4PSYF+TtHr qi0zGetElc/TqXwFOXSz+0YtAnLBDfQHZ7yrSoPY= Authentication-Results: mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, vsementsov@yandex-team.ru, peter.maydell@linaro.org, yc-core@yandex-team.ru, davydov-max@yandex-team.ru, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v2 8/8] io/channel-socket: qio_channel_socket_flush(): improve msg validation Date: Tue, 26 Sep 2023 23:15:32 +0300 Message-Id: <20230926201532.221152-9-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230926201532.221152-1-vsementsov@yandex-team.ru> References: <20230926201532.221152-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=178.154.239.136; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1695759450849100015 Content-Type: text/plain; charset="utf-8" For SO_EE_ORIGIN_ZEROCOPY the 32-bit notification range is encoded as [ee_info, ee_data] inclusively, so ee_info should be less or equal to ee_data. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Maksim Davydov --- io/channel-socket.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/io/channel-socket.c b/io/channel-socket.c index 02ffb51e99..3a899b0608 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -782,6 +782,11 @@ static int qio_channel_socket_flush(QIOChannel *ioc, "Error not from zero copy"); return -1; } + if (serr->ee_data < serr->ee_info) { + error_setg_errno(errp, serr->ee_origin, + "Wrong notification bounds"); + return -1; + } =20 /* No errors, count successfully finished sendmsg()*/ sioc->zero_copy_sent +=3D serr->ee_data - serr->ee_info + 1; --=20 2.34.1