Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3221353rwb; Sat, 3 Dec 2022 00:58:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Vkn8SPnqyazeeOdgkhNmiDFwUxHUXhqLc3Q5WIiYM1he1+KrNmMzt0MY1pQ+V/o56wJPF X-Received: by 2002:a05:6402:4512:b0:461:4c59:12d6 with SMTP id ez18-20020a056402451200b004614c5912d6mr67204707edb.250.1670057921319; Sat, 03 Dec 2022 00:58:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670057921; cv=none; d=google.com; s=arc-20160816; b=0bg6/XqH+kcV4P/IZB/RAWRnpd29SPnNSJfr/SBtDuz3kRg+gCmxUvyc1aBcUcly3o EwEStGTdE/0I7Q0pJHBVyFD/gMtIQ8Bvd90v0y4lhdtYsNa03k4jU+8EoTtWWeoWDFHs YMYeZVdpNGelkjuVf8L78qzFpmgFdJI7n65125pwIIYo2kQN5HCnwJcWwpmqIcSzXhW7 1LacaPhJpdZHZQaIE2TVf/f0C9PFa9MQocq0o5QCtv6//t6DxdKxjMwZ/wFsXrpTVTFk i73Dd1l11amTbRmUrmh9ZC3thCbnKzVw6W34KnxiK0URk00GpKi9V1bnfEXy/thRMn1X 0YcQ== 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; bh=KXcpCjGz22SWMR7OFbK0KarqXEiWIfe+gg821WhNiG0=; b=cojmwfXEuwuLIxKhOqYlhRdMr/HHSLag+8XNyh5kpqX7wZSZwiSatEMeffShDtJynV KHXBDk6OhKXKTUa+Kna6SpkY5jv3PHV/KJe1320yNtcTQt+1A9l9Prtr16MoZkXNA5aj nzXCxa5I2LVn40vURRORYd+fzq8g4onkTkshWZCBKuc7WVoXG5+rIa08Oi6BwvAo6B1o zZl/nBtYan4xvQ2Yuj1S1abz1IY2+88u07AYugkmYBHMFk4t+HKzRu5SNN5KKndm6X0X GbyBhfdI9yQVwF8/1knVyPVTIkPS12UW2YwNUrgVlwZrsU7PVdjVwETR9e8QCH0qKCBc 2+Dg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qk11-20020a1709077f8b00b0078dad659776si7336566ejc.320.2022.12.03.00.58.20; Sat, 03 Dec 2022 00:58:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231601AbiLCId0 (ORCPT + 83 others); Sat, 3 Dec 2022 03:33:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229781AbiLCIdX (ORCPT ); Sat, 3 Dec 2022 03:33:23 -0500 Received: from gw.red-soft.ru (red-soft.ru [188.246.186.2]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1D753209A9; Sat, 3 Dec 2022 00:33:22 -0800 (PST) Received: from localhost.biz (unknown [10.81.81.211]) by gw.red-soft.ru (Postfix) with ESMTPA id 209713E479A; Sat, 3 Dec 2022 11:33:20 +0300 (MSK) From: Artem Chernyshev To: Vishnu Dasa , Bryan Tan Cc: Artem Chernyshev , VMware PV-Drivers Reviewers , Stefano Garzarella , Jakub Kicinski , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH v2] net: vmw_vsock: vmci: Check memcpy_from_msg() Date: Sat, 3 Dec 2022 11:33:12 +0300 Message-Id: <20221203083312.923029-1-artem.chernyshev@red-soft.ru> X-Mailer: git-send-email 2.30.3 In-Reply-To: <702BBCBE-6E80-4B12-A996-4A2CB7C66D70@vmware.com> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-KLMS-Rule-ID: 1 X-KLMS-Message-Action: clean X-KLMS-AntiSpam-Lua-Profiles: 173907 [Dec 02 2022] X-KLMS-AntiSpam-Version: 5.9.59.0 X-KLMS-AntiSpam-Envelope-From: artem.chernyshev@red-soft.ru X-KLMS-AntiSpam-Rate: 0 X-KLMS-AntiSpam-Status: not_detected X-KLMS-AntiSpam-Method: none X-KLMS-AntiSpam-Auth: dkim=none X-KLMS-AntiSpam-Info: LuaCore: 502 502 69dee8ef46717dd3cb3eeb129cb7cc8dab9e30f6, {Tracking_from_domain_doesnt_match_to}, red-soft.ru:7.1.1;localhost.biz:7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2 X-MS-Exchange-Organization-SCL: -1 X-KLMS-AntiSpam-Interceptor-Info: scan successful X-KLMS-AntiPhishing: Clean, bases: 2022/12/03 07:58:00 X-KLMS-AntiVirus: Kaspersky Security for Linux Mail Server, version 8.0.3.30, bases: 2022/12/03 05:27:00 #20641058 X-KLMS-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org vmci_transport_dgram_enqueue() does not check the return value of memcpy_from_msg(). Return with an error if the memcpy fails. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 0f7db23a07af ("vmci_transport: switch ->enqeue_dgram, ->enqueue_stream and ->dequeue_stream to msghdr") Signed-off-by: Artem Chernyshev --- V1->V2 Fix memory leaking and updates for description net/vmw_vsock/vmci_transport.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c index 842c94286d31..c94c3deaa09d 100644 --- a/net/vmw_vsock/vmci_transport.c +++ b/net/vmw_vsock/vmci_transport.c @@ -1711,7 +1711,10 @@ static int vmci_transport_dgram_enqueue( if (!dg) return -ENOMEM; - memcpy_from_msg(VMCI_DG_PAYLOAD(dg), msg, len); + if (memcpy_from_msg(VMCI_DG_PAYLOAD(dg), msg, len)) { + kfree(dg); + return -EFAULT; + } dg->dst = vmci_make_handle(remote_addr->svm_cid, remote_addr->svm_port); -- 2.30.3