From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7D0B7C433EF for ; Thu, 21 Apr 2022 16:14:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 13B8760B17; Thu, 21 Apr 2022 16:14:39 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZsQLk5CZTbA1; Thu, 21 Apr 2022 16:14:38 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id B935660B9C; Thu, 21 Apr 2022 16:14:37 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 684B8C0033; Thu, 21 Apr 2022 16:14:37 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 652F9C002C for ; Thu, 21 Apr 2022 16:14:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 3F14660B9C for ; Thu, 21 Apr 2022 16:14:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 05se2aRI8zMw for ; Thu, 21 Apr 2022 16:14:35 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 50E7E60B17 for ; Thu, 21 Apr 2022 16:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650557674; 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=D4jkeh8D3DG6ylcdKCfSz7aO0Yk8nKIdM9V5hvGsEvu7+8XGmYHc0pgEI9veMAG62yx+le jVLjkDwC46P7Q2HJkea4tbOQIepvGC7DORK2hJ23YKyqFrAnvfzjvmBR53hY4hS5n9OWn1 7E+8egSguhKwg0u7AWpyMRAVowG+o8c= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-99-UvXKMgH8MDSRRI1cWFbTGA-1; Thu, 21 Apr 2022 12:14:32 -0400 X-MC-Unique: UvXKMgH8MDSRRI1cWFbTGA-1 Received: by mail-lj1-f200.google.com with SMTP id s14-20020a2e2c0e000000b0024ee4322c6bso1023366ljs.1 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=SLfZvgmeWklI82rHSRlWEYl5z8h3Q8xGNrpdHQXQ9KvphReA1lv45Cd7/PiZhRNiKV IMuAWBGUCwp13n872tYmDcXy4YkjzAU80cNGWIdxOxQK7NJcCPESVD2KJar57/89/hSJ pFbsYfC0JS9px5rFw2X7Y34J0BTLB3WwGAx4YgaFyLLYymWUmH3Ojb2lmsp8ygcCnrzh BxIMAoqsEvDNGhjB8LlPXc3lpAwNQe0mOR4/3Yzoi8gqv1dzRryFdTyxar/LcZNTVlNn ZHvQnYkbeH/+aKAtccMhIZiqj6+wiT4TtpekJxLHbzELBLI1tzh3FThyyTnRS6/v37t7 8cfQ== X-Gm-Message-State: AOAM531ya6XcfUV1KKAczAluuDti09zL0ndL4YoUiGuhr+/7uUJgpt0O X2Cy8x4xYcutw1XjP39R/1HwQPJGe+0u1Xw4JyTkJB9VRBMKQbo6c9h5Ywgk+zo4/WmBYgHutHd /PEqKTw1CLNi6GCCn38WtZhZc4JAiNo4iPXapitcmuDHqny1grSdC+L0RIA== X-Received: by 2002:a05:6512:68b:b0:471:d466:979b with SMTP id t11-20020a056512068b00b00471d466979bmr145642lfe.519.1650557671049; Thu, 21 Apr 2022 09:14:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyH8/DjjuvvyMkckIHc+m1v/FBNR0YvL8JTrt6ayXJd/rtn7oBKbgJ1GEaT0nlskTay3z63zTKH5i8fe1g198I= 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=sgarzare@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: Wei Liu , Paolo Abeni , Stephen Hemminger , netdev , Haiyang Zhang , Dexuan Cui , linux-hyperv@vger.kernel.org, Michael Kelley , Jakub Kicinski , Linux Virtualization , David Miller , kernel list X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" 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 _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D652CC433EF for ; Thu, 21 Apr 2022 16:26:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230127AbiDUQ3E (ORCPT ); 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-Google-Smtp-Source: ABdhPJyH8/DjjuvvyMkckIHc+m1v/FBNR0YvL8JTrt6ayXJd/rtn7oBKbgJ1GEaT0nlskTay3z63zTKH5i8fe1g198I= 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" 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