Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4084806rdb; Mon, 11 Dec 2023 08:24:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjY0eBMu+FfOqI7/zDVWKs0tyRBK/sRXjVZdpN7tCDSij3lRh3jKH9+6z9+0PI+2jID4uB X-Received: by 2002:a17:90a:f418:b0:286:ee29:f712 with SMTP id ch24-20020a17090af41800b00286ee29f712mr5074219pjb.46.1702311847297; Mon, 11 Dec 2023 08:24:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702311847; cv=none; d=google.com; s=arc-20160816; b=XOeXRBu7/jR94DRpwvBuBLTgN0MBA8KZuSPW7g+GTbfD8oO4DKKiFvLaEp0edQgm6G AHWh45zN9P06IZfu+B77JUnRq1rUj2NPvu7tT9otvMtTj2VMA28OT1jYFPM7XmtHLgXv xvza0HypCWVI/7HNB7jBXYecK1BKXYoJXNRgglsaEVCVDRelHx+lVeIDR7odWxxDpnc8 W/AVuXtHFN4ONXmm2H0z9SEFi/R0C3TQQ8V+v85Pml5KhW1Sbwc6+rIsqGUX9TBFIjxg WUPDFzH7cIFhm7hiSIMRbq3paCm0LjnGdCr09ilIANiYYSG8Mfu57Smwfo8/UCGzMOGx N+Nw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eeCkrSB3uFHx+QRJXvlLlycFFlbNNEdrpOCWz+C0kpk=; fh=QwrctTXh8Jm28CP5wVsoDN9Vq1j9owXSiGpoEQgJ/DU=; b=Hy6fgrxgBTegNLWEmljZpvCDRCtsAju6vIApFqKlfndpJocJedQ009nGQ3qaGU58Sr /f0gZ5/MFL5btCU6YuVPZfsnySbf3IrVg+c14YJKldHLwq2I5yE3uOUdXlMs/yv8f9eh 3ttGnKXtoZURQIpp1U5CgCTF6JQqiSgIGE/cm9J01tMZCpyYmpgOIPubhg38kbHUu1dQ thXDPRo3w82TPnLXhLaGVidYgSSplgEX8zpx2rjRAR1fVwdOGAsVFAbkCvIYvkydilED ulGxXTR9IRpTEuYJVPQbEWKHH5koDTk92rZX+gjxXNIXPSHz1IiEuzYa9I8pOzqD+x9S h/kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=BJK5ocSU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id x11-20020a17090a8a8b00b0028a84e29ca4si2283501pjn.159.2023.12.11.08.24.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 08:24:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=BJK5ocSU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 517EB80B9919; Mon, 11 Dec 2023 08:24:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344188AbjLKQXq (ORCPT + 99 others); Mon, 11 Dec 2023 11:23:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343931AbjLKQXp (ORCPT ); Mon, 11 Dec 2023 11:23:45 -0500 X-Greylist: delayed 7044 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 11 Dec 2023 08:23:46 PST Received: from forwardcorp1c.mail.yandex.net (forwardcorp1c.mail.yandex.net [178.154.239.200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAC53A9; Mon, 11 Dec 2023 08:23:46 -0800 (PST) Received: from mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:5329:0:640:5ed5:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTP id 3E4B160C91; Mon, 11 Dec 2023 19:23:44 +0300 (MSK) Received: from kniv-nix.yandex-team.ru (unknown [2a02:6b8:b081:b718::1:2a]) by mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id dNkT8A0IWuQ0-nnbTnYGE; Mon, 11 Dec 2023 19:23:43 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1702311823; bh=eeCkrSB3uFHx+QRJXvlLlycFFlbNNEdrpOCWz+C0kpk=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=BJK5ocSUmwBAXUWxnxRxQ9ZaPvc9/tH0wvTRNftWfHKzpX0ZrG1oMhu0CncAWC4SE YqPLIYVe+91mVmsWIevlull4NeJhRrdaRu0yN+f5GJ4z4KGaJOwOsKJtae+RT1qah4 q13RtR9UNj5Y0Fa6kBmupOJynNc94YylHEhnzGw4= Authentication-Results: mail-nwsmtp-smtp-corp-main-26.myt.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 v2] vsock/virtio: Fix unsigned integer wrap around in virtio_transport_has_space() Date: Mon, 11 Dec 2023 19:23:17 +0300 Message-Id: <20231211162317.4116625-1-kniv@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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 morse.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 (morse.vger.email [0.0.0.0]); Mon, 11 Dec 2023 08:24:04 -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 Fixes: 06a8fc78367d ("VSOCK: Introduce virtio_vsock_common.ko") Signed-off-by: Nikolay Kuratov --- V1 -> V2: Added Fixes section 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