From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A5F8C432C0 for ; Tue, 19 Nov 2019 06:09:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 22611208CE for ; Tue, 19 Nov 2019 06:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574143757; bh=SbUMUnJim/VLR30Kb/P0spszcZpvqXA7aR6Fp6ri25M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=gA2ywr1flufKZWPKOCeMUUQ6MzIBnkKySpd1nB6qvAJZcvXvV9d6QfuteFoDXwEJ6 iJGecvcgfpQKUVnwnsVeHrrTcNXIGofZQnw4fYYpy4lLVJynLusAnIHbsGQUHT+z4B P/HBA677Fx2THApAbH+dSjzLwuWGteBt24oMJ2bI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728949AbfKSF3N (ORCPT ); Tue, 19 Nov 2019 00:29:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:47656 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728199AbfKSF3I (ORCPT ); Tue, 19 Nov 2019 00:29:08 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 745C821823; Tue, 19 Nov 2019 05:29:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574141348; bh=SbUMUnJim/VLR30Kb/P0spszcZpvqXA7aR6Fp6ri25M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v7Qk9IZW+PGtp6k5jEEBHXd7y/stYE/LBkrWDfD9bOK+i9CIOt+E5sfjslYf9ND3O Icw9sJI/EfWWunSxKmwBW9bwKsN+BBtYqySdunI84i9X7IF5PifyT8aKFIivYMJtdH L3x3muZeFVW5xPRyWvza4+E0v3bXWm2o30w1yumo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Muhammad Sammar , Feras Daoud , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.19 129/422] IB/ipoib: Ensure that MTU isnt less than minimum permitted Date: Tue, 19 Nov 2019 06:15:26 +0100 Message-Id: <20191119051407.280428723@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191119051400.261610025@linuxfoundation.org> References: <20191119051400.261610025@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Muhammad Sammar [ Upstream commit 142a9c287613560edf5a03c8d142c8b6ebc1995b ] It is illegal to change MTU to a value lower than the minimum MTU stated in ethernet spec. In addition to that we need to add 4 bytes for encapsulation header (IPOIB_ENCAP_LEN). Before "ifconfig ib0 mtu 0" command, succeeds while it obviously shouldn't. Signed-off-by: Muhammad Sammar Reviewed-by: Feras Daoud Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/ulp/ipoib/ipoib_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 78dd36daac00e..d8cb5bbe6eb58 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -243,7 +243,8 @@ static int ipoib_change_mtu(struct net_device *dev, int new_mtu) return 0; } - if (new_mtu > IPOIB_UD_MTU(priv->max_ib_mtu)) + if (new_mtu < (ETH_MIN_MTU + IPOIB_ENCAP_LEN) || + new_mtu > IPOIB_UD_MTU(priv->max_ib_mtu)) return -EINVAL; priv->admin_mtu = new_mtu; -- 2.20.1