From patchwork Sat Aug 15 07:29:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 247774 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp1485627ilo; Sat, 15 Aug 2020 16:29:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQM0WzWHXncB+gSEYv+lrek3wpaZtA0UJn+wPkY2WsT+oZkfVemER8QVMPrbgyXrXLeifg X-Received: by 2002:a17:906:dbd8:: with SMTP id yc24mr8503489ejb.176.1597534194400; Sat, 15 Aug 2020 16:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597534194; cv=none; d=google.com; s=arc-20160816; b=Fj2kI39NJVwUrXXHfbmILMVxuDLtQfwuerNBmNt4C3cK3P9FaGRHN3Yik0Yak5yvB9 YYD2/b1BK/vVAhiCAg09Tx6pzMZHuM0rgEtN/bPXGfnn3dMGj/+6BFjvVvOAms+b+DdZ KGJsNsnUCVm83wtKRDIldLIS2AeJ36UZ8/SKlEx+thsVa4FZ9DMcg0sFYh/Ny0OWhCAi K5xqlmi/uEJtP84t6Dw2IFunOhmNN6gSmdLAIe5zkz7HtPuoRDV0j24b4J0SjJjga01N +rmh1x9L4EiVuRdFeuqWvL5Zp/axzzDP4VT55JyGkA/YgQo+Ap5fcCqTUwOmcgo11RLU f2WQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=wCyRP4ybr+d2FCdGH9LUpz1iCNPSigUor1/M7nfY/9c=; b=F8vBTSJ7JUCPPCX9in5i0zfRw9ykFsDN2Sl/RlApggN9h/VUxYVYfQaRqaV5i+6QJ1 hK57LUP8/m2H4DusC4X7ijl/qusfQwgJ4AXNzeWAtnweELD45blOos4hLNxZ6waKowZ1 ybfVJXS3VzCLPsj04ZYbnAN6vCZ7R4FUptwLwmEWmvpJ2cgEvyCq7J5gdeDDj5Yf/CYR PKWt8w9x9eQfHBxiB1an5YR8g80e9mBjROYzc1wxgyJfOqo54Hef/LvQJm7FaaQgpj1T MMqOy74bsvW8Mj6+Sw5nQxfrl98MQADZqcZUEMVyCGz0HPo0oyQPJSNLyRCfFQ086n+S S/wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b="jkISz9//"; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l11si8964865ejx.11.2020.08.15.16.29.54; Sat, 15 Aug 2020 16:29:54 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-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=@zx2c4.com header.s=mail header.b="jkISz9//"; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728833AbgHOX3x (ORCPT + 9 others); Sat, 15 Aug 2020 19:29:53 -0400 Received: from mail.zx2c4.com ([192.95.5.64]:39479 "EHLO mail.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728749AbgHOX3w (ORCPT ); Sat, 15 Aug 2020 19:29:52 -0400 Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 17dbf29d; Sat, 15 Aug 2020 07:03:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:mime-version:content-transfer-encoding; s=mail; bh=ZIFPDsMaam/KKfRH8s4z6SGuX7w=; b=jkISz9//M14wD6i5jF3L z06/aSM1xT7iqBBx3dLvKjgtn2LPG9fjcA/u9z/jadujcTgp/4wCBqtOXpJ79v5c dlaD9RVc8alTLcJgBrLvuPAq1EHIqG63qXsvSdlVHg6esEXLtXeVoMcaRkenoz1e 0eYdJK/QqYV83Qo61Bqr7cyi0RaXuj0uZIx+z9C1X9kmhsl0Gp1jaFWo9SQ2Mn5G OQj8UDovrYIU4neWq/Auw3t6MY9YbA8hjWkqqGsr1bqLy+SAB8ZQHnonLz2vCVu6 7DXljHGWJETdvpsaqmFK+GeQwGtMqm2irDI7ZxBubzJB4ReprNndQKJgT9B7lNEV yA== Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id b64639ef (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sat, 15 Aug 2020 07:03:58 +0000 (UTC) From: "Jason A. Donenfeld" To: netdev@vger.kernel.org, bpf@vger.kernel.org Cc: "Jason A. Donenfeld" , Jesper Dangaard Brouer , "David S . Miller" Subject: [PATCH net] net: xdp: pull ethernet header off packet after computing skb->protocol Date: Sat, 15 Aug 2020 09:29:30 +0200 Message-Id: <20200815072930.4564-1-Jason@zx2c4.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When an XDP program changes the ethernet header protocol field, eth_type_trans is used to recalculate skb->protocol. In order for eth_type_trans to work correctly, the ethernet header must actually be part of the skb data segment, so the code first pushes that onto the head of the skb. However, it subsequently forgets to pull it back off, making the behavior of the passed-on packet inconsistent between the protocol modifying case and the static protocol case. This patch fixes the issue by simply pulling the ethernet header back off of the skb head. Fixes: 297249569932 ("net: fix generic XDP to handle if eth header was mangled") Cc: Jesper Dangaard Brouer Cc: David S. Miller Signed-off-by: Jason A. Donenfeld --- net/core/dev.c | 1 + 1 file changed, 1 insertion(+) -- 2.28.0 diff --git a/net/core/dev.c b/net/core/dev.c index 7df6c9617321..151f1651439f 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4676,6 +4676,7 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb, (orig_bcast != is_multicast_ether_addr_64bits(eth->h_dest))) { __skb_push(skb, ETH_HLEN); skb->protocol = eth_type_trans(skb, skb->dev); + __skb_pull(skb, ETH_HLEN); } switch (act) {