Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5698261rwb; Mon, 5 Dec 2022 02:55:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf7b1xAeN/FGe1LbmKWy5Cku2q/MV+QC/Ujm8Xg9zS8nQEhS2CniCSllYEeSdvDvyqzQZkTI X-Received: by 2002:a17:903:240a:b0:188:abb9:290 with SMTP id e10-20020a170903240a00b00188abb90290mr64060776plo.86.1670237714002; Mon, 05 Dec 2022 02:55:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670237713; cv=none; d=google.com; s=arc-20160816; b=w0S8Mt2F1s9n0LZc1zINVwS+IhVPhYHA138NKonLjPN4p4aWXrXP0dNh/ZCuiKI7gP mxm29QWWmN478imyFLZlrJAWnw1g+g0O3YTtX2IQNdckd5R0WlqxFe0v/EhvZ6tXB46z B8BOaj9mje+vErxPgU5k9TLHuxLHyrK2V9fpH7KTjniDIKeEkGWxxUukqwjLkt9ESNup XYPGpFSFVt72ZRFzY6ZDoTLoTQvyc7y5UjyJFNCQiaMqH8tIRxxe3+tt2Cdr4DRSCCA3 jLNO9jQbg+6DP5n/k/yMuPW+mMd8fPuVFKcsBfiI38tt7lamUuNAhx+jySvImFlAm4ob 6+eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=IcvnyLKDgnT5EwGdRxoCJ/l5uFVnluQmDLioHt8iGWE=; b=PSkeFK/t/7lSi3si1MKkCVodEIuYe8U5GF/oXsgKUkWyL1am1qKPPGGmXpYYSNWVMJ zKaronsuPCn2WpzjBiJrVxr96olloxwrkY6OmfOAhO+JKj3jdwlUcIS5ZChvYScLquYr F62hMtuTx1o8eLRX+2hHhVfEK/xB1woPrUtC6JAkrhFpGKgYXsrD1l/VM+3XxaTvgGvy WCJg+43frocRb+TX4xDbPmkj2EVcIT6iLunShyX+5FdofTkVO+ad4mYN8swQ1SMUWL+Z 43I1fXXtMF0LmuyLXmV5K4gHjTYVC4jcbEKIHFeoVh+HKPnS4LbHXrSWeaqp6WjYUWnE m3aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M4MoF8Zi; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c18-20020a170902d49200b001898e06ac4esi15429005plg.553.2022.12.05.02.55.02; Mon, 05 Dec 2022 02:55:13 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M4MoF8Zi; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231488AbiLEJs4 (ORCPT + 82 others); Mon, 5 Dec 2022 04:48:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231454AbiLEJsm (ORCPT ); Mon, 5 Dec 2022 04:48:42 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B9E110AE for ; Mon, 5 Dec 2022 01:47:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670233665; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IcvnyLKDgnT5EwGdRxoCJ/l5uFVnluQmDLioHt8iGWE=; b=M4MoF8Zih7RlM/aZzhWm4NqAFN+GciVNM44hmiVPBTKUXuN5yF91olQn4pGNzTRbS+OWpi R8Gl4Kk+tgpUcQKUxHbnnA702JXGPvi6XGshvHXQ6XdcEVaKaMfsHkLOt3ZRL8fU3we+1L +HBT6tkypR2Rx5cGRuK4Gcipf1nxAfE= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-59-2tqt99egNrWc-wvDdOQpZw-1; Mon, 05 Dec 2022 04:47:44 -0500 X-MC-Unique: 2tqt99egNrWc-wvDdOQpZw-1 Received: by mail-qv1-f71.google.com with SMTP id w1-20020a056214012100b004c6ecf32001so28743323qvs.8 for ; Mon, 05 Dec 2022 01:47:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=IcvnyLKDgnT5EwGdRxoCJ/l5uFVnluQmDLioHt8iGWE=; b=S7yyDS9u9JTfkiMSCmHMnDhzdCR1sr9yLSAieltyCTxRXC7u+WP01hjAq051ruIXxC N6hwennBDz9ceIqtW6nsxbBeymegHwS2dvWSuzxAuZNiCp9jNH1uUlsJiwygF3mr/bLH o0i+lGX4E9g7bX/fawE+1YKmSpgJUJ8EwgR2p/AHGhVmodjSguvFIe6pQpjgA1QXkGdX T2LKETTV3MaUeuyq+Scu/CQANwRnr0ocCV8AvO5nv4NGpgrx6aj3zlcc0XAo/s1uwFYp EbFH0C4pb64uBm2LR/Q3hvjjqIUyksG48ysxShtaEJnwFMV4wGzwwBZcv0q7gVXZIVPF ZKqQ== X-Gm-Message-State: ANoB5pl68u1HOHJoswE3sDoZuDYHswEB6/BqiCldMAr1UuWqWl3o3WfI 4uyEFftrDK8ifk1JO20KQF9YFngxuRVqnGzC5Uu4SlGcD8S/m/7ZP70PIftIwebulHXeaZ5SbKl tyNZbymOaKvh4lH2Xmu3FwgNs X-Received: by 2002:a05:620a:13ab:b0:6fe:b81b:b34d with SMTP id m11-20020a05620a13ab00b006feb81bb34dmr3591726qki.670.1670233663913; Mon, 05 Dec 2022 01:47:43 -0800 (PST) X-Received: by 2002:a05:620a:13ab:b0:6fe:b81b:b34d with SMTP id m11-20020a05620a13ab00b006feb81bb34dmr3591720qki.670.1670233663688; Mon, 05 Dec 2022 01:47:43 -0800 (PST) Received: from sgarzare-redhat (host-87-11-6-51.retail.telecomitalia.it. [87.11.6.51]) by smtp.gmail.com with ESMTPSA id ay40-20020a05622a22a800b003a57a317c17sm9285578qtb.74.2022.12.05.01.47.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 01:47:43 -0800 (PST) Date: Mon, 5 Dec 2022 10:47:36 +0100 From: Stefano Garzarella To: Artem Chernyshev Cc: Vishnu Dasa , Bryan Tan , VMware PV-Drivers Reviewers , Jakub Kicinski , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, lvc-project@linuxtesting.org Subject: Re: [PATCH v2] net: vmw_vsock: vmci: Check memcpy_from_msg() Message-ID: <20221205094736.k3yuwk7emijpitvw@sgarzare-redhat> References: <702BBCBE-6E80-4B12-A996-4A2CB7C66D70@vmware.com> <20221203083312.923029-1-artem.chernyshev@red-soft.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20221203083312.923029-1-artem.chernyshev@red-soft.ru> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 On Sat, Dec 03, 2022 at 11:33:12AM +0300, Artem Chernyshev wrote: >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; Since memcpy_from_msg() is a wrapper of copy_from_iter_full() that simply returns -EFAULT in case of an error, perhaps it would be better here to return the value of memcpy_from_msg() instead of wiring the error. However in the end the behavior is the same, so even if you don't want to change it I'll leave my R-b: Reviewed-by: Stefano Garzarella Thanks, Stefano