Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2271610pxb; Mon, 11 Jan 2021 05:42:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvGlbAwsjnz7I0MLM0LAeNO1H9iK8wbFEqzQHEOmAEx+nP+Ou8JdPSiE1ZR4G6hCx2znd8 X-Received: by 2002:a05:6402:2da:: with SMTP id b26mr14342077edx.350.1610372575286; Mon, 11 Jan 2021 05:42:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610372575; cv=none; d=google.com; s=arc-20160816; b=OrUb17lEzyrrC3bNTqRgElmTRs2aAZVVkFYNugObvNnwuC2mGs8+4exI1NYSJv61Wm eQxmdqXaXDfi20+t4ZUIdCMsCNhmjlz3QVe/Dg43WGPpmEIdu5qgqW/XVn7wL3HaSXTi mxSDyiollABiSxgcOakbMQVIXGISBmNzDw0ZP9i3Ki6cwHB/kDVVCu6dUpeZO0H390mj p/m6Y3pRKrd7c/zjdQJmvqvjQ+0k/8Hhh2wOvBbxQulmVAWwi1sXP2BM9ZjWe9IRcvrz oqMRY2PxM+1B8riPHdg5/yokX3EK/0EaIBZMEv1Fgfk7157wyNkl3UmsNi5iqI8XOVh/ Mcfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0XXRoQmwXu7W/90R9VXcTjpV3amGkMwVPuUJsUlHkMI=; b=mrU6X2tIYp0hxkbq2vWn0heC0mjAGEBDUxz2NFJQ3OzbzOUzHOnNmk4BMedhYCxQXP O9BLND4oaL5L8jhHiH70UD054eQlXTwNxHrkBd/QGmlY46MPgiqU/pfTARIOWGiD4kLw +0PK23r3/qLnr8bdXtOUyGoVP/m7ZVp64ZYNNtxzaV4IbrTuvxxrg0pQMkEUJtTmaTN4 ootaXpkRiDIMt/Vpp30suRLyvG78f8RNX8QkTMKIY/DoruOEhdA7liSQhcxTpi1DKmxE 9SwHrfLqVb9uDLRct8pKKC0UCQn3SnxoPri1a1zzndKhE9k/s/wVpqmacKiaDSUqz4jW LB9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1foWbyvy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dh5si6639528edb.122.2021.01.11.05.42.30; Mon, 11 Jan 2021 05:42:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1foWbyvy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731620AbhAKNNL (ORCPT + 99 others); Mon, 11 Jan 2021 08:13:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:58908 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730942AbhAKNMT (ORCPT ); Mon, 11 Jan 2021 08:12:19 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9822821534; Mon, 11 Jan 2021 13:12:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370723; bh=l16RtqhC7S/v30fafAiX2Y5m+Bp5Qein82UDZB18Dx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1foWbyvyOwEL9FMwKq9/sxU9eF9J/ypN+rfaQ5O4gzbo2mWAiqIE88YWOGzDgT7iV xgFpD45ruKsIVRr68vKdWmOmnWelR7oKyvgig4nFeB0Z+T4e/0snbFdSObnl15ZN6i vUHuvfqK7q+O1oJRYpLuaoFUba2rY5w9HnI0uoEg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Manish Narani Subject: [PATCH 5.4 70/92] usb: gadget: u_ether: Fix MTU size mismatch with RX packet size Date: Mon, 11 Jan 2021 14:02:14 +0100 Message-Id: <20210111130042.523326086@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130039.165470698@linuxfoundation.org> References: <20210111130039.165470698@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Manish Narani commit 0a88fa221ce911c331bf700d2214c5b2f77414d3 upstream. Fix the MTU size issue with RX packet size as the host sends the packet with extra bytes containing ethernet header. This causes failure when user sets the MTU size to the maximum i.e. 15412. In this case the ethernet packet received will be of length 15412 plus the ethernet header length. This patch fixes the issue where there is a check that RX packet length must not be more than max packet length. Fixes: bba787a860fa ("usb: gadget: ether: Allow jumbo frames") Signed-off-by: Manish Narani Cc: stable Link: https://lore.kernel.org/r/1605597215-122027-1-git-send-email-manish.narani@xilinx.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/u_ether.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/drivers/usb/gadget/function/u_ether.c +++ b/drivers/usb/gadget/function/u_ether.c @@ -45,9 +45,10 @@ #define UETH__VERSION "29-May-2008" /* Experiments show that both Linux and Windows hosts allow up to 16k - * frame sizes. Set the max size to 15k+52 to prevent allocating 32k + * frame sizes. Set the max MTU size to 15k+52 to prevent allocating 32k * blocks and still have efficient handling. */ -#define GETHER_MAX_ETH_FRAME_LEN 15412 +#define GETHER_MAX_MTU_SIZE 15412 +#define GETHER_MAX_ETH_FRAME_LEN (GETHER_MAX_MTU_SIZE + ETH_HLEN) struct eth_dev { /* lock is held while accessing port_usb @@ -786,7 +787,7 @@ struct eth_dev *gether_setup_name(struct /* MTU range: 14 - 15412 */ net->min_mtu = ETH_HLEN; - net->max_mtu = GETHER_MAX_ETH_FRAME_LEN; + net->max_mtu = GETHER_MAX_MTU_SIZE; dev->gadget = g; SET_NETDEV_DEV(net, &g->dev); @@ -848,7 +849,7 @@ struct net_device *gether_setup_name_def /* MTU range: 14 - 15412 */ net->min_mtu = ETH_HLEN; - net->max_mtu = GETHER_MAX_ETH_FRAME_LEN; + net->max_mtu = GETHER_MAX_MTU_SIZE; return net; }