From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.179 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795950673; b=NX7gnwYFXQ4Iy9TxrcpsgS1KLRpZLh8wD0xI51WfyYhTdsgtpb12FAvRCuMsOhLK5sw7 kVUQsO6v/bpFrXhfZUSE3J31+D2YYaWbHWWYzPwA3P9T2nBpygh23mAHkfp5WMYRKIr5V lpu6Znjnen1FxMf08nxSO5f+oYsqqfYrhLDLWlbqBy3W+XMEvoTAppHQn/68CkGoXRPYm goDsRDtxHRe3Z6GO62i0G6/0UD62wk6bc8RyE28A3WmnnVe7mSnoqODn1vPvL3MK+s8yB vbtXMwSWBg0Yu+Rlpjq4sCFBJnL45HdN3y1PHCdt+J5NpiNYOV19SFkesulzg5nnpgQ== 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-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=h3yL0O02vvnq1o76a4zYY2N6C5T6Whads3nALmrmjj0EIAmfqabZ4vd5re07GgkblURT hizQcV46IUBmKQoW3mc84sKUkvQc69uGktetedFnMfX0OHVPDsgufsLpYerH4wX2w/IaK pDkfpJUkU2q8fOYTcm98VVt/RQ+ivjEKfT8qcY/lLZUme7z0fv5rvLqlXD61+ZbrPj4Y+ jo8btKFl7fj4NsFt6y5VyMK2xOF9l7HSQ/kWytHceY4izKtvBFNtcwUzC6s8iMn2hxxbV Lx5c010CPtnSUmZbz5hu4CgvDcc/8hD9ZbTmwyT4QeHCIX+wueNXOyHnFVQBs3CaVtA== 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.179 Received: from mail-dy1-f179.google.com (mail-dy1-f179.google.com [74.125.82.179]) (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 DCCEA606A325 for ; Sun, 29 Nov 2026 11:11:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DCCEA606A325 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-f179.google.com with SMTP id 5a478bee46e88-385c497bf94so11547512eec.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=LLYWNRJUB3vMsqIMlmswQWEE4Prj2mnm5lHIOGdszE1L3Hq/V3oS3DyG5y+dur3T+D ug0CNAXqXnwpjuhDFJv9IbruecfemB+AaKyqAHoYDcs9rrJny5NL9s0ezNZsrg+Ipgjh +hzIIh8e8GQcDaIfJajlJHksOezQ7xKcBJGVd1w6D9cO4XSF0+T2UvOg1A4kXh0jWO/O 6nrAEcgmjhkV5ZMs8GzUGpdObGwHd9L3jteJ/YSC1qGM3he81somnShlnOwS5rT9kMtP 5rMP1j35ZcZRHr2OFkcR5iwiNNTBysPt3R8QfCI042DjZCfMEo+KKpw4zYqyaJond3St EMig== X-Gm-Message-State: APuU4Z85PbC00DryZDLwJ9KudPRAbwLZI1QHdSqNTTdxYVtrnOmRRdsu 2hvui9Qgpvo2xMDDyvwjMnILdgjoBYfNv4hb6f3f4bswASO58krvcP7O X-Gm-Gg: AZFdTZc3DZ9fhAs+r+NCZac3jUz8EqwsvhOH+GP5UXXi+w+69vwKmboiS95ftvWvb10 /stJTnGkPWacob1Fzr7wes8o+E2VZkGDEURVa9AqgtWOLYAXLcaF5qetCAnTzfktt9yYFc7v5kK AdL45/ZL4jhjHdF7x4ZrhVLqfe8fq7Z6R/kuqdbhTiISO+0ZZnqpsyIIRnjJzsGiYeXLH9j8TQP fxj/9i1duLW+R3CV4BGX0cPDSlN6Z+s04AQGNAq5iBtrGpOTXc6+A2sDXIItzT+jb12bYdzMEgC 3RpIIQx7VeY9U/LI83pwWLcAzaDLg+ebbgDvrRC+fsOShiHb/URtUEmJwB9G6Q1AgYOxgpaDu56 NEfa+GkWHDc4yYPrt5lQg2Z1Cb2WoGAI/dGD6mFlrE6/ViLSK96lWOoZAO11g9NN3j8ot+bi9Si TBmz/3oFqp5VzKfFFq7IFlpLeCMJnvBFPJTjiC7/PeqTYmRkOghlcOjHHotEU5BNvk6A6jJEIKc 37jlvLvMYBgemBRQuW+5reZN83WeGXn4pP9fcorD8j0Sqi/+Zv2n3MHQcUgvszrpJdBav3FDTy8 a4kDSqfYPsp5mJnwtVN/yS5lp2Co9bCqBYABOlayAeAQm2BjPHoEL/hNRcfaZNzkn8X9n7KMuqw B3cYvlvuhfn06ZixJ+pumeT3Kdw2rxBYXN9VMYAMftucs1vtBIOrRjsE7JmiKQA4bCIbzAaquQ6 wr3PV/+6ebFinnaU4Low== 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: netdev@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