Article View: linux.kernel.netdev
Article #6540Re: [PATCH net v3] tipc: fix refcount panic in tipc_rcv() when receiving shared skb
From: Eric Dumazet
Date: Thu, 22 Oct 2026 17:20
Date: Thu, 22 Oct 2026 17:20
191 lines
16110 bytes
16110 bytes
Le jeu. 22 oct. 2026 ร 03:15, Tung Nguyen <tung.quang.nguyen@est.tech> a รฉcrit :
>
> TIPC assumes that the received skb is not shared with other users.
> However, syzbot reports a bug triggered by receiving a shared skb:
>
> ...
> RIP: 0010:pskb_expand_head+0x135a/0x13a0 net/core/skbuff.c:2308
> __pskb_pull_tail+0x111/0x1870 net/core/skbuff.c:2890
> skb_cow_data+0x2ed/0xc50 net/core/skbuff.c:5398
> tipc_aead_decrypt net/tipc/crypto.c:892 [inline]
> tipc_crypto_rcv+0x346/0x23d0 net/tipc/crypto.c:1843
> tipc_rcv+0x4b7/0x1040 net/tipc/node.c:2119
> tipc_l2_rcv_msg+0x2d9/0x470 net/tipc/bearer.c:669
> deliver_ptype_list_skb net/core/dev.c:2533 [inline]
> ...
>
> The root cause is that local delivery hooks in the kernel (e.g.,
> deliver_skb()) may increment the skb's reference count (`users`) before
> TIPC processes it on ingress.
>
> Fix this by calling skb_share_check() to ensure exclusive ownership
> before passing the skb to tipc_rcv(). As TIPC needs to modify the skb's
> data, the cloned skb needs to be uncloned in tipc_sk_conn_proto_rcv(),
> tipc_sk_filter_connect(), tipc_msg_lookup_dest() and tipc_link_tnl_rcv().
>
> Reported-by: syzbot+0017742620a9d06f06ef@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=0017742620a9d06f06ef
> Closes: https://lore.kernel.org/all/20261018145928.58317-1-ngocthang2710.1999@gmail.com/T/
> Fixes: 6e967adf798a ("tipc: relocate common functions from media to bearer")
This commit only moved recv_msg() from eth_media.c to bearer.c,
the bug was there from day 0.
Fixes: b97bf3fd8f6a ("[TIPC] Initial merge")
> Co-developed-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
> Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
> Signed-off-by: Tung Nguyen <tung.quang.nguyen@est.tech>
> ---
> v3: Use skb_share_check() to unshare the skb and unclone that skb
> when needed.
> v2: https://lore.kernel.org/all/20261020104852.90350-1-tung.quang.nguyen@est.tech/
> v1: https://lore.kernel.org/all/20261019050648.287309-1-tung.quang.nguyen@est.tech/
>
> net/tipc/bearer.c | 4 ++++
> net/tipc/link.c | 7 +++++++
> net/tipc/msg.c | 3 +++
> net/tipc/socket.c | 10 ++++++++++
> 4 files changed, 24 insertions(+)
>
> diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
> index 05dcd2f9e887..5e7e220fa7f5 100644
> --- a/net/tipc/bearer.c
> +++ b/net/tipc/bearer.c
> @@ -659,6 +659,10 @@ static int tipc_l2_rcv_msg(struct sk_buff *skb, struct net_device *dev,
> {
> struct tipc_bearer *b;
>
> + skb = skb_share_check(skb, GFP_ATOMIC);
> + if (!skb)
> + return NET_RX_DROP;
> +
This part is fine, and is what other L3 handlers do.
The skb_unclone() parts are addressing a different (and older) issue:
TIPC already receives cloned skbs today, as soon as a packet tap
(tcpdump) is active, since af_packet clones the shared skb.
Please split this into two patches: the skb_share_check() one
(small, easy to backport), and a second one dealing with cloned skbs.
Some comments on the second part:
> rcu_read_lock();
> b = rcu_dereference(dev->tipc_ptr) ?:
> rcu_dereference(orig_dev->tipc_ptr);
> diff --git a/net/tipc/link.c b/net/tipc/link.c
> index 6427c69f8929..d7ce384d3b89 100644
> --- a/net/tipc/link.c
> +++ b/net/tipc/link.c
> @@ -1363,6 +1363,13 @@ static int tipc_link_tnl_rcv(struct tipc_link *l, struct sk_buff *skb,
> }
> kfree_skb(skb);
> } else {
> + if (skb_unclone(skb, GFP_ATOMIC) == -ENOMEM) {
> + kfree_skb(skb);
> + return tipc_link_fsm_evt(l, LINK_FAILURE_EVT);
> + }
> +
> + hdr = buf_msg(skb);
> +
> /* Set fragment type for buf_append */
> if (msg_fragm_no(hdr) == 1)
> msg_set_type(hdr, FIRST_FRAGMENT);
> diff --git a/net/tipc/msg.c b/net/tipc/msg.c
> index b0bba0feef56..9a222e15ed31 100644
> --- a/net/tipc/msg.c
> +++ b/net/tipc/msg.c
> @@ -736,6 +736,9 @@ bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, int *err)
> sk.node = tipc_scope2node(net, scope);
> if (!tipc_nametbl_lookup_anycast(net, &ua, &sk))
> return false;
> + if (skb_unclone(skb, GFP_ATOMIC) == -ENOMEM)
> + return false;
> + msg = buf_msg(skb);
> msg_incr_reroute_cnt(msg);
> if (sk.node != self)
> msg_set_prevnode(msg, self);
> diff --git a/net/tipc/socket.c b/net/tipc/socket.c
> index d5d70eb230b5..9789d1ce6bd4 100644
> --- a/net/tipc/socket.c
> +++ b/net/tipc/socket.c
> @@ -1345,6 +1345,10 @@ static void tipc_sk_conn_proto_rcv(struct tipc_sock *tsk, struct sk_buff *skb,
> tsk_peer_port(tsk));
> sk->sk_state_change(sk);
>
> + if (skb_unclone(skb, GFP_ATOMIC) == -ENOMEM)
> + goto exit;
> + hdr = buf_msg(skb);
> +
> /* State change is ignored if socket already awake,
> * - convert msg to abort msg and add to inqueue
> */
> @@ -1359,6 +1363,9 @@ static void tipc_sk_conn_proto_rcv(struct tipc_sock *tsk, struct sk_buff *skb,
> tsk->probe_unacked = false;
>
> if (mtyp == CONN_PROBE) {
> + if (skb_unclone(skb, GFP_ATOMIC) == -ENOMEM)
> + goto exit;
tipc_msg_reverse() always allocates a new skb, so there is no need
to unclone here. Simply set the type on the new skb:
if (tipc_msg_reverse(onode, &skb, TIPC_OK)) {
msg_set_type(buf_msg(skb), CONN_PROBE_REPLY);
__skb_queue_tail(xmitq, skb);
}
> + hdr = buf_msg(skb);
> msg_set_type(hdr, CONN_PROBE_REPLY);
> if (tipc_msg_reverse(onode, &skb, TIPC_OK))
> __skb_queue_tail(xmitq, skb);
> @@ -2223,6 +2230,9 @@ static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb,
> return true;
> /* Empty ACK-, - wake up sleeping connect() and drop */
> sk->sk_state_change(sk);
> + if (skb_unclone(skb, GFP_ATOMIC) == -ENOMEM)
> + break;
The break leads to the "Abort connection setup attempt" path, after
tipc_sk_finish_conn() was already called. A memory allocation failure
should not abort a connection that was just established.
msg_set_dest_droppable() is only used here to ask the caller to
silently drop the packet. Now that the skb is not shared, a bit in
TIPC_SKB_CB() (or a different return value) would avoid both the
header write and this new error path.
> + hdr = buf_msg(skb);
> msg_set_dest_droppable(hdr, 1);
> return false;
> }
> --
> 2.53.0
>
skb_unclone() returns 0 or -ENOMEM, the usual form is:
if (skb_unclone(skb, GFP_ATOMIC))
Because it is very possible that in the future skb_unclone() start
returning other error codes instead of crashing with BUG_ON()
pw-bot: cr
Technical Details
Message-ID:
<CAL4WiiogRi0-zhfw1vHxQMsf30TTb-vFZymQQgCwiCpTs_Ca+g@mail.gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350717-linux-kernel-netdev=dewy.ruReferences:
<20261022011539.6882-1-tung.quang.nguyen@est.tech>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-350717-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v3] tipc: fix refcount panic in tipc_rcv() when
receiving shared skb
Date: Thu, 22 Oct 2026 19:20:43 +0200
Organization: Usenet Network
Message-ID: <CAL4WiiogRi0-zhfw1vHxQMsf30TTb-vFZymQQgCwiCpTs_Ca+g@mail.gmail.com>
References: <20261022011539.6882-1-tung.quang.nguyen@est.tech>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="273521"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:e9C653bhKtm2jUOgG2tEzKJs/Es= sha256:tyABTYJBAut8lculSrDMD1FX6+O3hqE1rRJzKg3u5lE=
sha1:7nZwWNsRNz79hM8IZ5PnXXRIEfU= sha256:JnQh4zqaPSoOnrHbSOWjoORbZ4ESwzb442PftqZ+WFg=
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 812A311130D; Thu, 22 Oct 2026 20:21:21 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.738
X-Spam-Status: No, score=-3.738 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.339, 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 js6qynQhuBRr;
Thu, 22 Oct 2026 20:21:18 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-350717-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 A78001112E6; Thu, 22 Oct 2026 20:21:08 +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 C14572B51C; Thu, 22 Oct 2026 17:21:02 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1792689660;
b=Q2z5iu8XdUABjCxLxfFZCsPG09y+ciU3+Ox3b/JM0tI9tdX2rEgARomOFZaj5yA5xjOa
9E6ByaWBCsPGRI4SK2HQvT80PI2DkVwCI77W4CinkmZqQDSX9ja2VMW5NScyUOoa5/zeR
PYUAsxKFv23J3CmoVnUGWsMdBi8hnfHBDvznt6YYtUfatB7atbxp/0jSghSOydjx+8Rob
JL/lDEx/GZCwfNmLKmv3PbPl33NvqJgfNno7CLRwZFeZYb/sAESNiP73NR5WZOHcenH4E
CPjgnlhmJKDj4hflDQBHZbwDZdFSEpDrR8A/7XAqmwcaRSBhTQ99/ShoZU7S35ihjTQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792689660;
h=X-Original-To:Received:Received:DKIM-Signature:Received:
X-Gm-Message-State:X-Received:X-Mailing-List:List-Id:List-Post:
List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
MIME-Version:References:In-Reply-To:From:Date:
X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:Subject:To:Cc:
Content-Type:Content-Transfer-Encoding;
bh=dMUwdNNlX47GZDregQd1aU44dhCXXAKv5Dr+YMUKeZM=;
b=D9X7/bwLBWQNnBI3/pvG2FPmeXvGLmsi+N1l01gM/4tep+gJ0e0699r1MmP8uyZoh+Ir
pSxeC/9DKw93+BdZixhGIjXO4SE4ltjf8kTwp0U8Y51rYdJ01m+P70KK/tTcEsaMRaz6e
5crlGi08j4iYFVSYoLTtrubgfRVSl7Mv4S5jG/NyHeyImufjL8Cd26U3L+6FbXZ+er/A/
ADnqUC1CWaxBKh4yBHNjuY52uj41Jug7zNqd+uF0xlYeb2T5n/wR5eArLQY7pI5oMgVGj
rJLyIcJ4AMfCm0epyk/3Oje0L7NTmyv3ph2+xSKDm7UYgJcxLByG4aG75rShxAgKr5w==
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=EKt9hsN6;
arc=pass header.oldest-pass=0 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 16743606A326;
Thu, 22 Oct 2026 17:21:00 +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=EKt9hsN6
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=1792689659;
b=NedDZrvFc8u+E5Basal1E/n1qfOCAkBcKvKiSoN+lomK70cs4VE/N1y0zLJBiOKGvrVo
+GOPPSP9QAPBRrUsQsLM3qEBm0JDbiT69gG5qLwGDnhcRzKVpDxqKIDlDCv8ATMbxW4Nq
P385QbGfSZSP3dLmFY9H5fm3WZKaxTCOUgh4gVfJ+wnO0FfmSIpECNT7SXMEGK7qeCXoU
RJpGTk90ockUacp4tdx3xbQvFUL3P/p3vP84SkneIKSDHGcvA5FlbIlERvyRB4KQAx2yO
NzQLxZi9AwC2jdUYG+lxnNQ7ojUDGMq5JkodGow82VMfz9P0Yj87pHzfWnS4fevAsIw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792689659;
h=Received:DKIM-Signature:Received:X-Gm-Message-State:X-Received:
MIME-Version:References:In-Reply-To:From:Date:
X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:Subject:To:Cc:
Content-Type:Content-Transfer-Encoding;
bh=dMUwdNNlX47GZDregQd1aU44dhCXXAKv5Dr+YMUKeZM=;
b=b1ss0Nwick0M2xtkOanV0ET1HPgGLphYwSnQkp4fIdcg7rA4D+Lzd25Z6dT2JQKlVqNP
9IhKCothzL/vky23n4la2ujlA1PlI2A/yQ15+bYImQhyLkc3rwCaJFMulFC36WISuJ24C
TJxO6YNV9nuJXtP6DhCep8yV9InMJ4SthKHafskCJwH8q0MS3/Q0zsFvYQ2/nbmcJXvoI
BhOdtwFi74j6ahHArkD6RqKxc2eel3iPHmWoFapl+0+Cmp1NZsW1xfVbimk5dL5b8PB9s
c2QmZridwH1pZ1oMO1aUIWITim9VtxTnFj5Ur9mIAgpNY4Ph0EEmjLZ9rj0fX7FECZQ==
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=EKt9hsN6;
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 E632E606A319
for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 17:20:58 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 803431F031E0
for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 17:20:58 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
s=k20260515; t=1792689658;
bh=dMUwdNNlX47GZDregQd1aU44dhCXXAKv5Dr+YMUKeZM=;
h=References:In-Reply-To:From:Date:Subject:To:Cc;
b=EKt9hsN6+QlaQlXb3P5LlOvTa9SI9XXwkm8go83sjLImRym9h3iIEQfNKwWc0a5fB
TjWrRTzeX1z+yv2nUL5e/fxIHi29hrwP3I9i9sY2wMk6v0xAezPcmfBTWqpO1HSFJb
Sn7gcdL+NDApcRr41wm3s37DJqD5ZLsbFlCZM3f6rNtguY4zsVm1BztPTT6SPB+x5y
FClSksaawhVSQbFiTNl7WEGh6046jrcSbZfEnh4+qcKyuHGYcyh5SXq8EUN3b+BXnq
6ebjmPynUK8CQxnRKfymtJ5DXjBIrDhdSZLjzIZlNt7HnMFNgFiwznlB1k5odDWOrJ
7WxJG5XTjOefA==
X-Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-3ab35e31f6dso10281471fa.1
for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 10:20:58 -0700 (PDT)
X-Gm-Message-State: AFq9FYJQUm901DmmIK82yFLtZYLxwSEXMy+DqbZsWe2NUUr67LVpc0L0
R6nxenTav3V1D9k63tMOxil+tPSYsag5JTfwM9sAZ0G9L9qGEFMlZVoQSjzSy/Ps7JejyokWfM6
UD6CaAGkDMjP8eNGhONTNM0s6lROi26Y=
X-Received: by 2002:a05:651c:345c:b0:3a9:8775:5f11 with SMTP id
38308e7fff4ca-3ac510bec21mr8824021fa.4.1792689657196; Thu, 22 Oct 2026
10:20:57 -0700 (PDT)
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
X-In-Reply-To: <20261022011539.6882-1-tung.quang.nguyen@est.tech>
X-Gmail-Original-Message-ID: <CAL4WiiogRi0-zhfw1vHxQMsf30TTb-vFZymQQgCwiCpTs_Ca+g@mail.gmail.com>
X-Gm-Features: AclHuK-56Zydd_GeAy-1gWfJYTA5OtsO83acQye9DAJXnz3sd6lhVU7KKN_WBGY
X-Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
pabeni@redhat.com, jmaloy@redhat.com, horms@kernel.org,
tipc-discussion@lists.sourceforge.net,
syzbot+0017742620a9d06f06ef@syzkaller.appspotmail.com,
Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>