Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp965462pxb; Thu, 21 Apr 2022 14:45:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjfLuTXQ0pSVXt3HgnCoWzF3Pes5+q8wf2DAhfBkd4mnmYtyGdtRYx4Pr5fzmBG+IaOg9+ X-Received: by 2002:a17:906:4546:b0:6e8:873a:22a8 with SMTP id s6-20020a170906454600b006e8873a22a8mr1304801ejq.711.1650577535886; Thu, 21 Apr 2022 14:45:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650577535; cv=none; d=google.com; s=arc-20160816; b=M76c22hB1/gianWfTD8RjUXzGWebkIeRJSVA97j2Ybe+CSZm00rvxBb7wfQy36b9qw nL6uMlIbdDeTmCB5VcPasawpW97hsajf+MfdH/ZBPfOJxMv3BNd6xSlR7lH/0VKZ4Gt2 49hf6nxU4oRRiKvRmZV9tJfWoIGyqzd3o3ablgmYzmjuLWm/HUBa6ez2ECXGjQVA7Awi oxf13ec+9Z3+QnJL8PW/X75OAuCRE0Uy8/oXbazDYztXYj3DPYqwWRfwL9j7MjGj2/0/ djiNAH9fIg76SK1cQ582ACThj2GnfDRy0SUWA1szjnZmREcArP9ccaaUsd2nEZEq7+x7 w1Cw== 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=huQqspaZHPvV/8IOlr6z6gZgnSzIiLdiEX7SuuM2584=; b=Fp5dm4MzpDatk+FQyZulyIFkatwMWNO3/Yq8KXccrj6ahk/hO0TpfgT4e85wydSjmT ESRKzNmvCCXjlj5CXX/U/sGs/A8h9YfD4uti/tRFdPR97LFvjEkvE38pR7sBXWmoumFi rEeaDjc4ceTvP63hAUSVsJV7eb3ddFAY7lh1lZmFEzAbCBM0PGmPvoCk5CZK5TBAoJeQ SLjwQn6nP9Rh4VsmDDjPcAPFSgMR0ZaBdjU+/B2lYYMN05+8aJZg0nKOyXdBzP++Qht5 G08GBtglbdw6MAHEVKM/tQQv6D99V2uLCGLWOFPWohs05XigIBxORlFgNy7eLTVApYkb j/4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=G7tH+56q; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h14-20020a056402280e00b004239aa67363si5766341ede.191.2022.04.21.14.45.11; Thu, 21 Apr 2022 14:45:35 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=G7tH+56q; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390112AbiDUPdd (ORCPT + 99 others); Thu, 21 Apr 2022 11:33:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345052AbiDUPdb (ORCPT ); Thu, 21 Apr 2022 11:33:31 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBEE265AF; Thu, 21 Apr 2022 08:30:41 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id lc2so10755554ejb.12; Thu, 21 Apr 2022 08:30:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=huQqspaZHPvV/8IOlr6z6gZgnSzIiLdiEX7SuuM2584=; b=G7tH+56qA4f9NTwapDG+DLXd06PdDvJdLtVjhiBrgMxFwbfmKNbeILawc7wQBAW8J8 TMUN2fHEhgyyK02LQme1FcI4Ot2S2kn0oZQypIDi5IuoQCNoofWKNPBoq/MbCnirQ3iN E2q+rkJE+0AxG5KvBy622bjkL+5B0S2aFcT1zexE6i0Uk+Yyvv6TATPdhsw3eAQvzoX/ 8Ao8uZ/vUwixk4DopyvSmYrPPhaX71JXRmoScz80JYsmzBI6v2brUcYks7IS5Pes7lfI tVRX8B1E6PX3z+ce5Ni2h5UlfAtDUxVMn7NQwm4g3gOzi5cjb1y+lhhhFaD2VwxSBngz HKkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=huQqspaZHPvV/8IOlr6z6gZgnSzIiLdiEX7SuuM2584=; b=cB61EpsUlJainHKbvbby8NyPUrT8jvz58WQDFnHR6ft0O5xrXoj5vPmf4A/HrEYkvR h80fVMVL8D8ESaot0Y/B0wskWe7tV99EwEEjp3PQU0OqxVlqeeqopeulXqwAW1R+ulit QuBlt9vKjiF7bH+hxK+rqvIRXkC4W2ABU3gyxyVdys9PBr2VgBrVj/vVQLHGvjDT0V3t NdBv3zLttYo5WOSVHu19sWMIWMB5Rd84ei4NHsInI1Xypq9N4iMOPq0ybIfaeaJgZGD3 aVvHBEN1cD1fo1npAgibVSvXv4xwXlDaG1hElmrTZyazJtjlCVY6ED+Jlx9nSMYRj+tN /OGA== X-Gm-Message-State: AOAM533ek2cURIQOJahG55+26r8G+9/rrrpPCQUbQSh5lHF6gsSSc32w hF0RhpgTF+JrstO/5nreCVM= X-Received: by 2002:a17:906:7950:b0:6f0:e53:a864 with SMTP id l16-20020a170906795000b006f00e53a864mr123481ejo.0.1650555040435; Thu, 21 Apr 2022 08:30:40 -0700 (PDT) Received: from anparri (host-79-30-22-114.retail.telecomitalia.it. [79.30.22.114]) by smtp.gmail.com with ESMTPSA id bl20-20020a170906c25400b006efeef97b1esm2546120ejb.206.2022.04.21.08.30.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Apr 2022 08:30:40 -0700 (PDT) Date: Thu, 21 Apr 2022 17:30:37 +0200 From: Andrea Parri To: Stefano Garzarella Cc: KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Michael Kelley , David Miller , Jakub Kicinski , Paolo Abeni , linux-hyperv@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/5] hv_sock: Add validation for untrusted Hyper-V values Message-ID: <20220421152827.GB4679@anparri> References: <20220420200720.434717-1-parri.andrea@gmail.com> <20220420200720.434717-4-parri.andrea@gmail.com> <20220421140805.qg4cwqhsq5vuqkut@sgarzare-redhat> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220421140805.qg4cwqhsq5vuqkut@sgarzare-redhat> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 > > @@ -577,12 +577,19 @@ static bool hvs_dgram_allow(u32 cid, u32 port) > > static int hvs_update_recv_data(struct hvsock *hvs) > > { > > struct hvs_recv_buf *recv_buf; > > - u32 payload_len; > > + u32 pkt_len, payload_len; > > + > > + pkt_len = hv_pkt_len(hvs->recv_desc); > > + > > + /* Ensure the packet is big enough to read its header */ > > + if (pkt_len < HVS_HEADER_LEN) > > + return -EIO; > > > > recv_buf = (struct hvs_recv_buf *)(hvs->recv_desc + 1); > > payload_len = recv_buf->hdr.data_size; > > > > - if (payload_len > HVS_MTU_SIZE) > > + /* Ensure the packet is big enough to read its payload */ > > + if (payload_len > pkt_len - HVS_HEADER_LEN || payload_len > HVS_MTU_SIZE) > > checkpatch warns that we exceed 80 characters, I do not have a strong > opinion on this, but if you have to resend better break the condition into 2 > lines. Will break if preferred. (but does it really warn?? I understand that the warning was deprecated and the "limit" increased to 100 chars...) > Maybe even update or remove the comment? (it only describes the first > condition, but the conditions are pretty clear, so I don't think it adds > much). Works for me. (taking it as this applies to the previous comment too.) Thanks, Andrea