Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4006308rdb; Mon, 11 Dec 2023 06:28:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IF56igoC1gc4tpQqtVxMSl6ipgKOhSU1pBqSEfrPm5iqsy5DKuZYHqVSsHR4ZQ149vx2gZZ X-Received: by 2002:a05:6a00:b92:b0:6cd:eda8:258a with SMTP id g18-20020a056a000b9200b006cdeda8258amr4925930pfj.27.1702304902453; Mon, 11 Dec 2023 06:28:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702304902; cv=none; d=google.com; s=arc-20160816; b=eb0G0p8D3tUy3RHJgb76FfSqvrhZcMySNme0ZTOe0jryxJkD3ps0ODyjOA9I/X8aRN yMqtQGXWxEBKDRDEGSMQe69KI1gvtkKU1c0b8ipLitPOOJGJo0ufwzcKSL28qXV6btlt lj5hljLSh2/BlV9wLHixR8TRbzqslIJc61J9yYjjvBLNJQDtZkYVXYLTKjcSJeCU2b0Y yDQHlskkbZTraRwDJ1D7fdacZS1x6c43h0mnWkpPkOMNwBd+OF6Ek6yqkD4voDLd6WCb C2yTWCOJSzyhRNCe9kUKQuoY4DhdmxvGdTMLltquDaupCF8OpSgiZ63WWtdoyLg2hDOn HQoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=okgSQ4jSQ39ig7kfarAvRYBE8MWRoq0a2/YUSKkMo0Q=; fh=QwrctTXh8Jm28CP5wVsoDN9Vq1j9owXSiGpoEQgJ/DU=; b=l/ltocqIkb1/BfgWT+NUUArEC/+ECIe1KC4an8Th+YDVzgQbgMMLukfBbfshP1gH3v NLL8FOH7jXngyiWcpn8U61DYfHwn3M2nGeGsycJt4Jcb192IEeexvOD2i2OxhYN+dNQK LP97E5ggm55WfeKMBBbpk5DBpparoXqDRGkkSn6Ab0+Jwu2cPveaVUQQTC8MReJoVH2e NcQfkYLXBHfmTAs2hTxvvON/MpQauqm5hdy4NeTo1146E/0px5j1SVwDRpyRkAD7Ii7d n57c3PPaDO94BNBm/C88UiUkUprEMLAIEN4v9s6R2s6mBVccLlcB41V+nkEr+KsWpPp+ Wb4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=0keANDS6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id d9-20020a056a0010c900b006cdff9ab05fsi6169808pfu.50.2023.12.11.06.28.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 06:28:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=0keANDS6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 3B381805DEC1; Mon, 11 Dec 2023 06:28:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234943AbjLKO15 (ORCPT + 99 others); Mon, 11 Dec 2023 09:27:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235010AbjLKO1p (ORCPT ); Mon, 11 Dec 2023 09:27:45 -0500 X-Greylist: delayed 71 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 11 Dec 2023 06:27:37 PST Received: from forwardcorp1b.mail.yandex.net (forwardcorp1b.mail.yandex.net [IPv6:2a02:6b8:c02:900:1:45:d181:df01]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AF6210D0; Mon, 11 Dec 2023 06:27:36 -0800 (PST) Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bd84:0:640:4b62:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id 571116154A; Mon, 11 Dec 2023 17:26:20 +0300 (MSK) Received: from kniv-nix.yandex-team.ru (unknown [2a02:6b8:b081:b718::1:2a]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id FQiaE60IfSw0-y85DjH1F; Mon, 11 Dec 2023 17:26:19 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1702304779; bh=okgSQ4jSQ39ig7kfarAvRYBE8MWRoq0a2/YUSKkMo0Q=; h=Message-Id:Date:Cc:Subject:To:From; b=0keANDS6V0C7aVY3xGtXMkiaVMTvJdnVS5F3XyDJyx9XiAkgJ6M8OgSpGHth7NGnY NuX+yg8iQbYu4HsIpsvKwre/gFTts5MXRR1vzSU0Rk7E3DdsZU8oFspCy15oQkOo1g x7OUziUIHBQoOXJ6fuEr42ns6WbdTn8ctoOTyiDo= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Nikolay Kuratov To: linux-kernel@vger.kernel.org Cc: sgarzare@redhat.com, netdev@vger.kernel.org, virtualization@lists.linux.dev, kvm@vger.kernel.org, Nikolay Kuratov Subject: [PATCH] vsock/virtio: Fix unsigned integer wrap around in virtio_transport_has_space() Date: Mon, 11 Dec 2023 17:25:05 +0300 Message-Id: <20231211142505.4076725-1-kniv@yandex-team.ru> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 11 Dec 2023 06:28:20 -0800 (PST) We need to do signed arithmetic if we expect condition `if (bytes < 0)` to be possible Found by Linux Verification Center (linuxtesting.org) with SVACE Signed-off-by: Nikolay Kuratov --- net/vmw_vsock/virtio_transport_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c index c8e162c9d1df..6df246b53260 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -843,7 +843,7 @@ static s64 virtio_transport_has_space(struct vsock_sock *vsk) struct virtio_vsock_sock *vvs = vsk->trans; s64 bytes; - bytes = vvs->peer_buf_alloc - (vvs->tx_cnt - vvs->peer_fwd_cnt); + bytes = (s64)vvs->peer_buf_alloc - (vvs->tx_cnt - vvs->peer_fwd_cnt); if (bytes < 0) bytes = 0; -- 2.34.1