Re: [PATCH] libceph: reject secure mode without a session key

From: Xiubo Li

Date: Thu Dec 03 2026 - 19:55:17 EST


Hi James,

Thanks for your great work.

I tested this on top of ceph-client testing in a KASAN
VM with a fake msgr2 monitor. The unpatched client oopses in
gcm_crypt() as described; with the patch, crc, secure and prefer-crc
clients all fail with "con_mode 2 without a session key", with no WARN
or KASAN report. rbd I/O against a real cluster, with cephx in every
ms_mode and with auth none, behaves the same as before.

While an equivalent fix was already reported to security@xxxxxxxxxx by
Georgi Steffenhagen earlier, as part of a larger series that is still being
handled there. That series also covers the case your notes leave out,
a con_mode the client did not offer.

Thanks,
Xiubo


On Thu, 3 Dec 2026 at 22:11, James Sawyer via B4 Relay
<devnull+james.jamessawyer.co.uk@xxxxxxxxxx> wrote:
>
> From: James Sawyer <james@xxxxxxxxxxxxxxxxx>
>
> process_auth_done() takes con_mode from the peer's AUTH_DONE frame and
> passes it to setup_crypto(). With auth_none there is no session key and
> no connection secret, and setup_crypto() only warns if the peer chose
> secure mode anyway:
>
> if (!session_key_len) {
> WARN_ON(con->v2.con_mode != CEPH_CON_MODE_CRC);
> WARN_ON(con_secret_len);
> return 0; /* auth_none */
> }
>
> The connection then carries on in secure mode with no AEAD transform.
> The first frame it encrypts, the AUTH_SIGNATURE that process_auth_done()
> prepares straight away, dereferences the NULL gcm_req:
>
> WARNING: net/ceph/messenger_v2.c:720 at setup_crypto+0x264/0x290 [libceph]
> BUG: kernel NULL pointer dereference, address: 0000000000000030
> Oops: 0002 [#1] SMP PTI
> RIP: 0010:gcm_crypt+0x1b/0xd0 [libceph]
> prepare_head_secure_small+0x8b/0xd0 [libceph]
> __prepare_control+0xdb/0x1a0 [libceph]
> process_auth_done+0x2d5/0x3d0 [libceph]
>
> This was reproduced on 7.0 with a monitor that answers a keyless client
> (name=admin, no secret) with AUTH_DONE and con_mode = SECURE. The client
> crashes whether it asked for ms_mode=secure or ms_mode=crc, because
> nothing checks the mode the peer picked against the ones the client
> offered. A client with a cephx key is not affected: it offers only cephx
> and refuses to be steered to another protocol.
>
> Make the condition the WARN_ONs describe an error, so that the
> connection fails instead.
>
> This is a different path from the one closed by the fix for
> CVE-2026-22992 (mon_handle_auth_done() now returns the auth handler's
> error). With auth_none the handler succeeds, so that fix does not apply,
> and the crash above was reproduced on a kernel that already has it.
>
> The problem was found, reproduced and fixed with the help of an AI
> coding assistant (Claude). The reproducer, a fake msgr2 monitor in
> Python, and the before/after tests ran on the author's lab machines:
> stock 7.0.0-43 oopses, and with this patch the connection is refused with
> "con_mode 2 without a session key". Built with W=1 on 7.4-rc1 with no
> warnings; checkpatch clean.
>
> Fixes: cd1a677cad99 ("libceph, ceph: implement msgr2.1 protocol (crc and secure modes)")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: James Sawyer <james@xxxxxxxxxxxxxxxxx>
> ---
> A monitor can answer a keyless (auth_none) msgr2 client's AUTH_DONE
> with con_mode = SECURE, and setup_crypto() only warns and carries on
> with no AEAD set up, so the client oopses in gcm_crypt(). Reproduced
> on 7.0 with a fake monitor, for both ms_mode=crc and ms_mode=secure
> clients. Clients with a cephx key are not affected.
>
> Notes for reviewers:
> - This is not the path fixed for CVE-2026-22992; that fix is present
> in the kernel that crashed.
> - With the patch, the client re-handshakes about 400 times a second
> while hunting after the rejection. Stock libceph does the same for its
> existing "bad con_mode" -EINVAL (measured 14,137 against 15,030
> handshakes over the same window), so the lack of backoff predates this
> change.
> - The client could also reject a con_mode it did not offer. That is
> left out here.
> ---
> net/ceph/messenger_v2.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/net/ceph/messenger_v2.c b/net/ceph/messenger_v2.c
> index b323b61e7023..85132360a2c4 100644
> --- a/net/ceph/messenger_v2.c
> +++ b/net/ceph/messenger_v2.c
> @@ -716,8 +716,16 @@ static int setup_crypto(struct ceph_connection *con,
> }
>
> if (!session_key_len) {
> - WARN_ON(con->v2.con_mode != CEPH_CON_MODE_CRC);
> - WARN_ON(con_secret_len);
> + /*
> + * auth_none yields no session key and no connection secret,
> + * so there is nothing to set up secure mode with. The peer
> + * picks con_mode, so reject anything but crc mode here.
> + */
> + if (con->v2.con_mode != CEPH_CON_MODE_CRC || con_secret_len) {
> + pr_err("con_mode %d without a session key\n",
> + con->v2.con_mode);
> + return -EINVAL;
> + }
> return 0; /* auth_none */
> }
>
>
> ---
> base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
> change-id: 20261203-ceph-msgr2-authnone-secure-acd58760af48
>
> Best regards,
> --
> James Sawyer <james@xxxxxxxxxxxxxxxxx>
>
>