From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 947254F85CA; Wed, 30 Sep 2026 16:43:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790786592; cv=none; b=ozKHx4NYA9s8y7lEsS6akBeel74kT1Uc5+jaoZRSwbd/1pnyGHIYSRYteQ0nIrxHR75ffoI9CRUxDSrFqeKzC5pRipjmoIRWTR2nsZc/Y4qBcIpg3GEQaT6D3EJpXeN5yrr/7EEPfodWFzis2MTK3b5CiDqwytOn4rWwGE2Wy4g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790786592; c=relaxed/simple; bh=9qVNhXQiIwJakVgv3lYFiugnsWUMqq1/M8Uh/eY0OIQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D+KSKtC8hsx2TterOah5Jl7ML8VdeByG/+L0WQjKJFGVWn+zCCQ9nr/gnUz2mWSqMHmAaf8ldh9M76tqaaH+v2XhZxi0+qHV/qPakQejTRRjhq2e58FbhKGzzO7hHMYz8ieOkH5io18jB396774/G8HSAEwwaxOjYZLCCDIYQO4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ww/plDm5; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Ww/plDm5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0A2F1F000FF; Wed, 30 Sep 2026 16:43:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790786591; bh=KRLQs1LsnNe2aqKfCfIsuvu0Bhsfi6h2K/heQ9RAOr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ww/plDm5GF1Br68kVFa6A333lUag8kZHYAbIje0yLbXeM48wsiNCZ/7+HZcl7xM73 iQpRocNAOUL3jAp2+4LRCEnhl0o+3YBJ16j1WBnlG99W7XEj3Y7RmeOIhyk+JWYRYL h/bE2X99YnUK5WxhHnz+0vgw1EhI8LoDJ7wR4Mwk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zixuan Chai , Hangbin Liu , Eric Dumazet , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 915/982] vlan: ensure sufficient headroom in vlan_dev_hard_header() Date: Wed, 30 Sep 2026 17:27:31 +0200 Message-ID: <20260930152436.393498260@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152416.775402466@linuxfoundation.org> References: <20260930152416.775402466@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit cd5dd68267c4238795fadaf02b3575ca3f8a6500 ] Callers that only reserve ETH_HLEN or less (such as llc_alloc_frame()), or skbs allocated before dynamic device/headroom changes (e.g. toggling VLAN_FLAG_REORDER_HDR or bonding/team switching slaves), can reach vlan_dev_hard_header() with insufficient headroom and trigger skb_under_panic(). Use skb_cow_head() in vlan_dev_hard_header() when VLAN_FLAG_REORDER_HDR is not set to ensure sufficient headroom for the VLAN header(s) and the underlying device hard header. Use READ_ONCE() to read dev->hard_header_len and dev->needed_headroom as they can be updated concurrently under RTNL (e.g. in vlan_transfer_features()) while vlan_dev_hard_header() runs locklessly on the transmit path. Also avoid LL_RESERVED_SPACE(dev) here so that the extra HH_DATA_MOD alignment padding does not trigger unnecessary pskb_expand_head() reallocations on inner stacked VLAN devices after the outer VLAN header has been pushed. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: Zixuan Chai Closes: https://lore.kernel.org/netdev/cover.1789987105.git.petalzu987@gmail.com/ Link: https://lore.kernel.org/netdev/179022851638.2160803.1808206741379444999@kernel.org/ Cc: Hangbin Liu Signed-off-by: Eric Dumazet Link: https://patch.msgid.link/20260924082951.1599377-5-edumazet@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/8021q/vlan_dev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index c08228d488346..a703d7f09f502 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -53,6 +53,11 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev, int rc; if (!(vlan->flags & VLAN_FLAG_REORDER_HDR)) { + unsigned int hlen = READ_ONCE(dev->hard_header_len) + + READ_ONCE(dev->needed_headroom); + + if (skb_cow_head(skb, hlen) < 0) + return -ENOMEM; vhdr = skb_push(skb, VLAN_HLEN); vlan_tci = vlan->vlan_id; -- 2.53.0