Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795027260; b=V70ra32Ib5Wxvk64VAUs5hwfgsucPxbp0U6F3keLh8movsl/yxMj3DDBFR6YwjI1iQA7 rBLqkyrFga1D4iXmwwXGFNL9106o/AUgQVp4nZUPhfQm0VYBGOGoZyZ4Y85jrbTdzu0n9 mKRnWVpJaJQtkslQynOKb0IGukUxdblICoVmjFe6WSCiAry0sWAjDKUrv+SIOJ9f9bG6a LWRhbd/rSwALQ45NeNzGwsOO7DfcIXo8C77M7vu7EnaGGkTVbFHg1dp0Kp2558Q3Pbr9R UFNCl44yykT5fOxEBNjsox8gDXFsqZ+6+8WZy7iBt/fb7w5qtw4lm+3wf877mvctCBg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795027260; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=AEb+uku4FEB3FIoyi5bb7jsyU+AY5pRj41LZlPWCepw=; b=3o4JZkRaRim3u6bX1CQZX/WHZVGtJhnzae7n/Jb9LrQF0BOm/4lV8hmv50nGAyejK8FA D0IMRYPBHjXnMP8QmLwAVpTbB7u9AUMXlUsqp0YvwYRhYd5iUhSdek+mHB+WTRMFMdcOG OrUMKWqUSAfD9tFWHlbrio0sn0y4O5gSSEmdPUfwSW2PnvrnOh70ZrCHghppioRjMhdVs w5eGC+t+wgvvsQyGwv0sx5sDcAOtQJyL71uEVajkYsjHiB9PLx01y6ogpcduBWp9vTWXc 1ZfaeFMSSFNpOHG88LlZNNBL0+WXPZ+dRxwDd9/6AJ9Aank2mnseC0hqC9Hxr2a+kEw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=mYq55tzC; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 323C6606A320; Wed, 18 Nov 2026 18:40:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=mYq55tzC Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CB8E1F000C4; Wed, 18 Nov 2026 18:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795027259; bh=AEb+uku4FEB3FIoyi5bb7jsyU+AY5pRj41LZlPWCepw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mYq55tzCTejO9H3RrGM4qKq2zEPWiTRiIPITdyJwdq/oWwWs9eV/V9DCjNwUYy2T0 yOwnmRjFGU91ufAb56nxZ6jG5T0K7tTAy577uojFBXjJOiGPqEpNAMCSxx3RKROqtC oNJyG/Zg/WUi7guJSTAUYD8L6xrOpzM7Y8yCHxtU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Josef Bacik , Alexei Starovoitov , Sasha Levin Subject: [PATCH 6.18 1725/2151] bpf: Update the SRH state if End.B6 fails late Date: Wed, 18 Nov 2026 15:57:40 +0100 Message-ID: <20261118150224.677177418@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150121.603863898@linuxfoundation.org> References: <20261118150121.603863898@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Josef Bacik [ Upstream commit 427e751a231aa781441d51c42e716905ee348099 ] For SEG6_LOCAL_ACTION_END_B6 and END_B6_ENCAP bpf_lwt_seg6_action() looks for the SRH again only if bpf_push_seg6_encap() has succeeded. That function pushes the new header, for which the head of the skb is reallocated if it has not got the room, and then looks up the route to the first segment. If there is none, it returns an error, and the pointer to the SRH in seg6_bpf_srh_states still points into the old head, which has been freed. The program goes on behind the error. bpf_lwt_seg6_store_bytes() and bpf_lwt_seg6_adjust_srh() read the SRH through that pointer. Look for the SRH whatever bpf_push_seg6_encap() says. Fixes: 486cdf21583e ("bpf: add End.DT6 action to bpf_lwt_seg6_action helper") Signed-off-by: Josef Bacik Signed-off-by: Alexei Starovoitov Link: https://patch.msgid.link/20261017163745.3341787-14-alexei.starovoitov@gmail.com Signed-off-by: Sasha Levin --- net/core/filter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/core/filter.c b/net/core/filter.c index 991c218922874..8eb54d7bc7325 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -6778,8 +6778,8 @@ BPF_CALL_4(bpf_lwt_seg6_action, struct sk_buff *, skb, return -EBADMSG; err = bpf_push_seg6_encap(skb, BPF_LWT_ENCAP_SEG6_INLINE, param, param_len); - if (!err) - bpf_update_srh_state(skb); + /* The header can be in place although err says otherwise */ + bpf_update_srh_state(skb); return err; case SEG6_LOCAL_ACTION_END_B6_ENCAP: @@ -6787,8 +6787,8 @@ BPF_CALL_4(bpf_lwt_seg6_action, struct sk_buff *, skb, return -EBADMSG; err = bpf_push_seg6_encap(skb, BPF_LWT_ENCAP_SEG6, param, param_len); - if (!err) - bpf_update_srh_state(skb); + /* The header can be in place although err says otherwise */ + bpf_update_srh_state(skb); return err; default: -- 2.53.0