From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796212298; b=5BZh3aFxgBNpNyrHLLKab1JhdNpG+9Sel+YgWOB8Tvu/oHnhk3kIOlOnv7TaWR7j3n+S mzcEdI8RDkLaQfCYj+N8Qt+92Ok0RkoAPKgQ5NiyiNRv3QXA9jepryuce0J+8Cdn5rrTA 4rHaWAmBJny4FIYHBa0LQp6n/QCo3Ogdls2AFZLlUZqTO/GPA+ZfzWa10Ew4dx6lNu61o vQdZzAgcVOoKWD2o+f/haM8U24wfKNBSdy6C7+GtTG+7vJH3JQTdjlmKoa8AXzYk75Q0d 3auz9SAzpG/jdjfZZ3Qe7EwJEr8Gu2L9w1vF5jQ4U2RqY+xAauZKJRB+2nJKrM1ktiQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796212298; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=Subjckqnk5Vh2Ohok+1+il6FfHG6yuNKhvco+kcRnBw=; b=fPJv+Dun5fTDmsZRBKPnKBeJKbZjYf20D+GrYa701yhpncRSFbAeTNdj2mhmTQ0xkmjo y8P6pSxEOfqVLSZn5G7q6kDOP3GXObuOJRNVWKRbLy3tH3xFvyhaR0yE/+6zegrLxJr2z DWnTJ8oOi7IW7Yb8LFlC9WbweHPRG/rGgsMCTeLsPlaCl5XcYEbeM2qUnSlYm2VvsjvyR i08yWISFTE/IiGH6PRFVH08x33VXoGtLoWt9dqXQdVveO7VO5zMSSEsodqOKJKhmgp4ZK xe/1pAj3AcOHdG4E8sBjZlJUqQiUN/yRmyonzTekehCxqU6YXwSfeuYnYR7B5LhUrvg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TMS8NwtP; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=A+r1Apbu; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25176606A6A3 for ; Wed, 2 Dec 2026 11:51:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 25176606A6A3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TMS8NwtP; dkim=pass (2048-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=A+r1Apbu DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796212297; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Subjckqnk5Vh2Ohok+1+il6FfHG6yuNKhvco+kcRnBw=; b=TMS8NwtPTno7nIckIV0GkOY/QrJbut2c8BMN4ad2bXYpKj9vlXGyDh01nnF+pThp+SP3dE ZLQxRCfTs7JIA5oHY6K7R7fGzCjH8mn2B1SxH7oPrC3pWw9y05tY5y2SG8apswAfaozcri xBLk9QQHsUZPxziWPEvT1dElgHF4JcU= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-547-56sfc05ZPtiBasJ83keNWg-1; Wed, 2 Dec 2026 11:51:34 +0000 X-MC-Unique: 56sfc05ZPtiBasJ83keNWg-1 X-Mimecast-MFC-AGG-ID: 56sfc05ZPtiBasJ83keNWg_1796212293 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4bb8ae35aeaso106642125e9.3 for ; Wed, 02 Dec 2026 03:51:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1796212293; x=1796817093; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Subjckqnk5Vh2Ohok+1+il6FfHG6yuNKhvco+kcRnBw=; b=A+r1ApbuTue6GMMUrrBguxFM0KSdHOIvHOiORCB1BAZ94+LrVpfeGf53zblmIOpi1I EicO7Xcw5rrAsJCrmQQWEdLq4XvhAttwo64QPslSZtNS7oFOpW4p//umkfb85FXUh7bn E15x+6DSPldzTgXie0CscuuekTRYV5UXZDoYqmsUBN5BjxImb949wvluTdvRDIEI1YA6 qpP0YnhRA74Nw3Piwml4LmnvN9XMinli21WP69LQaNzNDol3bWaWl46KwOtnCVKsvGdo bL+JnsxUgJ9t4541R1/5eMN/p6vYkEIx4JGTxnk9FE1nywavgsSXn0TGDslN4G3dYDqp ykHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796212293; x=1796817093; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Subjckqnk5Vh2Ohok+1+il6FfHG6yuNKhvco+kcRnBw=; b=B2P/hs+EaDKeJX36lXG9RcWj1uULw3QRkpieZmSwdrs8G+RBXaqIAIaVE8tAh3Pxpe SRD9cknBPd2z/JQiy4LgZMiAn+Ax3reAqcIFCe2HyyHfzK64vxN+CLqeffIN6M7FBibx siNGe/lMrkOy6uHctbRvQxSUKVMMWJRyZsHKQiNAcdcSUmlzJdn29YKZLR68mjtdtf7v 5x7Ad0GRr5vkDq5gcQLH9tZCpESMcGh6KPVMDtdGdDfok8aIoppva9Yx96f0Jz97lZ5Z ZsKIs689Up7vw8SROkfPU0M06t4GHaYjM7pBwdFBbHmsIk71f0ZSzvfMPDpT0IeKNOrm cxwQ== X-Gm-Message-State: APuU4Z845i1T+axdNmPRi2nddLV7wJRAAmTvFY/I10VrOwZNi/vf7PwT HosSoJ9WOrjIJyMYM6rqOPxvYBfD+A64Nlqkhf6DQJDJfs3Y9FdM8GmlIoaQ+4y5vmDZXMNy1pk dPB/NulvgzvhuZVq2cWHSF+1R0axmg07Xi2OMIvMBtX2mKrhsAyMvpi+8YQ== X-Gm-Gg: AZFdTZfq0BZ+Nldcqb1URURC+cQHzweOo/Dl8V5tJjTbS0fcpWdP0vYti4/kQZJGlyY OQTaAA/aSt43QGplVAKL43dvqUsxc9NYd8e2rn6znH+f8OmQyHbanctN3T7YCXISq3ufprlJusk HQgU4eWzdTX37eKU0NMR/XCY+QVXQqcdZs06yQHtb1BFNdszTcy1wtHjQOzN+UDqE36arrfV2Js 8dnfGWix7okyfnUcDjcr2imMjO43aCtVBj55uZnAGvGzTGxdrCfQi9CJ/HvvDlAQ2FSLRzMWwtx GT2mE4yYtzsfBqMRQw4PUf457f2+qAJZQs3ytiFMBI14X2QIToBRnyX3V0l9+9HX/5LkMZlcLtC EjN4k+dKUos1n4IKzKncw3pEdYaaMsiv3gNNfck8lG/DUQAoE9NDlHfmys82ZpyZwZcPlQxBqYP FaO6NyS4C3EG0oXTP0Kv4IgcbQlWrB/+CRCrA+2KzY6Ho= X-Received: by 2002:a05:600c:3b94:b0:4bb:6f41:39be with SMTP id 5b1f17b1804b1-4bb8880ca3cmr962667905e9.15.1796212293115; Wed, 02 Dec 2026 03:51:33 -0800 (PST) X-Received: by 2002:a05:600c:3b94:b0:4bb:6f41:39be with SMTP id 5b1f17b1804b1-4bb8880ca3cmr962667295e9.15.1796212292638; Wed, 02 Dec 2026 03:51:32 -0800 (PST) Received: from [192.168.88.30] (ip231-128-192-82.pool-bba.aruba.it. [82.192.128.231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb853a9846sm1262498745e9.11.2026.12.02.03.51.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Dec 2026 03:51:32 -0800 (PST) Message-ID: <1323c2e2-02ab-42b1-8bee-57a61d7a9e40@redhat.com> Date: Wed, 2 Dec 2026 12:51:30 +0100 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net v3] net: xdp: fix generic XDP on skbs without an Ethernet header To: Jiayuan Chen , netdev-bot+sashiko@kernel.org Cc: netdev@vger.kernel.org, kennethbwlee@snu.ac.kr, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, horms@kernel.org, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, sdf@fomichev.me, kuniyu@google.com, wang.zhan@smartx.com, mkarsten@uwaterloo.ca, bpf@vger.kernel.org References: <20261124142545.221584-1-jiayuan.chen@linux.dev> <179561685970.3135.9452194614168004635@kernel.org> <675a13e9-ed23-4a73-8d09-28517c377353@linux.dev> Content-Language: en-US From: Paolo Abeni In-Reply-To: <675a13e9-ed23-4a73-8d09-28517c377353@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 11/26/26 03:16, Jiayuan Chen wrote: > > > On 11/25/26 10:27 PM, netdev-bot+sashiko@kernel.org wrote: >> Thank you for your contribution! Sashiko AI review found 3 potential >> issue(s) to consider. >> >> Critical: 0 · High: 0 · Medium: 2 · Low: 1 >> >> If you believe none of the issues are legitimate, please reply to each >> issue of Medium severity or higher and explain why the AI is wrong. >> If any of them are legitimate and you plan to respin, please let patchwork >> know by including "pw-bot: cr" as a separate line at the end of your reply >> (one such reply per series is enough). >> >> - [Medium] dev_xdp_attach() (net/core/dev.c) now rejects every >> XDP_MODE_SKB attach with -EOPNOTSUPP when dev->type is neither… >> - [Medium] The new early return in netif_receive_generic_xdp() (`if >> (skb->data - skb_mac_header(skb) != ETH_HLEN) return XDP_PASS;`) skips… >> - [Low] Documentation/networking/af_xdp.rst (around line 86) says XDP_SKB >> mode, which is used when the driver has no XDP support or XDP_SKB is… >> >> -- >> >> net: xdp: fix generic XDP on skbs without an Ethernet header >> >> The patch refuses to attach a generic XDP program to a device that is >> neither ARPHRD_ETHER nor ARPHRD_LOOPBACK. It also skips the generic XDP >> program at runtime for any skb whose mac header is not exactly ETH_HLEN >> bytes. The goal is to fix a WARN in skb_vlan_push() that comes from the >> Ethernet header fixup in bpf_prog_run_generic_xdp() on L3 devices such as >> sit0. >> >> Closes: https://lore.kernel.org/bpf/20260812043643.808295-1-kennethbwlee@snu.ac.kr/ >> >>> diff --git a/net/core/dev.c b/net/core/dev.c >>> index cd0796a1dbfdf..a9ef193967bab 100644 >>> --- a/net/core/dev.c >>> +++ b/net/core/dev.c >>> @@ -5825,6 +5825,10 @@ static u32 netif_receive_generic_xdp(struct sk_buff **pskb, >>> if (skb_is_redirected(skb)) >>> return XDP_PASS; >>> >>> + /* XDP is Ethernet only, skip skbs without an Ethernet header. */ >>> + if (skb->data - skb_mac_header(skb) != ETH_HLEN) >>> + return XDP_PASS; >> >> [Severity: Medium] >> Can this silently skip a program that was attached successfully to an >> ARPHRD_ETHER device? >> >> Take a VLAN device with reorder_hdr off. Its type is ARPHRD_ETHER and it >> has no ndo_bpf, so dev_xdp_attach() defaults to XDP_MODE_SKB and accepts >> the program. On receive, vlan_do_receive() does this: >> >> net/8021q/vlan_core.c:vlan_do_receive() { >> ... >> if (!(READ_ONCE(vlan_dev_priv(vlan_dev)->flags) & VLAN_FLAG_REORDER_HDR) && >> ... >> skb_push(skb, offset); >> skb = *skbp = vlan_insert_inner_tag(skb, skb->vlan_proto, >> skb->vlan_tci, skb->mac_len); >> ... >> skb_pull(skb, offset + VLAN_HLEN); >> skb_reset_mac_len(skb); >> } >> ... >> } >> >> That leaves skb->data - skb_mac_header(skb) == 18. Then >> __netif_receive_skb_core() jumps to another_round and calls >> do_xdp_generic() with the VLAN device's program. The new check returns >> XDP_PASS for every packet. >> >> Before this patch the program ran on the full Ethernet+VLAN frame, so >> read-only filters and XDP_DROP filters worked. reorder_hdr can be toggled >> at runtime, so a filter that is already attached could stop being >> enforced. Nothing reports this: no warning, no extack and no tracepoint. >> >> The commit message justifies the runtime check only by dev->type changing >> after attach. The VLAN effect appears only in the v2->v3 note below the >> --- line, and that note won't be kept when the patch is applied. >> >> Would it make sense to warn once here, or to reject the attach, and to >> describe this in the commit message? >> > > > > This is on purpose. The direction from the maintainers on v1 was that > XDP is Ethernet only, so generic XDP only handles skbs with an ETH_HLEN > mac header. v2 tried to let this VLAN case through, and the review on > v2 asked to skip it too, because the fixup after the program is wrong > for it. > > v1: https://lore.kernel.org/netdev/20260813113229.381136-1-jiayuan.chen@linux.dev/ > >> A separate point: bpf_xdp_link_update() calls dev_xdp_install() directly: >> >> net/core/dev.c:bpf_xdp_link_update() { >> ... >> mode = dev_xdp_mode(xdp_link->dev, xdp_link->flags); >> bpf_op = dev_xdp_bpf_op(xdp_link->dev, mode); >> err = dev_xdp_install(xdp_link->dev, mode, bpf_op, NULL, >> xdp_link->flags, new_prog); >> ... >> } >> >> This path never reaches the new dev->type check in dev_xdp_attach(). The >> device type can change after the link is created, for example through >> bond/team port enslavement or TUNSETLINK. In that case the link update >> still succeeds, and the new program never runs either. >> >> Is this inconsistency intended? > > > Yes. dev->type can change after attach anyway, the run time check is > what covers it. > >> >> [ ... ] >> >>> @@ -10775,6 +10779,12 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack >>> NL_SET_ERR_MSG(extack, "XDP program already attached"); >>> return -EBUSY; >>> } >>> + /* lo is ARPHRD_LOOPBACK but uses Ethernet framing. */ >>> + if (mode == XDP_MODE_SKB && dev->type != ARPHRD_ETHER && >>> + dev->type != ARPHRD_LOOPBACK) { >>> + NL_SET_ERR_MSG(extack, "Generic XDP only supports Ethernet devices"); >>> + return -EOPNOTSUPP; >>> + } >> >> [Severity: Medium] >> Does this break existing generic XDP users on L3 devices? > > Yes, that is the direction from the maintainers on v1: XDP is Ethernet > only, and BPF on L3 devices should be attached at TC instead. Given the behavior change, I'm moving this patch to net-next. I know Jakub suggested the exact opposite in v1, but nowadays we are try to shrinking the amount of changes landing into 'net'. /P