All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Saeed Mahameed <saeedm@mellanox.com>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	Tariq Toukan <tariqt@mellanox.com>
Subject: [net 07/10] net/mlx5e: Rx, Check ip headers sanity
Date: Tue,  9 Apr 2019 12:36:33 -0700	[thread overview]
Message-ID: <20190409193636.13663-8-saeedm@mellanox.com> (raw)
In-Reply-To: <20190409193636.13663-1-saeedm@mellanox.com>

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 <xiyou.wangcong@gmail.com>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index 0e254de23f3d..36fd628188bc 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -692,7 +692,14 @@ static inline bool is_last_ethertype_ip(struct sk_buff *skb, int *network_depth,
 {
 	*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)
-- 
2.20.1


  parent reply	other threads:[~2019-04-09 19:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-09 19:36 [pull request][net 00/10] Mellanox, mlx5 fixes 2019-04-09 Saeed Mahameed
2019-04-09 19:36 ` [net 01/10] net/mlx5: FPGA, tls, hold rcu read lock a bit longer Saeed Mahameed
2019-04-09 19:36 ` [net 02/10] net/mlx5: FPGA, tls, idr remove on flow delete Saeed Mahameed
2019-04-09 19:36 ` [net 03/10] net/mlx5e: Skip un-needed tx recover if interface state is down Saeed Mahameed
2019-04-09 19:36 ` [net 04/10] net/mlx5e: Use fail-safe channels reopen in tx reporter recover Saeed Mahameed
2019-04-09 19:36 ` [net 05/10] net/mlx5e: XDP, Avoid checksum complete when XDP prog is loaded Saeed Mahameed
2019-04-09 19:36 ` [net 06/10] net/mlx5e: Rx, Fixup skb checksum for packets with tail padding Saeed Mahameed
2019-04-09 19:36 ` Saeed Mahameed [this message]
2019-04-09 19:36 ` [net 08/10] net/mlx5e: Protect against non-uplink representor for encap Saeed Mahameed
2019-04-09 19:36 ` [net 09/10] Revert "net/mlx5e: Enable reporting checksum unnecessary also for L3 packets" Saeed Mahameed
2019-04-09 19:36 ` [net 10/10] net/mlx5e: Switch to Toeplitz RSS hash by default Saeed Mahameed
2019-04-11 21:12 ` [pull request][net 00/10] Mellanox, mlx5 fixes 2019-04-09 David Miller
2019-04-14 22:12 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190409193636.13663-8-saeedm@mellanox.com \
    --to=saeedm@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=tariqt@mellanox.com \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.