linux/net/mctp
Joas Antonio dos Santos d2bfe74a8f net: mctp: free reassembly head skb when key_add fails on SOM
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.

Free key->reasm_head on the key_add failure path before releasing the
key.  Other teardown paths (__mctp_key_done_in(), EOM delivery) already
clear reasm_head before the final unref, so this only affects the
failure path.

Fixes: 4a992bbd36 ("mctp: Implement message fragmentation & reassembly")
Signed-off-by: Joas Antonio dos Santos <joasantonio108@gmail.com>
Reported-by: Guikun Yang <yangguikun19@qq.com>
Closes: https://lore.kernel.org/all/tencent_43A65D51143E18518EA968DF9323694EFD08@qq.com/
Acked-by: Jeremy Kerr <jk@codeconstruct.com.au>
Link: https://patch.msgid.link/179287946888.17431.11219154409333681184@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-10-29 10:48:51 +01:00
..
test treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
af_mctp.c mctp: convert to getsockopt_iter 2026-05-10 10:11:07 -07:00
device.c net/mctp: publish the mctp_dev only after it is initialised 2026-09-25 16:34:40 -07:00
Kconfig net: mctp: tests: Test that outgoing skbs have flow data populated 2024-02-22 13:32:55 +01:00
Makefile mctp: Add test utils 2021-10-03 14:35:41 +01:00
neigh.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
route.c net: mctp: free reassembly head skb when key_add fails on SOM 2026-10-29 10:48:51 +01:00