Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp954385pxb; Fri, 22 Apr 2022 15:13:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLNfeiOWaiK5VPLiTgQGM4nmRT/6i9rlOombuRDgEnf/UZrFmVU3Vl1owq03zgqyB1mr7D X-Received: by 2002:a17:903:40c5:b0:158:b603:ab10 with SMTP id t5-20020a17090340c500b00158b603ab10mr6705781pld.124.1650665631549; Fri, 22 Apr 2022 15:13:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650665631; cv=none; d=google.com; s=arc-20160816; b=JIv38GoKm3TSPR/eNZDpLoEZG694NaTsETTeCmq9dklG2AzUjyVcpn3BPZ2o1yBG2c r0FXTwEzyKT/Yk5dThXdBhpsuBVeEHO/E5q/Y0FyKC0V+NwxQFhTnDrrXPUv2xDTAX3f Dlyn2rixY/Ayh0kj8TEifZ8xSws4/b+iA3WpxiE0deojuaiNV2oDJ/biGmOyIyh0Dg5D mp9qOZD9O2VnGNeBVQOzSENSmKUVNoLsQ1omXHykDFDIO20jBjGjMAn4BT6XJ9arsQ9f cz0g0+vpkDm6rEDMu+tBFEoibs3HWdHzoxBE5joCc8m+mPmGWRxWhx6kibsv3LJGTyQo k9hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=1ngZ3ZDY9ywW927Z5RN+MQNpAIO8k9NmG/nkTnk+1Gs=; b=czcbf01mld23ffB2/3I7gJiMAs3kd0H+VXMgtQq5I6Pidm2o3grEq4PWxhEUMG+yDE hhl0BwWF1DIEZ2H9VCEgtOIc4RvzOV9tZpQ447Ak4nQvy8yq5udWShyJ1DNvTF7qzi12 hKW2CAIu2S3AFUKVyHmdgDzf0AOFRE4C1oUwyA/yspJRdQ8JVKfPAqO1ICjxiJo4HsoF dpperT/0ICBsQYCTFExp1yu1PskevgukcrW/7jmOuDv/aT4EmvbWRQgvLsrRm83yF7Rm H6VOFLj4Cuvi193iLC5NXMyGkqhw41Qbtxlq/leXUcOStnbEXAfxL7sQRtz0up9rMvE3 bjcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="RQV6R/OB"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b18-20020a056a00115200b00508360cea5asi9624124pfm.295.2022.04.22.15.13.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 15:13:51 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="RQV6R/OB"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D509B3A494A; Fri, 22 Apr 2022 13:19:13 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229673AbiDUQ3E (ORCPT + 99 others); Thu, 21 Apr 2022 12:29:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231679AbiDUQRY (ORCPT ); Thu, 21 Apr 2022 12:17:24 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 85F3F2B24E for ; Thu, 21 Apr 2022 09:14:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650557673; 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=1ngZ3ZDY9ywW927Z5RN+MQNpAIO8k9NmG/nkTnk+1Gs=; b=RQV6R/OB43yQqrkm5oggp9zm3OQVzwmouCHF2z78ixodK8OWZ+73QtiVn5v5sLXs/47n/e LBEFsbpvqxHeeZj870spCCxizcQfMiXe9l8nIRG/ZqVnUtZVauDPYTWM8n3jqP48B57MtD I1PDHote2fMra8vv+o1SdBPcIs4Yu+I= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-282-C-KLB3WxNg2XuWs8uBQeAg-1; Thu, 21 Apr 2022 12:14:32 -0400 X-MC-Unique: C-KLB3WxNg2XuWs8uBQeAg-1 Received: by mail-lj1-f199.google.com with SMTP id e3-20020a2e9303000000b00249765c005cso1689192ljh.17 for ; Thu, 21 Apr 2022 09:14:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1ngZ3ZDY9ywW927Z5RN+MQNpAIO8k9NmG/nkTnk+1Gs=; b=nKUVr3nlGjaIv3HWWZo07VB5F3lYJLp1HgfhCw7soKawSlkLni6GsJ8ncbY0FC0z9i nuH73gGyQz0HgoXJwn/BPU12PkMWpcOALBrsJ21zwcQy+moTW/hVygpDGFX93VxO+dcW jbOi2eJ3pVMob5POUA9532b0Xu1PhuHrZx9XoXK041yEDKlc95295zw6JQMHkZqsFJtt XQt+i5JxU+A3gf0L2lq5l3Hr+gtno6X4La22/oUYkyAb6Je6YPhv/jpIpha9OKZnfTgu /Ufp0EG4v7NOhxv7KmUet49f5ythQuU5e/BWSRq7HukkT3zr9w4QyFxq8cWDoJnmMwfY D7rw== X-Gm-Message-State: AOAM5325AJi1G5O0iLrHj9P/GvpMwaDnms4vrLTaPPrWyYLtsRaWQA+3 LxTlSdJ/VwU8k6Ea8udPV7nIwkfNgaTKnRI5hm+y180YQ/I64DtPiRiTSeSad3Xmpx2iaHKOcyQ YLTtUm8/VkfKK6et0j+YvWtxHLKmy15lVuBDJ70uu X-Received: by 2002:a05:6512:68b:b0:471:d466:979b with SMTP id t11-20020a056512068b00b00471d466979bmr145638lfe.519.1650557671047; Thu, 21 Apr 2022 09:14:31 -0700 (PDT) X-Received: by 2002:a05:6512:68b:b0:471:d466:979b with SMTP id t11-20020a056512068b00b00471d466979bmr145622lfe.519.1650557670855; Thu, 21 Apr 2022 09:14:30 -0700 (PDT) MIME-Version: 1.0 References: <20220420200720.434717-1-parri.andrea@gmail.com> <20220420200720.434717-4-parri.andrea@gmail.com> <20220421140805.qg4cwqhsq5vuqkut@sgarzare-redhat> <20220421152827.GB4679@anparri> In-Reply-To: <20220421152827.GB4679@anparri> From: Stefano Garzarella Date: Thu, 21 Apr 2022 18:14:19 +0200 Message-ID: Subject: Re: [PATCH 3/5] hv_sock: Add validation for untrusted Hyper-V values To: Andrea Parri Cc: KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Michael Kelley , David Miller , Jakub Kicinski , Paolo Abeni , linux-hyperv@vger.kernel.org, Linux Virtualization , netdev , kernel list Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 Thu, Apr 21, 2022 at 5:30 PM Andrea Parri wrote: > > > > @@ -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...) I see the warn here: https://patchwork.kernel.org/project/netdevbpf/patch/20220420200720.434717-4-parri.andrea@gmail.com/ in the kernel doc [1] we still say we prefer 80 columns, so I try to follow, especially when it doesn't make things worse. [1] https://docs.kernel.org/process/coding-style.html#breaking-long-lines-and-strings > > > > 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.) Yep. Thanks, Stefano