From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.180 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795950673; b=3OqXBo83jmljb+ZZXzLFEnAokeLcc3Qz9J1vy9onxtvhmw/xJD1QJvy2VIIjTLqKFEhq 0jjB/pdjTLpxkGVrgc9Xkey5d3Te8ZsrFjbhWyhIJutSJ/V7bGNmPezx1kxgX0rRcVcQl GtwHZMS1XRoOe0PCcq/P1kriOS06sOjDGGRbGUxH3s6EahhZ2HPF6lgz8Jj2iLlCaq7yS 5qOAK4QM+esmHUp8OIR6iDI/vNVvMlIVkX7L+FE+gtsFjXSdemGfkzAzrNsKZpoQ82TSH FpBmy6Qw0CHJYOt9XddZXyR10dO5/7gZCat1MS9idKz5wXfnIUjQa7cLe6P9ueOourg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795950673; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=MONZdEku5HVj5ezhmFClOUpIzykrax+77+Z7AM41gMA=; b=MKkGdO7QZsPm/PO3HxIL41VntxyZpWO7O3yJ+roSyLzk74/Ev5zslKabsc6GQG1o9mST +MUH23CaCKCVLKyLFLTi/WHvcdNml+E2A08CuV7fv5yWmwjxTGGDaHQQ7Z9A96Nm/Uitu O734DmwSfDol9KXT0QYSQhd46p1yMMfxbK8FAXMz+Equ4S+39EVe9a8bIQDi9eFY6uPL3 OWldg4kX6BIxGl2CexxmyOaF25tiUEuzvxK75sqYnFLvM6gnBeKlo+c5GedGiSF2n2Fbh eQC6OPXxwgIZ5ODXNEm4KS5uvfDsheOm8Yel+fPXQCBiB107K+Go0+zHQDbCLh+/rPw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=L0tjAngX; arc=none smtp.remote-ip=74.125.82.180 Received: from mail-dy1-f180.google.com (mail-dy1-f180.google.com [74.125.82.180]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9259606A31C for ; Sun, 29 Nov 2026 11:11:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D9259606A31C 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.a=rsa-sha256 header.s=20260707 header.b=L0tjAngX Received: by mail-dy1-f180.google.com with SMTP id 5a478bee46e88-385c497bf94so11547510eec.1 for ; Sun, 29 Nov 2026 03:11:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795950672; x=1796555472; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=MONZdEku5HVj5ezhmFClOUpIzykrax+77+Z7AM41gMA=; b=L0tjAngXfoDXty93k9jqT1wbprKhXSKRdv9rGTGW576uBhEUEejJFziVquRsj9GpQk UqqxXueffSPc3YoWH4DOVV+pY6aRQFL3LvhMgzJVzQkPU+xWD3UeAjwi1mZrXNv+7S7B 9luIRqXIpaLOgIrQEVqs1Z25Tp+yf92OIiW7mVQJFcru65APpWUGhXi8a681IlkCFpQn zssL9JB+liKhxxgS6SGCAHO2uo24pSesGaMrJ4cx7msU1tPDui4aRtbDenBodPtOtBcM hyswQukaYE8EI2neFDapBjlW+kX97PhFMTgVoAwyvSklXT8e+2vp2kY9o0nHDX6Fv+CV ZLwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795950672; x=1796555472; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=MONZdEku5HVj5ezhmFClOUpIzykrax+77+Z7AM41gMA=; b=HtbBkmkEDyZ0PQ18807qIXiy4HHkUsKaWdZXI5JYZNlYx5cujchIwYOfL3vUyMYhDM 7SWMqE/AFXQW/qQ8wvBEybGe+rWf4UiOBXvuDBK55aui6g93vVjcz59Q1nXt55vWTvdT bfVjXlD2y5nOmErtTD+CkkjU9wROmR2JYAUekYrocHfsV2rR+i+cv6NWjnEcgm1M2bjx WMx4nA1J5iREUI0K0KOrTy64Q09UV7jUbz27wbsJR4uk8G5tzhkO2fHc7yfZwnPJDSSr 0BMWuyPS/vS0mawYtWxD9B+IhDAc/qqaP+hTa0AfprlXXCsT30x6bwfTYTs9UaqxusKK U8BQ== X-Forwarded-Encrypted: i=1; AL+hErFA/Lwb+rpZqcZXt43LxSyNuPimajaj7qG4j7j290LXwGupwvDFG/lFLypZqc1z3EEh9ts=@vger.kernel.org X-Gm-Message-State: APuU4Z+RXV3MwFJaXhbIqTkULybNpuwChRD7lr7YJNAAIRmPy7Np+hGz IlJOi1FU9tzuoKi9TL6GDZjEXXLBabW1nCSr6ls0SYg42aKatUWLwEvT X-Gm-Gg: AZFdTZfsXyyucim2nkCiDGEl5YvBj+z+eUjQw5SV3mdmUX0cRrPmK6hA9ciLhInfWbz Hdmva1/6CsaNr8LSiSmbBYC4KP/mIJnuUB9m3T+/SwfN7xjkezoptW4VZEGcSaZS19INUP0x198 G5Q0kn1/wnjWyjAcjY2uQT4r6HXol9WzumyCHEYmG7C4udn4sISwmgluAojNwps8ZpL7WCb3eFY n6r7JmWT/hgSNRjoxPNHs9bYMFxBRRPPAS3QpAPr1jnBrWtz7NIowV4CE9X9FF3A49/8W8ftnqw zttGqmQ+JidLV4HNeP+JaSOufOL9KeDro3LrS30r8FGvHHkYJONHiLSs2KUI25dY1FtO52ew470 1SPTgy2hIn9MV66OlRKZVrXwwsel8xb4AOYmy+55FJK1nsrfxAWPkXcO3hmWRTNnokvrYAoZXJE ubWUiVGHVTDrBw8LHN7QT2WXq1qhwxqDsLP3CaFCGAbsikR51eeH+T8pA49wjA3KebtU0g3JRso 9mXpkQ70gUyhS7KljJEVcDYRXEdkZpnjWtF15nhv8lAnCtL9mEUSw5OXebLfutTUAdzSLbxapAm a5DCWtkWDuaG+ruxqkyo7nw3ghgXbnQRbkmEbwQa11Z5PPaXsnYCa1oaY3uLC1R4ReLQP/g37LJ /clV/2zGWuwlYm/6VJvqgtkDU47MFEmr1/0t9cwV7Fwoeh/uApjXXCOuBYVncJ++M1Y1qjU8RXg ZW8XvxOvRvbrTsV5zcBg== X-Received: by 2002:a05:7301:3a82:b0:374:ea35:9069 with SMTP id 5a478bee46e88-3856fb67380mr27003606eec.39.1795950671923; Sun, 29 Nov 2026 03:11:11 -0800 (PST) Received: from localhost.localdomain ([38.114.108.154]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-38567ea2cc5sm81277415eec.29.2026.11.29.03.11.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 29 Nov 2026 03:11:11 -0800 (PST) From: Jason Xing To: willemb@google.com, magnus.karlsson@intel.com, maciej.fijalkowski@intel.com, sdf@fomichev.me, bjorn@kernel.org, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Jason Xing , stable@vger.kernel.org, Petr Oros Subject: [PATCH net v3 1/2] net: reset the mac header in __dev_direct_xmit() Date: Sun, 29 Nov 2026 19:10:55 +0800 Message-ID: <20261129111056.11124-2-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20261129111056.11124-1-kerneljasonxing@gmail.com> References: <20261129111056.11124-1-kerneljasonxing@gmail.com> X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compared to __dev_queue_xmit(), __dev_direct_xmit() is the only open gate for skbs whose mac_header might not be initialized. A few months ago commit c2707480cfbf ("net/packet: reset the MAC header on the packet-socket transmit path") solves the case where AF_PACKET skb can miss resetting mac header if a few conditions in packet_parse_headers() are not satisified and it will cause out-of-bounds access. Similarly, Petr reported an issue about AF_XDP path where copy mode can also trigger the uninitialized mac header problem. In reply to Petr's patch, Eric suggested to add the reset logic in a general layer to stop future issues like this happening instead of dealing with scattered cases one by one[1]. So anchor the mac header in __dev_direct_xmit() exactly as __dev_queue_xmit() does, before validate_xmit_skb_list() so that ndo_features_check() and the vlan helpers see it too. For callers that already reset the header the operation is idempotent. [1]: https://lore.kernel.org/all/CANn89i+aacS2PfaMXnimzGgbCLz-JSnqo6QyoS122Gf+kxya3w@mail.gmail.com/ Fixes: 35fcde7f8deb ("xsk: support for Tx") Cc: stable@vger.kernel.org Reported-by: Petr Oros Closes: https://lore.kernel.org/all/20260817153957.3177627-1-poros@redhat.com/ Suggested-by: Eric Dumazet Reviewed-by: Björn Töpel Signed-off-by: Jason Xing --- 1. this patch will be backported to stable branches to fix the xsk problem and will also be merged in net-next. In the -next branch, I'm going to follow Eric's thoughts to handle the mac_header 'issues' from the driver side, and then finally remove the guarantee (reseting mac header in the core stack layer) like this patch and that af_packet case. 2. this patch is also a prep for the second patch in the series. --- net/core/dev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/core/dev.c b/net/core/dev.c index 3c58db732761..6ea2fd3506f7 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5149,6 +5149,8 @@ int __dev_direct_xmit(struct sk_buff *skb, u16 queue_id) !netif_carrier_ok(dev))) goto drop; + skb_reset_mac_header(skb); + skb = validate_xmit_skb_list(skb, dev, &again); if (skb != orig_skb) goto drop; -- 2.43.7