Article View: linux.kernel.netdev
Article #7339Re: [PATCH net] net: mctp: free reassembly head skb when key_add fails on SOM
From: Jeremy Kerr
Date: Mon, 26 Oct 2026 07:12
Date: Mon, 26 Oct 2026 07:12
53 lines
10295 bytes
10295 bytes
Hi Joas & Guikin,
[merging two threads here; Guikin reported the same issue, around 12
hours earlier]
> When a start-of-message fragment creates a new reassembly key on the
> broadcast/bind path, mctp_frag_queue() stores the skb as
> key->reasm_head before the key is made observable with mctp_key_add().
>
> If mctp_key_add() fails (a race with another SOM packet for the same
> source/dest/tag, or the receiving socket going away), the error path
> only drops the key reference via mctp_key_unref(). The final key
> destructor frees the key itself but not key->reasm_head, and since the
> key was never added to any list, neither the expiry worker nor socket
> teardown can reach it to release the queued fragment. The skb is
> leaked.
OK, good catch.
> diff --git a/net/mctp/route.c b/net/mctp/route.c
> index e7c95eeac..3d79c2031 100644
> --- a/net/mctp/route.c
> +++ b/net/mctp/route.c
> @@ -552,8 +552,16 @@ static int mctp_dst_input(struct mctp_dst *dst, struct sk_buff *skb)
> * can do is drop.
> */
> rc = mctp_key_add(key, msk);
> - if (!rc)
> + if (!rc) {
> trace_mctp_key_acquire(key);
> + } else {
> + /* key_add failed: the key is not observable by
> + * any cleanup path, so free the fragment we
> + * just queued on it to avoid leaking the skb.
> + */
> + kfree_skb(key->reasm_head);
> + key->reasm_head = NULL;
> + }
We could just defer setting skb to NULL until the mctp_key_add() has
succeeded; there's already the common error path that cleans up any
remaining skb.
Alternatively, we could change the semantics mctp_key_unref() to also
free any pending reassembly, but I'm okay with the current approach of
being explicit about the state handling.
Cheers,
Jeremy
Technical Details
Message-ID:
<426ef7428413b8d05b6cc3ac22e24b1927ab5aca.camel@codeconstruct.com.au>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351710-linux-kernel-netdev=dewy.ruReferences:
<179287946888.17431.11219154409333681184@gmail.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-351710-linux-kernel-netdev=dewy.ru From: jk@codeconstruct.com.au (Jeremy Kerr) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] net: mctp: free reassembly head skb when key_add fails on SOM Date: Mon, 26 Oct 2026 15:12:38 +0800 Organization: Usenet Network Message-ID: <426ef7428413b8d05b6cc3ac22e24b1927ab5aca.camel@codeconstruct.com.au> References: <179287946888.17431.11219154409333681184@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="1247217"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:jDhVL/vXU+cpUDde/pXrU2ERma4= sha256:AoCBzhU+1SYEBNSGiP/QC1vGgpQDLsKZTd5hE+ESgIY= sha1:BAFhpldZRGGHKlGRyQIULfhCqUU= sha256:+ByGToVXSlvYBHkOcEFNtaz68t9mTMByPgkiFUmktXs= 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 DB5E4125B8C; Mon, 26 Oct 2026 10:13:39 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.049 X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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=codeconstruct.com.au 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 7IT5nT6UYGeu; Mon, 26 Oct 2026 10:13:30 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-351710-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=codeconstruct.com.au X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 33C7E125B8A; Mon, 26 Oct 2026 10:13:18 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 044EC34A62; Mon, 26 Oct 2026 07:13:00 +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=1792998779; b=oa+VI++M3txqORA64lLP5RUIn2AjtbjupXt1DEViRnkRFMEMrs1TSn96CQW1pWCc3Bex LE7q+bxU9Mhv3vqA2O43EilluW8+QlFZqRcOGNZFNp7y+9RIL/X+DPALsvU43J5rfwprd GVZ2EbxjjKCYUhybaaBCQv+ekFcA3yNxdM+PykGJ5R4SOjkjzBR2soMwC5ZK7VlhZpQb4 uFdDqJDNflk2zHGt2CdnTEyaHLGhupYE+6sEjRi3h1rjPqy6O0WqOfmbxf9SQvvu7ANZ6 7UqD2dBM+0g0Ag27rXqA4edfm5pTKwb6FdKPwQ8Cp1L3nzy9VG1/DzHZXYTsArR+JJQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792998779; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received: Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:Content-Transfer-Encoding:User-Agent:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version; bh=YfFDC1jVO97rchmqhk69xUqL3nX6bi1ZD5lzwfJRjZw=; b=fSstL+hRUgfSiWfxQ74rS8uHRS1ybITteCvrcqFr8REHKdzQ8BGADimLgBr/fjlGF61C hSfktZC4QQfDls320L7CFL4AFwVx+9QlC0TmLcyAOscXkNdermZ9WTF8HvuhS8hkES/Ao q2+gy7F2FOsJezfmaQSOLUCKQRL722pobmL0ZD2ubz8TU6xeWw2y+8931fw2dZlqcVb5z QjmvU+4Kt4x2Vn8sdaamEuVNKUzTjsncqPM7F9coAlCIjDnNuUR1Cx5PPfbscGCUqOeXH 19PAUKLo2OEltdbL3IsJp5HRqyyJDdHLUtsR47gT7u4jasQ+PHwhE0hf2tqh6kKS3ng== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=codeconstruct.com.au header.i=@codeconstruct.com.au header.a=rsa-sha256 header.s=2022a header.b=ktPyZEdE; dmarc=pass header.from=codeconstruct.com.au; spf=pass smtp.mailfrom=codeconstruct.com.au; 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 98C1D606A321; Mon, 26 Oct 2026 07:12:59 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=codeconstruct.com.au header.i=@codeconstruct.com.au header.a=rsa-sha256 header.s=2022a header.b=ktPyZEdE X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=203.29.241.158 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792998763; b=JHo0PGWlY+Zck186M4i8QxkJtq+8YPBrcor/iuUpBPlQtxoESWQ9xKIPG6qcxJXAYnNR L+GdeLkP0QT2ZFNfQa06wilgx77gX7s0udYJA2rPbsxwOZaxGyrRMqIKm46gn10mjMvFF CTeO3WJZnSq2ADeGI0PxBBGCiuGyOKK2kLENv+blp6WADaxi860e/ES5a0eAfjzct99xo Q9OUNMnjA+mBNmcj82TPkQj5CdO62utOmZQgp1Z13l4sxU08pkgC+njCgftPgqtKz4cIM rpdurbf3VQxab9rW7K6oIqaEOxC40Pjk6HWZoHBGaPom2gV1nngh7vadr3aBv+0+wHw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792998763; h=DMARC-Filter:DKIM-Signature:Received:Message-ID:Subject:From:To:Cc: Date:In-Reply-To:References:Content-Type:Content-Transfer-Encoding: User-Agent:MIME-Version; bh=YfFDC1jVO97rchmqhk69xUqL3nX6bi1ZD5lzwfJRjZw=; b=JZGzicagjWbyB8DuYlE+dT64aCkJO8KjX/MppM5TGMT1AW2y6ksVxueUFDcwKilWEZhP XkfDZ/7D2Y4qQR2U3ZbnYQAUQ0BU1fkrMMjOjirJW0xqeckbAbAv056PLlONCx7I/mZU2 90QLIXgqKvybaHNGsL2aEMZej3wu5lrek5u84lV1wnTo+q0p5u4uXrBnHgslKO65KOnKg 0CtrdUNEgODjeGnqMRuGKSpTpsxpx+kXYI1TYCIfx90SRGsWp/QhyPL19UbTitwdjA9TO Rz4+RB2zJRdKBGc6TWbIP+m2tjbzbCwvL7/cTZIq25GU/GJpag/kEuGSS9QziJh386w== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=codeconstruct.com.au; spf=pass smtp.mailfrom=codeconstruct.com.au; dkim=pass header.d=codeconstruct.com.au header.i=@codeconstruct.com.au header.a=rsa-sha256 header.s=2022a header.b=ktPyZEdE; arc=none smtp.remote-ip=203.29.241.158 X-Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C65EB606A31A; Mon, 26 Oct 2026 07:12:42 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C65EB606A31A X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=codeconstruct.com.au X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=codeconstruct.com.au X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1792998760; bh=YfFDC1jVO97rchmqhk69xUqL3nX6bi1ZD5lzwfJRjZw=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=ktPyZEdE7ep+IMO966Da/U2pwLXgZpsyqNB4nLyZpMZvldpvRPtoHqXwN74+Xh0cX 2EUxTCMp1sidVQ7hZyWAGAp7Yd1sDBof2qzgTbu/l0KpmBJJaddWtO0li/ivv21XAT Pz30JcWFWmU8As6E27P1UKdwlkkscstAABmBENK8ZuQHbbMkuzVdPCnmNEA3adHTyV 2hCqq7q6jYDpMuW/lPlhWl0Cy9qpoPMmsXyvGEzKlpMIsTZlAhRC5kXRERsupx757f +o6Se7v3VFr3Yu466NKdfKVllzHO05ftYGKFz0Z9KF2aNGkAC4TXhWvnjjJj3g4g5W mjgisOE76VZQg== X-Received: from [192.168.72.161] (210-10-213-150.per.static-ipl.aapt.com.au [210.10.213.150]) by mail.codeconstruct.com.au (Postfix) with ESMTPSA id 31AB66E6D4; Mon, 26 Oct 2026 15:12:39 +0800 (AWST) X-Cc: "David S.Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-In-Reply-To: <179287946888.17431.11219154409333681184@gmail.com> X-User-Agent: Evolution 3.56.2-0+deb13u1 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