From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f52.google.com (mail-yx1-f52.google.com [74.125.224.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E15A325494 for ; Sat, 8 Aug 2026 15:32:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786203129; cv=none; b=ubXa1FTsuAwEMji8B5hHcdbRvWi4MrQ9N4YQ+WZkHeounEX9UcFKUVhRD5ShtF9F8MTIYCkfRWuyJOOTsikBw+ixhwel6TQLa+8Lv8ubMOUcItdjx+9O+b0iRKkhMq80zw+vMcakV47TFiEs4ZOIoaSch5rMg5FlL81jkNHr/hU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786203129; c=relaxed/simple; bh=avg/jQxBOIQlx57U/8c51C+uOom6aQtP9E7HIUCJewM=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: Mime-Version:Content-Type; b=MTiOw/sNT6DMP+IBzDcKje1w76nvIQls5PpG+D4/g/fljKIKLbu7G39SmIKzvn0qdCKbHt0e3zUZVBPdRbLhbv69vZRS4Q5P3JMAlHmXJfnUAEvKt/JhZSVL4QCFvTf7daTR5IUdEw8gRH86/bcdgHq0w2xnEwvW06tFBx9/5Ro= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ON+Hyay1; arc=none smtp.client-ip=74.125.224.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ON+Hyay1" Received: by mail-yx1-f52.google.com with SMTP id 956f58d0204a3-6679d88abdcso712668d50.2 for ; Sat, 08 Aug 2026 08:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786203127; x=1786807927; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:subject :references:in-reply-to:message-id:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to:content-type; bh=v+UUcaMhlc8IxxN5aJcZYdqNcrd7TqnKbW0pUSKDh7E=; b=ON+Hyay1LSWS59W3l+mnz5HGcULEhNAehZMtVyWc/VKWPtHvIOE25pPZrHlFFiYYdZ xCFxsth68pQ8hdvO0ALrs8Tz9AdkFm4gm2tGCjMBh0sMXjHVhpvCOQ3OZo7bMWHP4Yd7 O2Gw6hLQpYKePWbpZMMFALE751Bo5oJ7pew2u2OLaJrRXCszMDsU1TOnch3wK5iiVRLF Rw9Q80E+qR0F0m3LYDfAt6ROghL9YlhiHLKYb42gL6zdZIZKCzr1pyKBd1VLzy4kgDGt ofYVDpufdui7HBtlSY0lRAgkuiY0OuvMT+/17lAB9u46GeszmmI7waFy+3ER27LRgU0h 7QTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786203127; x=1786807927; h=content-transfer-encoding:content-type:mime-version:subject :references:in-reply-to:message-id:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=v+UUcaMhlc8IxxN5aJcZYdqNcrd7TqnKbW0pUSKDh7E=; b=QOZlZMwKVFBYIguZp7XgwTUj/7NGjYZGk6dlqVhKQI3I+Ls89/Ty9qOT36wpL0j0S7 LYAVtZx7kDJSWnftCnXRR7VNdH5UWIAiXTuEW8eze1qzrEI5HRTsg101eykiiY7Xjts6 4HvbClSBE5uKsH2lc4H5K6FZ87xnDnybNLT4gLeuRXvkJTO3KMvMjlZpRuKPk6nVYmb3 Jg18uAwOLjsU3v7uRpvw1EaqpUnMEeYt+QnMY/aKutxPf38edvTC3jpJvlT66NDn7OWC igBALIpQNzApx+l0JlIP2DNaKZY2sRUYRfz9rZg3mSSpWLl/w2U5aBRo9Ffs31ktjEYV t3dA== X-Forwarded-Encrypted: i=1; AHgh+Ro7RlMswGACF47qWz7WInmsXHIfawDgKqlgg30HpEFHQT9kEsAWhE68wVyYenT8GOkFOPPUGOI5v4aoN6s=@vger.kernel.org X-Gm-Message-State: AOJu0YzODBWfuZbZUfjDCpWJXI9EXq2DhnF/b5+bfdQ+Asb+N72NBuhb F/xR3E7Ni82IkCxGS1Buk9hgMeKjnNeim2kLn/xfB4VJdpiBDtYDDfaD X-Gm-Gg: AR+sD12jFl34nfbzqA3PEr1GW2yE6VvZgzbYMMJ5sP53WeqA7gCfyfiLjE+B5/9rCKc 9FO1zUjL02x4dVjY8te/wg79r/RRDuAXWXmIr4LNsW2L+FBWe1F+9abtJFHnHNFF9xAUDUlMn9r 7T57z29MnPMMU03hd3Ns8+JVqdvNzbBt3zJG3kVy7JBqVa32j4IukMfcj5DWls9CS2DoNTDmRar D0jFByUUZV3NVhn5VKI6aVKMyFTA7utKMiExnDt+/bFQ3Pt/GtMPGAZkNiOaiFm7VMyMdwrHVu3 KA0IcYuYPSyNQSHQwSWXJdHTaMYLZxX6qE5w96RLuUe0NB8ZHpvYt1PhHArUWM5iHeO+5EKWw9r tcQnC4Mh6J6e68dnF5n57HbsXRDdS9WYfnR4OItXyeMocJ2WdVQkmvE7aBXrg/rfFAxCohL3TS9 vuBGVQuLJ10VnFsfERMp4c6FMeQjfrkk00uiUltNAjIk9q0iXb336ztyqgeJFXdtLEDmc+S5s6u Tf9WBkVzDog4C+AQUCXWktEHZ96SmrNcHIhNLFkBw3Q8eo= X-Received: by 2002:a05:690e:1504:b0:667:c3f6:3810 with SMTP id 956f58d0204a3-66ad73a7c6amr4278650d50.49.1786203126984; Sat, 08 Aug 2026 08:32:06 -0700 (PDT) Received: from gmail.com (250.4.48.34.bc.googleusercontent.com. [34.48.4.250]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-66acad51b8csm3171220d50.8.2026.08.08.08.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Aug 2026 08:32:05 -0700 (PDT) Date: Sat, 08 Aug 2026 11:32:05 -0400 From: Willem de Bruijn To: wei.fang@oss.nxp.com, willemdebruijn.kernel@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, liuhangbin@gmail.com, mst@redhat.com, jasowangio@gmail.com, andrew+netdev@lunn.ch, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, sdf@fomichev.me, liuhangbin@gmail.com Cc: wei.fang@nxp.com, imx@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Message-ID: In-Reply-To: <20260807063405.688780-2-wei.fang@oss.nxp.com> References: <20260807063405.688780-1-wei.fang@oss.nxp.com> <20260807063405.688780-2-wei.fang@oss.nxp.com> Subject: Re: [PATCH v2 net 1/2] net: packet: fix wrong transport_header when sending VLAN-tagged frame Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit wei.fang@ wrote: > From: Wei Fang > > In packet_parse_headers(), when processing a VLAN-tagged frame, > skb_set_network_header() is called to advance network_header past the > VLAN tag to the inner protocol header. skb_probe_transport_header() is > then called with skb->protocol still set to the outer VLAN EtherType > (e.g. ETH_P_8021Q), while nhoff (derived from skb_network_offset()) > already points past the VLAN tag to the inner protocol header. > > In __skb_flow_dissect(), proto is initialized to ETH_P_8021Q and nhoff > points past the VLAN tag. When the dissector hits case ETH_P_8021Q, it > reads a struct vlan_hdr at nhoff via __skb_header_pointer(), but that > offset contains the inner protocol header (e.g. an IP header). The bytes > are misinterpreted as a VLAN header, yielding a garbage encapsulated > EtherType that matches no known protocol. The dissector returns false, > so skb_probe_transport_header() never calls skb_set_transport_header(), > leaving transport_header at its uninitialized sentinel value (~0U). Not for this patch, but: having a mismatched skb->protocol and network header offset is asking for trouble anyway. The blamed commit states that this block is here for GSO packets, and the mismatch will by fixed up when skb->protocol is updated in virtio_net_hdr_set_proto. But that only updates GSO packets, while this block affects all VLAN tagged packets. Both GSO and non-GSO should be treated similarly throughout the stack. One approach is setting skb->protocol here. But that does mess with anything matching VLAN packets. There does not seem to be a perfect solution.. > Move skb_probe_transport_header() to before skb_set_network_header(). At > the time skb_probe_transport_header() is called, network_header still > points to the VLAN header, so nhoff correctly points to the VLAN header. > The flow dissector can then parse the VLAN header, extract the inner > EtherType, and advance nhoff to the inner protocol header, allowing > transport_header to be set correctly. > > Fixes: dfed913e8b55 ("net/af_packet: add VLAN support for AF_PACKET SOCK_RAW GSO") > Assisted-by: WChat:claude-opus-4-8 > Signed-off-by: Wei Fang Reviewed-by: Willem de Bruijn