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 9AAB2C54EED for ; Mon, 30 Jan 2023 18:19:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237182AbjA3STT (ORCPT ); Mon, 30 Jan 2023 13:19:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237196AbjA3STO (ORCPT ); Mon, 30 Jan 2023 13:19:14 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B99DF75F for ; Mon, 30 Jan 2023 10:19:10 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id z1so5447039pfg.12 for ; Mon, 30 Jan 2023 10:19:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=in-reply-to:from:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=0z7OCBQkdRfuPBBXjvUA3YbaATgJDWrXYVSovCQQBhA=; b=X60NU/FplulLlfCTkuG0WLpSG0TP0r9/aZ4hqoJ4WwZqP3GENI/w3TxehB/QJmVvdF zwPwlrvD553cVoYWt8JUEEctNJFH2Y4jN+mWf0DMujTANoOr8CQf89pP6XcMW7Vntxtm gsX1VA8RvCE6MnbwVyMQ8++7QYpvuvIUOicKQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:from:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0z7OCBQkdRfuPBBXjvUA3YbaATgJDWrXYVSovCQQBhA=; b=vNVusGw+ToLg7SGzb6VBFgYxec04WFhb6G9NT+uHLMB+pOmFwfo2DkcI0EXJTeTfA5 piFDAYRRoABeIv9OUJwPx1dYCAj31EsTJ9mZ2SlLmxKUK5w9S0eFlxmpXFIepLuX8eow Cnw7vISuNfyb52dGB61Iv7o9/YmBUhm4CQubLbwSHo2dCuRY/haNoRWUx7c3p3Mja+W6 m5yTTfzRlYuBY1Po8mYni8HxXwXQ36RoW88z3QVszKRYoK49NSRXwj+Lw4fa1H4lcnCj xjuIXQWF+9fiGviZ3sPyL8+xWk2mJUqGWqBumyJiAO41ulUiIhxxb9lMN6B2EHqWFfu1 ZZOw== X-Gm-Message-State: AO0yUKWfL0Q1zTciR5xX0kpwmEcnrTLfKbxadDv1ZiImIQety7uQmoJp zqR9P1tKsSyDSbh7WUCUU85dwg== X-Google-Smtp-Source: AK7set94aXlKeAJiigHwa3wU5v9/0relxPpcL8bT3J5SEZPRYsCuiisIr+IS6L37Dj5r7kfUxrTANA== X-Received: by 2002:a62:58c2:0:b0:593:c41e:480 with SMTP id m185-20020a6258c2000000b00593c41e0480mr4299975pfb.23.1675102749627; Mon, 30 Jan 2023 10:19:09 -0800 (PST) Received: from [10.67.48.245] ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id t24-20020a62d158000000b005769b23260fsm6595054pfl.18.2023.01.30.10.19.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jan 2023 10:19:09 -0800 (PST) Message-ID: <162b91f4-9334-4941-6d71-8bb9f47a0c12@broadcom.com> Date: Mon, 30 Jan 2023 10:19:07 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH net-next] net: bcmgenet: Add a check for oversized packets To: Leon Romanovsky , Florian Fainelli Cc: netdev@vger.kernel.org, maxime@cerno.tech, Doug Berger , Broadcom internal kernel review list , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , open list References: <20230127000819.3934-1-f.fainelli@gmail.com> <7cbbb800-9999-302a-5ea9-b93020a1e9e8@gmail.com> From: Florian Fainelli In-Reply-To: Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="000000000000602abe05f37f4092" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --000000000000602abe05f37f4092 Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/30/23 02:09, Leon Romanovsky wrote: > On Sun, Jan 29, 2023 at 01:17:43PM -0800, Florian Fainelli wrote: >> >> >> On 1/29/2023 1:42 AM, Leon Romanovsky wrote: >>> On Thu, Jan 26, 2023 at 04:08:19PM -0800, Florian Fainelli wrote: >>>> Occasionnaly we may get oversized packets from the hardware which >>>> exceed the nomimal 2KiB buffer size we allocate SKBs with. Add an early >>>> check which drops the packet to avoid invoking skb_over_panic() and move >>>> on to processing the next packet. >>>> >>>> Signed-off-by: Florian Fainelli >>>> --- >>>> drivers/net/ethernet/broadcom/genet/bcmgenet.c | 8 ++++++++ >>>> 1 file changed, 8 insertions(+) >>>> >>>> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c >>>> index 21973046b12b..d937daa8ee88 100644 >>>> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c >>>> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c >>>> @@ -2316,6 +2316,14 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring, >>>> __func__, p_index, ring->c_index, >>>> ring->read_ptr, dma_length_status); >>>> + if (unlikely(len > RX_BUF_LENGTH)) { >>>> + netif_err(priv, rx_status, dev, "oversized packet\n"); >>> >>> I don't think that it is wise move to print to dmesg something that can >>> be triggered by user over network. >> >> A frame larger than RX_BUF_LENGTH intentionally received would be segmented >> by the MAC, we have seen this happen however while playing with unsafe clock >> ratios for instance or when there are insufficient credits given to the >> Ethernet MAC to write frames into DRAM. The print is consistent with other >> errors that are captured and is only enabled if the appropriate ethtool >> message level bitmask is set. > > I saw other prints in that function, but you add new one. > Won't netif_err() be printed by default in almost all distro? Do distributions alter the drive default message level: #define GENET_MSG_DEFAULT (NETIF_MSG_DRV | NETIF_MSG_PROBE | \ NETIF_MSG_LINK) ? -- Florian --000000000000602abe05f37f4092 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIIQeQYJKoZIhvcNAQcCoIIQajCCEGYCAQExDzANBglghkgBZQMEAgEFADALBgkqhkiG9w0BBwGg gg3QMIIFDTCCA/WgAwIBAgIQeEqpED+lv77edQixNJMdADANBgkqhkiG9w0BAQsFADBMMSAwHgYD VQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UE AxMKR2xvYmFsU2lnbjAeFw0yMDA5MTYwMDAwMDBaFw0yODA5MTYwMDAwMDBaMFsxCzAJBgNVBAYT AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMTEwLwYDVQQDEyhHbG9iYWxTaWduIEdDQyBS MyBQZXJzb25hbFNpZ24gMiBDQSAyMDIwMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA vbCmXCcsbZ/a0fRIQMBxp4gJnnyeneFYpEtNydrZZ+GeKSMdHiDgXD1UnRSIudKo+moQ6YlCOu4t rVWO/EiXfYnK7zeop26ry1RpKtogB7/O115zultAz64ydQYLe+a1e/czkALg3sgTcOOcFZTXk38e aqsXsipoX1vsNurqPtnC27TWsA7pk4uKXscFjkeUE8JZu9BDKaswZygxBOPBQBwrA5+20Wxlk6k1 e6EKaaNaNZUy30q3ArEf30ZDpXyfCtiXnupjSK8WU2cK4qsEtj09JS4+mhi0CTCrCnXAzum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