Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp5845488ybn; Sun, 29 Sep 2019 07:00:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyynQhFMMZX93LiitiTogxNu60Btwwc0rsubC/mfQ/JVsbCMQV70MhJv9Q6jEY3oIgDq2kr X-Received: by 2002:a17:906:5c07:: with SMTP id e7mr11133117ejq.127.1569765600160; Sun, 29 Sep 2019 07:00:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569765600; cv=none; d=google.com; s=arc-20160816; b=fLmITGPB7FT9LwxGAUtAAkpmE1dsMBvok1IdG+FPst00pPAe8xHWWbV2dMptK+a74g QZGfkEsXkcqe0bnR+TzFQ2wx0uASxUvV9zfaA3PKH4nScLjORkl/6bktztRdDAF1tu9v 4OCHgUj1q3onwkmvwaL53kGK9HpjcDDaXEw/fcUPVXzr3dx/ZWdJa10PqVEAAZu91kk6 h/a5wWXp58+fPBU8+xI85uFgURALQwoUYkeumGJTn4pRs2fNZHkNGtixcCmzRj5lTxxz xZfRZMkMtPr+Cc4j77ez33OlwvGYxF09JUxKLYDN1Ay8evZNigy4bRrmwn0rOtmeGDBq 4+MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bUUHEkN+yy9pOT9kSjGKsQEOUJddnrGU8bTxxsg4x0Q=; b=A4tUIbqsXKaqqiZpidcgAnSGKqE5sXGxJM+1+lpSSWvFL59X89NK+P/Y9Z2jfSTais O47UPIwNXDjieiZlN5lxBoguO3QSpO3UZPfdTejmBgjIQkw8/2Fdv9H4wq9jArwmaFD8 ljifdYH/XPpYr1j/bMn1+/1y0eqtEubIsUFveJLkMJ9lqzm6ySvNNxaFKyE3TwqiDZ0V GfXPLXHW33XVGdwC92MsoQQRuQrNXmS89LqyYIflqj+CRJXsQuBaZedFsjKmZj7Z+Typ tsEecZWr68B5jS3oWMLTIXRiKxyL/1eeSk+8tsRfoqyekD+6dkjVBLuU978tcmSxPGTS hFvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ok/zQek4"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h17si4983366eda.54.2019.09.29.06.59.36; Sun, 29 Sep 2019 07:00:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ok/zQek4"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729454AbfI2N6S (ORCPT + 99 others); Sun, 29 Sep 2019 09:58:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:38878 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729294AbfI2N6Q (ORCPT ); Sun, 29 Sep 2019 09:58:16 -0400 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 103E321882; Sun, 29 Sep 2019 13:58:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569765495; bh=1UXddJBhGzTR7X65RIq+VFUTwq0rTKPxvadhmJrHFxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ok/zQek4ZvrfAT+RbRXX9TbBmHMwyT4xN53ifXrI4U2DliLXQZ3xuJ50Mu6lkbmnn Yh3p+kWH2vIwwIZuUHFdHZYcv44PPJ3lfvYqJmL5PthHBE9r5W4cNnEqztephORmAf XAv0OnORfEUkb+F1PEvoD5gptsjwTcVbllUrEBtg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cong Wang , Tariq Toukan , Saeed Mahameed Subject: [PATCH 4.19 21/63] net/mlx5e: Rx, Check ip headers sanity Date: Sun, 29 Sep 2019 15:53:54 +0200 Message-Id: <20190929135036.383440709@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190929135031.382429403@linuxfoundation.org> References: <20190929135031.382429403@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: Saeed Mahameed [ Upstream commit 0318a7b7fcad9765931146efa7ca3a034194737c ] In the two places is_last_ethertype_ip is being called, the caller will be looking inside the ip header, to be safe, add ip{4,6} header sanity check. And return true only on valid ip headers, i.e: the whole header is contained in the linear part of the skb. Note: Such situation is very rare and hard to reproduce, since mlx5e allocates a large enough headroom to contain the largest header one can imagine. Fixes: fe1dc069990c ("net/mlx5e: don't set CHECKSUM_COMPLETE on SCTP packets") Reported-by: Cong Wang Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c @@ -694,7 +694,14 @@ static inline bool is_last_ethertype_ip( { *proto = ((struct ethhdr *)skb->data)->h_proto; *proto = __vlan_get_protocol(skb, *proto, network_depth); - return (*proto == htons(ETH_P_IP) || *proto == htons(ETH_P_IPV6)); + + if (*proto == htons(ETH_P_IP)) + return pskb_may_pull(skb, *network_depth + sizeof(struct iphdr)); + + if (*proto == htons(ETH_P_IPV6)) + return pskb_may_pull(skb, *network_depth + sizeof(struct ipv6hdr)); + + return false; } static inline void mlx5e_enable_ecn(struct mlx5e_rq *rq, struct sk_buff *skb)