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: 13445514 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 3CA4DC4332F for ; Sat, 4 Nov 2023 12:44:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EwuR7zrU760s1wlY64Tunf/sdw9aqflAfER7xGSFXN4=; b=MbUmLfGaV+s94m zQMF+i320GXRWjY8kr+T9nOyWM8mcHGx2jwRvWhAhdEg74neSYlLryKua73wmUAbJ50Emd3V0UaNw 8UWvmJQ1hneFU04tNNrAPw9Vo+I9hlXCW8KHU3HMNz+6fWPC7B/A2cLWdNRlePUcyTUyI//Ii//Wx C5Ej9LZrMA0rCtRUqwHKH/+b4Gt1aSnzGOC+JVKPDh93ev8pF7pCnxRUXYb0LLsdHS+EQCIXXuSj9 q5kcNTVl23UMMls6YGNavYd7naNIDt+Sb5rmE+ezCk/EaJ9abvWidF5iDaKV4NVzb2gqD5w5dy7G+ ck1cn4JTt7CPDW7uX4Vg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qzG0N-00DPIb-2E; Sat, 04 Nov 2023 12:43:59 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qzG0I-00DPGN-2e for linux-arm-kernel@lists.infradead.org; Sat, 04 Nov 2023 12:43:56 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-5079f3f3d7aso3884420e87.1 for ; Sat, 04 Nov 2023 05:43:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699101833; x=1699706633; darn=lists.infradead.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=qyE7Snj8Uxa/HeV7SygpBjHYg6/e4dP4BuLIsgRA4Ko/Gm1U73KdqHNAB76tPTNCxY Ozo5MTWDZnYzZG3EkzVn8Xs8T+6L4EuljZNhFh645vHQDH1t+pjrDcqLDJ0N81OOnNH2 l6WiBjrL8OteWqv95obD7LXwj+gqD5LocA879Ks/R+TN810K1QBpWlQ8APV1LhHL5tMu nIpdGMz9TY/JjDOkM7kcRI9utQXbEFT/5Y3fVlHtWerAHoV+6QcsTUzjM8Y2DuYjSxvl +/PNCukX+U/kQLHT1TZ9YLYN/sg0yf3BNLbatfO9d6u64VX7RadXfQUrXXgs+i7GVO6G I+lQ== 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=EbMAWdZSxwGM/q9dQnyyJPzSrKJwzTdfANBGAI6oW9KnWwCKZszSnJABo4qwCO2R+Y D8xlrCZ3ihab8DJKGA04zFXF8VUIyzqIxuIxmn4f69I4iBT8xBIHQKoJ+iZoPHyI3woq sRm+XAYEHUkG7JiNTS6KVO18xt3KbcWTYPRBlqfgqz7tT1W4oPWC80YdoQ9iWv8FWo0e eVvYUnISrAhUTJdvpCizcdt5vbQzpdhi754Fxr0ApFIo9HP2nkiUHodEJZf4AauR9QV6 0t8Vw9XaZBhqB+CGs7akcdlN2WX49xmahGvc0VwuLC5+HBBhJ/9FLJ5PFG1eZil9AaMH mL6Q== X-Gm-Message-State: AOJu0YwMGsUUcFTuCmEoGdEBCdUu+DZjRyQ6/+TAlkPrMMlN0tTmLBFp cKQK1P0YtkhKDDiaRD6BkX5Shw== X-Google-Smtp-Source: AGHT+IEOvtUSGS8gPMNB3spqJXMI2GzAA6fdOtLX2o73ozW/2re2ZnkjNq0X0bY0Zzh1Cl/kg6zB/Q== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231104_054354_860344_9AFAAEDB X-CRM114-Status: GOOD ( 11.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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;