Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 2B4F7382F1F for ; Wed, 10 Jun 2026 20:03:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781121828; cv=none; b=KC92+JnZ9mtNImGeZeYaBnXBusbVqUZBM0dt1+zCCyDMloeTVMW900qa00h/Ae+GdHR8A7fdZHYZpyt0euIC7NilKzi0L56FpR+rZzEg+SNpLmAVtKq1YJH4zyc4a02zk8HL2EdFnS3jSUQR9YZh9G6tpAzODih4mQrLZDV8HrU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781121828; c=relaxed/simple; bh=3ZElmahT+PnwQEQ9dTHLRsZo9ZlnYm739b1Vi/iM/UQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=U1rdqXq3wC5Xa4o3XfcavjiW9TJPenI1sWqqstLKWnNWoKVR5CFmcZxA66Q15blMK03VxhHcOMDlJOpLsz2UnlWdoBorsKtQ0/zWYz0QDvj6tIJokq5yFW5WvrpkZ+/ZxCdAN6R6fBYh5SoxnD2vdbbb4Z1+MF8BmKR4fi/Jy18= 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=xVO+XLQa; arc=none smtp.client-ip=209.85.128.53 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="xVO+XLQa" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-490acbb0f89so49465285e9.0 for ; Wed, 10 Jun 2026 13:03:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=0sec.ai; s=google; t=1781121816; x=1781726616; 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=Lgzi4vGlaNMbhkiNlf7vOeCQMYkJ2z31XuHhYzUTkxY=; b=xVO+XLQaQmpBH7m8PLKN4b5MZyIUQ31Hxn7pT0yw0iUwyIZUUAzqfIFGXTUmM0tYZU 0fWrwJszh4TG6WSvHDadbC5fIio+7AxNIWJebKSTyIfL/f3BkQm5ifnmA3PFTmEV+4U9 quH9h2K1zm8XkzaorxketYnwZurxy4X9yF7u18dSC8WU0o4Fa2mup9A6gSpDmW/uV6mR cYrkAN1uLB0E254PIM1hNnCow8oxY8DFvivV4JX+3oj6XnWmcvwXN1g1HbEfHc9HRI1A VqIAOmQfiC/kL+Ac6p7Ou+nAQFtWp/+hluIAruEondvv43fafFlcVgJdAHhMG2kvRqub pJew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781121816; x=1781726616; 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=Lgzi4vGlaNMbhkiNlf7vOeCQMYkJ2z31XuHhYzUTkxY=; b=X9bFsozV6OQVBj0Io6gjgxM4lFBJemdyenu8NmQzDgarpAl2JHJ/IW7TT8EwzxR/J0 aC6V+eg6iyzsKUWJiaPunGGx8jTJhtIPLwYaZ0E9A5/X2n1GyTlufxwG36qQYnu0pMvk kf7xO/7dQrAGimScZ2xJTirgq07Wwk/+NL9xBRf9/YTl1C7SP20jl434FaSA5TQbn9Xd H8DNZzPGRWar+XOqV2CqErfi1CTnzqVk5trqK8/eItJh/av6LS6MBNkgE2t4SwdyMTL1 2ymD24x07oeUTYN8V1bWsQIEjr1tqyve9ILikYYUc/PfdkYapTCBF8hq2ul8XQt9AZV0 o3uw== X-Forwarded-Encrypted: i=1; AFNElJ+DYzL3XyLWz+Q/iOgOEZSInNI/ZfxKezt8rlsUSVpy62FQGJtFMfwVLBKk/FlOEDnpYZ7WQKcHqgtQRxg=@vger.kernel.org X-Gm-Message-State: AOJu0Yx0T3/PCaKzeEZu7FREVUZ+RaLc31PyhtvzOts3s7Zzp8Wpe0ra z7LZ5z2KFi8iX0YDv3Ndi4Mj8RblEo7qQai1Z2+D/jeSVGjyIWhTUH8e5EcBZPZBzSqs X-Gm-Gg: Acq92OEno7K+iGoP7uTHF3dUPE4hYxeM9R8F57vd8toxWdo0gt9CFVJe+qdy8eg3kRE vsLNQC1mnn6rpYwvfVnoOt0jMFjmKZhPoMTNg/p6YL5v6SfcIwDemE56nBG8tdiJHuwFx5HItr7 /bvPor9ihOFnvU89mtq1Fub4HxqTajJJCR5sEjj9iFFt/MhS9CueNxlCU+tl/skFJQ4H0T8ozSQ XrmyNAgs1p2Mll45zRPzUYlT0JZy8uCn/3w38KF0WcQiLWgeF6kXQmwutLJHTg9Io2EfKVocmXc OlbQP3EM9BBmTXnsfvshL9+wPzlSinIwf/ycU06TBReDgYgZepFuprgpVGZrYHSKbQFym+y2h73 npVP4aY9oHp1ELAndmJTQAQjyvj4Kpn1Nl6JYsUCM1uM96SN8WjL9nfZKXnsRrc1lgaN6xd2dLN Le5Bx8UVPN86B+z59jrDhaj3CrEay+KSKgdvRf8HJy65+zd8+zrV3ieuA8ln0NUkoNVI4bJyUi9 vJfiLYzZFZcCMksCIB+N/OUu9B3LEXsbeD8bDT4ZrvTyhXEA9dMpza+ X-Received: by 2002:a05:600c:4e09:b0:490:be14:bfda with SMTP id 5b1f17b1804b1-490c259a003mr461443265e9.6.1781121816053; Wed, 10 Jun 2026 13:03:36 -0700 (PDT) Received: from PeakBook-Mini.tail8e484.ts.net ([178.197.222.237]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490e246f28asm10606275e9.0.2026.06.10.13.03.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 10 Jun 2026 13:03:35 -0700 (PDT) From: Doruk Tan Ozturk To: Jon Maloy Cc: aleksander.lobakin@intel.com, 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 v2] tipc: fix slab-use-after-free Read in tipc_aead_decrypt_done Date: Wed, 10 Jun 2026 22:03:32 +0200 Message-ID: <20260610200332.33960-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(); 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") Cc: stable@vger.kernel.org Signed-off-by: Doruk Tan Ozturk Reviewed-by: Alexander Lobakin --- v2: - Add Cc: stable@vger.kernel.org and Alexander Lobakin's Reviewed-by (per his review of v1). No functional change. 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