Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1135528rdf; Sat, 4 Nov 2023 07:46:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEN+z86weTvz82uH+pNSOlMVln3I/xZ3bF/5pvqbzOaWZU8wFD46X0SEHNxv15vlvMx18k7 X-Received: by 2002:a17:902:b489:b0:1cc:be6b:80fa with SMTP id y9-20020a170902b48900b001ccbe6b80famr1162069plr.12.1699109200228; Sat, 04 Nov 2023 07:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699109200; cv=none; d=google.com; s=arc-20160816; b=BVIx0DnD6M55T8BSKiiiySrZJeauAnxhfZ2K30lLy7U9m643ycRDJm3hcU8/SmRht2 QKY9B0bZ3m4i+IjuMIei34a0oM6c+hGBipf9bVG7Zqr7CBT3F4HT2dCwhi6/RhZ8aelB ml9qdglXVflb0fK4sN/d66rFknL8A3CwE6rur7jAg+Sfm9NywZU45W9nGU5N9tgSpCou JJekwlI0V6HIfjiI20HpKNl//RDBSSLBfeG9TFGHT8FnXR5x413ceNMNC7RR3FZyrB+A wQOgCj7FBClqTQ7mjSsx/SBEaYeRNVedB+J3+TUutsb1qtYNRfPIjCeKXJXT9kiY5AP5 dxtQ== 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=Vglbr5OscBwmzXeDr7ryPvhrzWRRWsVXpMVy/3stZxs=; fh=2YKzA2yVQd7HuQq3hOkoZhBH8PGg5ags6UDKgwNkN4I=; b=Ozwsq21bI4rp2mOWvNoBrId3dIrFCMoYx49DcFsaSGYkq6LqyAiTmKMpG5mubdheiT cxuTUUdhNo+MZnbqyl+DNvX/gw+VYqUlhtdl9xNdik+7e14Fy+lYRySxLLJm74FxJ794 JFgdco65CEuC89Jut9JECShPwZJMqlkx95fIXyfmgsGEUMrg/ul38z/8mhxsPNJzdQtY Byw/D0PRPyHDHmqhTkbh2Ii9Yw6wNDMLGuX/zLZrfihuu0vaeBsNdH2xJ1S3+6pBUAMi ugBMDgyzngzDVo95j0T6H3VLzVB8+/o2K4YY4uW1X2CHYAUU5ALqMvPvzMlSyJAy4Hno aTmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=K2szq9Va; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id oc14-20020a17090b1c0e00b00276b35bc424si4212783pjb.26.2023.11.04.07.46.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 07:46:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=K2szq9Va; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 8C9618095664; Sat, 4 Nov 2023 07:46:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232231AbjKDOqX (ORCPT + 99 others); Sat, 4 Nov 2023 10:46:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229620AbjKDOqV (ORCPT ); Sat, 4 Nov 2023 10:46:21 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17E531BF; Sat, 4 Nov 2023 07:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=Vglbr5OscBwmzXeDr7ryPvhrzWRRWsVXpMVy/3stZxs=; b=K2szq9Vaf0baMpHPaet72S7gAX NY7TsMRGmHSDRdpMRbHdpzKIEMm4nvW4upJD6DHOvaCpqxKDD25G6CkzSIfaSE6E/MjpM8+6jv91S WSW9qQpbvErgsQ9dBQ5vCNXnnRsLVQm0nsXJsXVtc/COKRYLrabAJ03zKJ4bqwE8pZ6g=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1qzHub-000sOR-PD; Sat, 04 Nov 2023 15:46:09 +0100 Date: Sat, 4 Nov 2023 15:46:09 +0100 From: Andrew Lunn To: Linus Walleij Cc: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Vladimir Oltean , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net 3/4] net: ethernet: cortina: Protect against oversized frames Message-ID: <39debb25-bf30-4ede-99b1-d9f6091a039c@lunn.ch> References: <20231104-gemini-largeframe-fix-v1-0-9c5513f22f33@linaro.org> <20231104-gemini-largeframe-fix-v1-3-9c5513f22f33@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231104-gemini-largeframe-fix-v1-3-9c5513f22f33@linaro.org> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sat, 04 Nov 2023 07:46:30 -0700 (PDT) On Sat, Nov 04, 2023 at 01:43:50PM +0100, Linus Walleij wrote: > The max size of a transfer no matter the MTU is 64KB-1 so immediately > bail out if the skb exceeds that. > > Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet") > Signed-off-by: Linus Walleij > --- > drivers/net/ethernet/cortina/gemini.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c > index fd08f098850b..23723c9c0f93 100644 > --- a/drivers/net/ethernet/cortina/gemini.c > +++ b/drivers/net/ethernet/cortina/gemini.c > @@ -1156,6 +1156,12 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb, > mtu = MTU_SIZE_BIT_MASK; > } > > + if (skb->len > 65535) { > + /* The field for length is only 16 bits */ > + netdev_err(netdev, "%s: frame too big, max size 65535 bytes\n", __func__); > + return -EINVAL; > + } > + The caller of gmac_map_tx_bufs() is a but funky: if (gmac_map_tx_bufs(netdev, skb, txq, &w)) { if (skb_linearize(skb)) goto out_drop; u64_stats_update_begin(&port->tx_stats_syncp); port->tx_frags_linearized++; u64_stats_update_end(&port->tx_stats_syncp); if (gmac_map_tx_bufs(netdev, skb, txq, &w)) goto out_drop_free; } So return -EINVAL is going to cause the skb to be linearised, and then re-tried. Maybe you want to check the error code here, and go straight to out_drop? Andrew