Netdev List
 help / color / mirror / Atom feed
From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: Doruk Tan Ozturk <doruk@0sec.ai>
Cc: Jon Maloy <jmaloy@redhat.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: Re: [PATCH net] tipc: fix slab-use-after-free Read in tipc_aead_decrypt_done
Date: Wed, 10 Jun 2026 16:18:16 +0200	[thread overview]
Message-ID: <dfe4dc2f-c740-45e6-b564-d4d601f7c2ff@intel.com> (raw)
In-Reply-To: <20260610130046.59867-1-doruk@0sec.ai>

From: Doruk Tan Ozturk <doruk@0sec.ai>
Date: Wed, 10 Jun 2026 15:00:46 +0200

> 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")

Cc: stable@vger.kernel.org ?

> Signed-off-by: Doruk Tan Ozturk <doruk@0sec.ai>

Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>

Thanks,
Olek

      reply	other threads:[~2026-06-10 14:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-10 13:00 [PATCH net] tipc: fix slab-use-after-free Read in tipc_aead_decrypt_done Doruk Tan Ozturk
2026-06-10 14:18 ` Alexander Lobakin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dfe4dc2f-c740-45e6-b564-d4d601f7c2ff@intel.com \
    --to=aleksander.lobakin@intel.com \
    --cc=davem@davemloft.net \
    --cc=doruk@0sec.ai \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jmaloy@redhat.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tipc-discussion@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox