From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.178 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795950673; b=4gNQqwuueMeXNKmRQJJHAYTle1xZZppSLJMDQBU+a2l4fTcGo4eERZuoaXZiffVKBaLs qspZf8XVN0xJclNaZFKFv/FkEa865V/i7UFsImK1stNeAhAEPp0fq255BgJ/jz62BJaUf JhDhOe5FXsLSWuwoNBd6Vd6883ysbVLGHfXQkNhLt/iexK4vN9MIt/poMj8EDW9w/7RJV pZtRB75uMDVOD0Y4DmbyvhVIo2UVTh5GGli4V5L+d9eXF+2Nix01qcRKlp7A4OsEcrXqY PGP2SgsEGGQ2u6516WuloiD57mWdbQWeLDRbm9KtWidkg168gGpYQiMEhNwg+/DN5iw== 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=icWUtrbR0b5MKMhWfq8cD36BUxwPoPgiAxTML/ciNRRqOVZEfIY6KeM4f7A+RPPUidk7 iQiigijxaTbGhddzzMORuocbiqhz65Y+D6a2/0NMLPqNe5YIlii45LU1qBe7YC4ZkYmNw REcHw2bIrVbV4AyX+1Lvy5Uinvzaga4782i9syttUrZpPd+6Zta4qyflOLKAouwt/HJBm sEPTHLmFSsF6GuCZCI2rF9OEqnyEPXWqD7AxeVtMeOk7AgLfbanh6r/QG6ZkSn86Rsylo NJlEhRLFyZOUE4BPvdGmfvwklt4dWkjiukgltzRQYMKyTQ8SzdsHOoAI5h9vSP/EYCw== 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.178 Received: from mail-dy1-f178.google.com (mail-dy1-f178.google.com [74.125.82.178]) (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 DCD18606A329 for ; Sun, 29 Nov 2026 11:11:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DCD18606A329 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-f178.google.com with SMTP id 5a478bee46e88-38692f62b22so13787437eec.0 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=XdXgSGRfU9yIn0+BnFH/fg/fIhuSwKMfaIpwyjmOX/HZlhMTnPkEhEzDA8k9b+zCCk /ZPRL5nJLbisxfbVWYFtS9AO5mw6WpfkVP393tfoIPeJwVkJc55xiyLxvrMxi+4bgGII bVFw/pZpG5V8nnoH8Phhxi3JNf3EWruc1PooyAnJ89WsZm9PuEQ5/ETj+9SxTy1jh0Z5 KqJqRORTR8yGXwwBflxNN+62H6pRwWxhxpPbKmWoSO9nviRg8CnoS4Si8F/9aujG+5is gjmAUBEpEaZg2WCaiXh1DEnNJLZ7qEisotG5WEWQtPRwmc4T+jrneyZ8fM7EjWyADiTG IFng== X-Forwarded-Encrypted: i=1; AL+hErEnIrfno/3LaoCA27+3b8RkD9sWlAdBdrbMv2pWNy5dlY3VR9wOJGQbxyDAQnUhgb+T4dF/594=@vger.kernel.org X-Gm-Message-State: APuU4Z+eSBDoYy4fW0kEP5yUSwHLimoWtHc+w1TGjNiXd4dQlA4ldEqM UTQWGiJ+7AGu/B8r7jSia2obMR9voBAHz9LYmVGOvJXzNKe5N0ILLkkp X-Gm-Gg: AZFdTZdqCyjWtA6Mf9HHhyzZOVf5w+FMzXIdALEJi9gSkRODDR/mw/iCV3Qhap6Iyo9 0gyDFLvo6Cb6wZIuN8sE43cXjslKx0tK86K/woKS863rFXUvy4QAjCbQhZ7j/pUT7vTjyWeEfUx prJaKI7gI9l/A5l1zXTAIBx4EjdBrqtXdxuwLoCBgfFhsjQMcUE3r8z9rmg5wQtc0shcbQVwVA/ Dr7lsiHPozpdmF4qwXs86Bl1uJWmUgngR1V0WN3bevqnE5oLoojjegm7ae/O5unFjGwEPp+JmVO ClSWzT+DLngR/d1mJBJQvQCHj+ybl8oj8egmn9x2/91n80QL7DLckjNdq9KW6K4pYWet1oJ/dEK komqhodVjx/ymSrRt5xTfRXxG3k6UQhUmHIWJ/sWfF6Q0KMtENNb7lCDM8hlshsEb6giyA+phTn +lNxXkmJ+OycTylLKrMUJ5aRQ6BzjTLCeHZNjb8yTayQUgQRabS+jqPthIl3V5lGjYxvALdj4xL GK/EBxTsdkOqpcks6RcaHiOTQiy5qGWvsUPldH+2oCAok1T2qFAstMHbIXR2OJoz7jhI/8zYJmj a4SZ6E/46azhQ6TSYTpXD2rLYIQykeLtfAvq9W36wUIlBddrNk2QccScg/YTxLtwWSxKEHW5WyL PDMWhSSDpSoWpbQzbuXkazhGh6s4ieQcw8wma91hNrsvF+nbCSl9IiDxMJqb92qZ1x/f4Houi0+ DTOKYqtIIODfvK3Eb2eA== 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: stable@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