From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 158CD76025 for ; Wed, 10 Jun 2026 13:00:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781096452; cv=none; b=qE6sxhaxvzEVYagLfe9P/4rSYSx0B6gyLwxIhDa/PYZ7YwhxrGL5dhk7A5MoLA7VTsBANHXMbwsYM0XpoPq3VsnT4NpJy82ZQv3/S8ghPaFYR4r4r6WpVIadIA+33En6kBn2cjtpRWsBYDa8w0BMlFq+SpSo/53Vmr+k/ZlOj3Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781096452; c=relaxed/simple; bh=epcyt5Wh1odVH3k/9F+LSiRC9CHJsqkFCDU6Pk58NqA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=m4vISDsCWzN5fTxmhvi4i1AINqMT1U974IZykoeW4hejiqUMKpniM1ttLLAVPa96WYR5FS/WKRkzvBT0FxKz2WHm0Ak2zfXFBUMz2TYpLLZaEUYhMX0n/tucxOtszuMqTRLLr3DcfEcyKG52aNiI42FE2pQqRczDSzVByy5CK0E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0sec.ai; spf=pass smtp.mailfrom=0sec.ai; dkim=temperror (0-bit key) header.d=0sec.ai header.i=@0sec.ai header.b=XaV52jL3; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0sec.ai Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0sec.ai Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=0sec.ai header.i=@0sec.ai header.b="XaV52jL3" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-460166910e6so3516435f8f.2 for ; Wed, 10 Jun 2026 06:00:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=0sec.ai; s=google; t=1781096449; x=1781701249; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=+G46dKJififF+uN+6x6XZ6FUhL5eRIvRdEqEqHKs0cw=; b=XaV52jL3lCR5jNZfr2GbWCU0+KHc5anVVNWVt/koB/t6BFObU4PAu2YMafDQ9QyvFy cZq9x7A8WEhmDwv+fR1MUH6BwYDN1Kn8Jl2VJTk1JLFGuBW37WAjJA13Am1BVPnPoaLy iNrEwFg7QUtvhJiEMB9pf7lYo0rtKeOgIci03OouvJHwVrXRV3lIoQNomVS/yzPhTlb6 dkSXBQxB4daki2TwwjiePTMp2ETfR6vvIeMu8pje2d1+BDYV/skj5I7cVfSgmFMcjt7n D36EoWc1Yg0q+RCSmEQWmLF8d3ilOSnJ6zojwPV6vt7efl/bzgKf9hRycPmVdRvmv0fA S4cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781096449; x=1781701249; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+G46dKJififF+uN+6x6XZ6FUhL5eRIvRdEqEqHKs0cw=; b=PJx1IYs1fF8sumz8kZD56dGlJn70it9VxYtaM9HwlnklEcQHT5lR/gYjcwug3dgxU5 XflI7VlTc4m0fbDJY5dcD0ho0B6EQ9wiXqDwmp79Xj/dfIS2lxrg/bB6i+5NYDRwJrDQ 9kh1Xtf96TzvFiwJS6mdeQwz2IdVdYKWH+OqC6if3a7KuqklgdSzwf5XkEdx8jMoXkWr /YE76/WBAXZRetCW3VLi8A5sEJR2peXK1zC6/WdtkT5x+/9cE24hS3UK1vtNnEzTd6Mk +0vyHqiMMrZPAVpygCRoTG/QwgDU9LmLljBnZMsm/gazSRZbKWwWuIM2apxWqf7aS07D M/JA== X-Forwarded-Encrypted: i=1; AFNElJ/Z5esHI5lZMquYBPftJrRH8AaoZdbHm8S9jlHdeHJ4fHnjiT5RFfy2xL62qcZrVbqGUVgUVZdTLuL29Mc=@vger.kernel.org X-Gm-Message-State: AOJu0YxU5Z2HjUBlBVz9PbxsbEeJAkgy8M7KzWGECYNRL1bP+VNQ2lhI E4fgWqKim12qMhhEcLYGcqA9x5SXYZT6hrvlsFbIyt+US05IqB2bkGBPGGXmnqyfvklz X-Gm-Gg: Acq92OHZWaMcurD6swp7DXriLqXVzP7iL1E/DgVHU+3v16r9GeWPV2N5RdlC5+Mks1J r7wOFbqDmZj9kXWLa+nssLiXK7UEWOd09iPr/Gj0wvvHSSCcKBS6P1UbS819gccK47vSwnejO1x OsCTAa8WZrqrQZqY3InnBdDjtlXbANXm2ELOqLqsG5CvQeXzoMz29M6nuPe9jWR0c4eCEtEbw1n OO5o49yUnHdLaFIXll91TE2uXAr1+JulvnwlkJTX5CtqRdvpv3Hyf3Bjvv7rkUxui/POPHDle4c klTE9YTtjwTMDWBe/XUx4z8+9gX5powtf6w/8qIiSeEdDxZIYpHRiDiPaT9FQVz/vFWUjEhqPvs dHyAK8/BqB5Bnt6NF2c1xjgEjEKNQTRucm6EAq9HyC/di+u128v/WEbZLX4DPvwdS9xhASGWpvP alNos9B0VPYLEnZ/I75QEeu9/92E/BMap1bP6p6iizPBZqzjNQk1IFh3tq7TUm8KTFy6HppRCX3 al7fsdkyU6oo3sdJ74YnApG7KuMrzcX0IEhHUrX1nBu2eMLKUQFJcR9eOVP+r5h+IY= X-Received: by 2002:adf:e011:0:10b0:43c:ef4f:79e4 with SMTP id ffacd0b85a97d-4603063a15cmr27177266f8f.37.1781096448976; Wed, 10 Jun 2026 06:00:48 -0700 (PDT) Received: from PeakBook-Mini.tail8e484.ts.net ([178.197.222.237]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f2eadefsm74123638f8f.11.2026.06.10.06.00.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 10 Jun 2026 06:00:48 -0700 (PDT) From: Doruk Tan Ozturk To: Jon Maloy Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH net] tipc: fix slab-use-after-free Read in tipc_aead_decrypt_done Date: Wed, 10 Jun 2026 15:00:46 +0200 Message-ID: <20260610130046.59867-1-doruk@0sec.ai> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The async decrypt completion path mirrors the encrypt one but is missing the net reference that guards against the tipc_crypto being freed during netns teardown. When crypto_aead_decrypt() is offloaded to cryptd (the SIMD aead wrapper queues the request when crypto_simd_usable() is false), the cryptd worker runs tipc_aead_decrypt_done() asynchronously. If the bearer's netns is torn down in the meantime, tipc_exit_net() -> tipc_crypto_stop() frees the tipc_crypto, and the completion then reads it: tipc_aead_decrypt_done() dereferences aead->crypto->stats and aead->crypto->net, and tipc_crypto_rcv_complete() dereferences aead->crypto->aead[] and the node table, reading freed memory: BUG: KASAN: slab-use-after-free in tipc_crypto_rcv_complete Read of size 8 at addr ffff888104c8c808 by task kworker/3:2/70 Workqueue: cryptd cryptd_queue_worker Call Trace: tipc_crypto_rcv_complete+0x1dd6/0x2240 tipc_aead_decrypt_done+0x1c3/0x300 cryptd_aead_crypt+0x3ae/0x660 cryptd_queue_worker+0x12b/0x200 process_one_work+0x66c/0x10c0 worker_thread+0x55d/0xc80 kthread+0x269/0x340 Allocated by task 1550: tipc_crypto_start+0x7e/0x890 tipc_init_net+0x30d/0x480 ... Freed by task 116: tipc_crypto_stop+0x1a4/0x2a0 tipc_exit_net+0x11c/0x1c0 cleanup_net+0x510/0xaf0 This is the same class of bug that commit e279024617134 ("net/tipc: fix slab-use-after-free Read in tipc_aead_encrypt_done") fixed for the encrypt side. The encrypt path takes maybe_get_net(aead->crypto->net) before crypto_aead_encrypt() and drops it with put_net() on the synchronous return paths and in tipc_aead_encrypt_done(); the -EINPROGRESS /-EBUSY return keeps the reference for the async callback to release. The decrypt path was left without the equivalent guard. Mirror the encrypt-side fix on the decrypt path: take a net reference before crypto_aead_decrypt() (failing with -ENODEV and the matching bearer put if it cannot be acquired), keep it across the -EINPROGRESS/ -EBUSY async return, and drop it with put_net() on the synchronous success/error return and at the end of tipc_aead_decrypt_done(). Reproduced under KASAN on v6.12.92: a UDP bearer with a cluster key is flooded with encrypted frames from an unknown peer (driving the cluster- key decrypt path) while the bearer's netns is repeatedly torn down. The SIMD aead must be forced onto its cryptd async child for the completion to outlive tipc_crypto_stop(), and the cryptd worker was delayed to land the narrow race deterministically; with the patch applied the same workload runs cleanly. Found by 0sec automated security-research tooling while auditing the siblings of commit e279024617134. Found by 0sec automated security-research tooling (https://0sec.ai). Fixes: fc1b6d6de220 ("tipc: introduce TIPC encryption & authentication") Signed-off-by: Doruk Tan Ozturk --- net/tipc/crypto.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c index 6d3b6b89b1d1..84a6489da036 100644 --- a/net/tipc/crypto.c +++ b/net/tipc/crypto.c @@ -941,12 +941,20 @@ static int tipc_aead_decrypt(struct net *net, struct tipc_aead *aead, goto exit; } + /* Get net to avoid freed tipc_crypto when delete namespace */ + if (!maybe_get_net(aead->crypto->net)) { + tipc_bearer_put(b); + rc = -ENODEV; + goto exit; + } + /* Now, do decrypt */ rc = crypto_aead_decrypt(req); if (rc == -EINPROGRESS || rc == -EBUSY) return rc; tipc_bearer_put(b); + put_net(aead->crypto->net); exit: kfree(ctx); @@ -984,6 +992,7 @@ static void tipc_aead_decrypt_done(void *data, int err) } tipc_bearer_put(b); + put_net(net); } static inline int tipc_ehdr_size(struct tipc_ehdr *ehdr) -- 2.43.0