From patchwork Sat Nov 4 12:43:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 161582 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1625355vqu; Sat, 4 Nov 2023 05:44:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHevcOwqaWv3aL7yixTvnP75yHT3sES++RIzEOqVG/5AGj77XMCXu+su5vgNrUvJEi4ocPx X-Received: by 2002:a05:6358:c82:b0:16b:3cc0:4fa4 with SMTP id o2-20020a0563580c8200b0016b3cc04fa4mr6951876rwj.30.1699101853228; Sat, 04 Nov 2023 05:44:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699101853; cv=none; d=google.com; s=arc-20160816; b=nqegeN1bCFmhjSPGY0/NkrnwT/yyXH93lxCGQckmViiKhpkt7EkVFxxe91ySR4PQw4 J5lnD7vsqruknjru4fXKBPklL1GH2L6Z0xRHaPrjWzubOBXtLUxWgmH0a+KqX/UerEYB naNAoF2aryaaUILk1bYUsj9LvZTU57243xdUd1YikxZ12tYQG8HWmWV/KtBcNgBUrHci WhQLsQOw4AZ8NTbL1qrK7lBWcGJhrvFn1t8X8k1YeYciHHc4GW0Xk7jhVdnT5Z9OC3W7 Q1e7EEmL7tvB3Ihi2MOByPjZZKm6K7XrnI4Jwt9lgmXJxlSZ5O+DnAFG9DH4dnEVkhYI yNkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=vbrVElpE/LRcXL9QrTPOXjtUB0U3i3Et1aitWER/TV4=; fh=bYuvYY+UAm+RKkoLNBZQ9/NmrCpqb49Mw9RYUbh+sKg=; b=HjarZjjcGgm6UkpFYuD2iCgE5ZJGvb6HpqWAXFMxqvUCnTz56CngOhAT6cIJaBcQhc g0CGG5CgzwzgtFDmVYYPHWorB2Tf1LFO48apRX8oAPDChJvEY2VMcA9ab8i5AghVTfJb aBYD/kTwz4sB79j6IEk8R055UkSPEskR2jRA3Le5wnbL67o+/h6DL63JXEtJNyd8S3le rc14vRwgek5kAfMf2axEyV6ZR8Ht5geWtJSxyqDkoliH46+2+vIv8MEHmF5ysO/r921z ZYWcKTEyXfRQ+YvChB9RNohj4/l/xJq3+CTknUIybYl15m9psxRb1XwSUYmeq245XmFK O+Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yy3Uh94e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id v64-20020a638943000000b005ad8009e304si3647031pgd.784.2023.11.04.05.44.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 05:44:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yy3Uh94e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 538FA8040EAA; Sat, 4 Nov 2023 05:44:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232003AbjKDMoG (ORCPT + 35 others); Sat, 4 Nov 2023 08:44:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231655AbjKDMn6 (ORCPT ); Sat, 4 Nov 2023 08:43:58 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F1BC1B2 for ; Sat, 4 Nov 2023 05:43:55 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-5079f9675c6so3866973e87.2 for ; Sat, 04 Nov 2023 05:43:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699101833; x=1699706633; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=vbrVElpE/LRcXL9QrTPOXjtUB0U3i3Et1aitWER/TV4=; b=yy3Uh94eo9ISIt7N3igeFW2Yn93KkptUPRKaRqm3tc95Hckgfob3SSvrYpMf9QyCGR /ae+NOo9o1uiKrgwVONTOQBO72lMiC6bN7n66oLerfIJ2I/pwJf4PL+f1sF4ft/CzB0q /vGTbxUE/lgnK+bCgP8P6nnnbRAfQ5vUMmbvxEbiwk7Ufef3G2Y2cwbrKgDi7uFTXeWq Tl+YJTVcdLA0SJ1cmeyRz6t7l71Mut7g0W2F1R1BkYG3Mh5t6LJAOHYgL7vq+UbZzA6B RIpTv+c4wD/6J1i/g0A9G0YrT01GB6ZUz5UeMOex12P0p0QTCWR2HYVXuPqifCHvn7NV Cm+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699101833; x=1699706633; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vbrVElpE/LRcXL9QrTPOXjtUB0U3i3Et1aitWER/TV4=; b=ni/9i3PpXzZP2jHCv+AUTLo1sM1xGY1AZcTAOCDrvh8ZpNM06SWurMfgGPjzB/yYIA ACHhW8E9sUr5GakJZvTtEKV9IfzJpKi9m0HjajVkWbPObRJwhxVV/yRvinIA5wc3Tg0E t2WUAzYXFtEUyQA+PUTRVjeirrrWPt2bKTxe2FwpbBxb7zFe/2QBcTgPBYA2i/05d4cG 7tppPhviY7sqICcnlAAj1pK88Y1qd3Iniz+oQiGuwY3Rn4ExbjAX5VHt8DuzrnXkDIDZ AjXBwMpcME0no1Fo1ZG0xM/aNN4zO+3mIYYMr43mpNVQFvl1j9+BRcJl1MJn+V+oDHeo doow== X-Gm-Message-State: AOJu0YzV0ZEzoJkAzz3NO1tgYTbVBDDsZYGalYrAgxh/nK/77ZXR6IHR hdy+y6kY4GjX+ml0ARTsAs56GQ== X-Received: by 2002:a05:6512:b93:b0:4fe:347d:7c4b with SMTP id b19-20020a0565120b9300b004fe347d7c4bmr23951283lfv.7.1699101833426; Sat, 04 Nov 2023 05:43:53 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id u22-20020ac24c36000000b005093312f66fsm496100lfq.124.2023.11.04.05.43.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 05:43:52 -0700 (PDT) From: Linus Walleij Date: Sat, 04 Nov 2023 13:43:50 +0100 Subject: [PATCH net 3/4] net: ethernet: cortina: Protect against oversized frames MIME-Version: 1.0 Message-Id: <20231104-gemini-largeframe-fix-v1-3-9c5513f22f33@linaro.org> References: <20231104-gemini-largeframe-fix-v1-0-9c5513f22f33@linaro.org> In-Reply-To: <20231104-gemini-largeframe-fix-v1-0-9c5513f22f33@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Vladimir Oltean Cc: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sat, 04 Nov 2023 05:44:12 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781637424460664392 X-GMAIL-MSGID: 1781637424460664392 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; + } + word1 = skb->len; word3 = SOF_BIT;