Article View: linux.kernel.netdev
Article #9059Re: [PATCH net] l2tp: fix use-after-free in l2tp_udp_encap_recv()
From: netdev-bot+sashiko
Date: Fri, 30 Oct 2026 22:40
Date: Fri, 30 Oct 2026 22:40
95 lines
11428 bytes
11428 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The commit message describes a use-after-free that no code
path in the current tree can trigger.
--
l2tp: fix use-after-free in l2tp_udp_encap_recv()
This patch reorders the error paths in l2tp_udp_encap_recv() so that
tunnel->stats.rx_invalid is incremented before the session reference is
dropped. The commit message says the old order could write into a freed
tunnel when packets are processed from the socket backlog, and the patch
is tagged for stable.
> The frees are RCU deferred, which hides the bug on the regular path
> because __udp4_lib_rcv() holds rcu_read_lock(). It does not hide it on
> the backlog path: __release_sock() drops sk_lock before invoking
> sk_backlog_rcv(), takes no RCU read lock and may cond_resched() between
> packets, so a grace period can complete before the statistics update.
[ ... ]
> Found by inspection; no reproducer. Hitting the window needs a session
> teardown racing a packet on the backlog path, and the RCU deferred frees
> mean KASAN is only likely to report it with CONFIG_RCU_STRICT_GRACE_PERIOD.
[Severity: Medium]
Can the backlog path described here actually be reached?
Only one sk_backlog_rcv callback calls l2tp_udp_encap_recv(), and that is
pppol2tp_backlog_recv() in net/l2tp/l2tp_ppp.c:
static int pppol2tp_backlog_recv(struct sock *sk, struct sk_buff *skb)
{
int rc;
rc = l2tp_udp_encap_recv(sk, skb);
...
}
pppol2tp_create() installs it:
sk->sk_backlog_rcv = pppol2tp_backlog_recv;
Nothing seems to queue skbs on a PPPoL2TP socket's backlog, though.
sk_add_backlog() is called only from __sk_receive_skb(), tcp, sctp, tipc
and x25.
The callers of __sk_receive_skb() are pppoe, pptp, l2tp_ip, l2tp_ip6,
phonet and vmci. Each of them targets its own sockets, never a
PF_PPPOX / PX_PROTO_OL2TP one.
The live entry point is the UDP encap hook set up in
l2tp_tunnel_register():
.encap_rcv = l2tp_udp_encap_recv,
That hook is called only from udp_queue_rcv_one_skb() and
udpv6_queue_rcv_one_skb(). Both run under the rcu_read_lock() taken in
ip_local_deliver_finish() and ip6_input(). NF_QUEUE reinjection runs
okfn with BH disabled, which also counts as an RCU read-side section.
The free path is:
l2tp_session_put()->l2tp_session_free()->l2tp_tunnel_put()
->l2tp_tunnel_free()->kfree_rcu(tunnel, rcu)
So with the old ordering, a final put could only queue the free. The
tunnel memory would stay valid until the reader leaves the RCU section.
For the same reason, can CONFIG_RCU_STRICT_GRACE_PERIOD expose this? A
strict grace period still cannot end while the receive path holds
rcu_read_lock() or has BH disabled.
The reordering itself looks correct as hardening. Would it be more
accurate to describe it that way, and to drop or justify the
Cc: stable tag, rather than present it as a reachable use-after-free?
Also, pppol2tp_backlog_recv() appears to be unreachable, and it passes a
PPPoX sk to a function that expects a UDP tunnel socket. Could it be
removed as part of a respin?
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261027063657.1359170-1-xiaolinkui%40126.com
Technical Details
Message-ID:
<179340002340.3131.5823454250644987437@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353990-linux-kernel-netdev=dewy.ruReferences:
<20261027063657.1359170-1-xiaolinkui@126.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353990-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] l2tp: fix use-after-free in l2tp_udp_encap_recv() Date: Fri, 30 Oct 2026 22:40:23 +0000 Organization: Usenet Network Message-ID: <179340002340.3131.5823454250644987437@kernel.org> References: <20261027063657.1359170-1-xiaolinkui@126.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2327668"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:0ZPZPimOvDa3YjT99kaPQpjhGbU= sha256:D7eu3bUCo4F+WnatgdMkUs37iNupVwUvlQAMIsaTV+4= sha1:GwH42/mE9FhHe9W+cN6WD5Nb1yw= sha256:CCozUd/YWscbHq3Yqucns4IeilFIJQ/eKuNHd3Vo7gY= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 5AAE2125BBF; Sat, 31 Oct 2026 01:42:00 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PhsfO1WAfowN; Sat, 31 Oct 2026 01:41:57 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-353990-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 3DDF5125CA6; Sat, 31 Oct 2026 01:41:47 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 722062CB5C; Fri, 30 Oct 2026 22:40:38 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1793400026; b=YBndS6opVmWziBvuyLbod4FqqiF46hVyDYa9l4Qij1kQP3j+bfgxqDJ2H/EybOIzOOap eIaZ3ZjBl8ZZfJA9pldt/5MtD/WzyaoZlTeKDLVPye9IRYBWkELhbhqOFowDRvrybnRO2 ZnECerh1nnSitV3r6G0XHjVNnSEE3RkoBzd80zTY/NKEEf47KYdVlqn3O4onJFWA60Jav ToL+ge/ncbXUBC4xsVtD2Ma1WCAMIqABxuSnZVFT0MeohIjtDbak5/otiBBSpkcgBxCOL s+wo0gUwLwJhrFA1MgCQyDm2W451MIZpbxgXo8InnkaPW3cS8aDG0Ey1Ja0xy8UMXHg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793400026; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=pKaXAD++xzCTb9YAmzxK6XCkM1LAwdtdAL8cl3z8d/E=; b=HKpvoMRv2/x/Chdkh34rO1Ndfi3+HL1+yGj4m9qFz10NK9C5ZQNrUM7S/j/Wur9l6JzP pqZ1stDW4ZHHrhKr03lvfg02ESHN43ZyMTEjKLvl4InV7Kojy8OF2xW1YvE7CJHHkPa0A lQ+GgoBLXGHdYAEuc6fQcjXHw46YVMaH6QDSvkGW7h6FeQg0ppHrTs+xV+h/uTNMJzHib yr/L37qj9uasv90bTmkHk1FVt27EtbcQA4dg1sjtzNRvY7Xvc/FLpViAXM0W0n2jivPqh 5NEiBsLvN1PvgJHjCDxL3ExOrOgc4QEr37p3CgrFRsrMQM0KRrBK1nfrLKqYN1/CUfA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=U7RjqwR1; arc=fail smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 41975606A329; Fri, 30 Oct 2026 22:40:26 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=U7RjqwR1 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793400025; b=xHvUzibcf3Jw2KdyxoEwEB/9oD+k3ausFbCcqbZ765dxP6dkT7bsND2zFGz+D/ojwx5C D68QZfTyqzlpMeFvyzHSeJ3IiH5cI+qvJC10hIxXcUA0ttY6/I+zWVKp/vCOdIdwK+zVC GGxhwe8XSfPV35ueEelsfldH7g5rzYLkRX5ngmflwqp9UjQiFr2cB9anf/TM3cxklVA/C BZvKMnGZtxMDg5+8kdB08Mzq0ISalZn32FwErc0R2xVDt14Hs+wLZibks7XeftszkkU28 EmkCJ+rjxs8Fh+OAELqD0ElaBYSK1iRal5VpAgSWef+hmem8spK5xlSWwd/nBZUTaSw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793400025; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=pKaXAD++xzCTb9YAmzxK6XCkM1LAwdtdAL8cl3z8d/E=; b=F+nbgLmr874VRP/Qkgt4a7KGYgu89OO1ytrnABPmGN2d8mwRKP0nOuZ6VRokJmSlnap1 g1Wr6F3d0RoYupNwbmXMHohqWdEfCpO5URds1mQeX5Zrk3RyoMW1gy8IYX/yiSyWC1+t8 9MoN1QbGgK5PC+g9D6h32cwcNtrVNxUemqXa2+MHAEcpKx4bO4Wyae/Y5oNJSczFEWMCX WMxD5amEEMDinqsw70b8SbsmXQmnhcV26JgUoL2Abok9drRufSWmRgh17g4h/d+F6s6Di +jdsg+OC7wgOZIg7Blvq/ofwSfMQ38C58t2k9dCeHWbyuRJ+JfPqU4LEtQkD1ll91UQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=U7RjqwR1; arc=none smtp.remote-ip=100.103.45.18 X-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 25915606A31A; Fri, 30 Oct 2026 22:40:24 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCAE01F00A17; Fri, 30 Oct 2026 22:40:23 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793400024; bh=pKaXAD++xzCTb9YAmzxK6XCkM1LAwdtdAL8cl3z8d/E=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=U7RjqwR1CCYKpI3YLKiGdzMbMplGHQR6AzHAljoDcgO1qr4m2jtLoQB8sIn007k9D 7ZwJUxKa27N9A7MSEVhk+4AWJvXrmm8ZXsw+rhwfeYBtOgjOA0Nf0t10irrnjonjp0 lTh9pHEShngtoOkVUe9uBp+ZQmzaywEnOgnp9PFa5uQxBUUw/fZJQOsBHeXwhKdUZl WENVWioWxHZuz7tgv6vmptqPNl9xdsTTK0LOc7TnJLdjGkl377ZZfC7UKbL5avVjIJ eV9IDyudNPp3FKnjnoXMdm56puymFl9SVH018aSUpVM5ZNUmRklbvhrD8FjUGXxcTU XX/pa/ZrQ/HYw== X-Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, gnault@redhat.com, kuniyu@google.com, michael.bommarito@gmail.com, alice.kernel@fastmail.im, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, xiaolinkui@kylinos.cn, stable@vger.kernel.org X-In-Reply-To: <20261027063657.1359170-1-xiaolinkui@126.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list