From: Willy Tarreau <w@1wt.eu>
To: Viacheslav Dubeyko <slava@dubeyko.com>
Cc: Dhiraj Mishra <mishra.dhiraj95@gmail.com>,
Greg KH <gregkh@linuxfoundation.org>,
idryomov@gmail.com, amarkuze@redhat.com, security@kernel.org,
ceph-devel@vger.kernel.org
Subject: Re: [SECURITY] ceph: msgr2 monitor data_len mismatch can trigger client kernel panic
Date: Fri, 1 May 2026 20:23:17 +0200 [thread overview]
Message-ID: <afTvlWJ_P1PSyqAB@1wt.eu> (raw)
In-Reply-To: <c247520dd5bfe49e22b29d221967d0fd569c2e6a.camel@dubeyko.com>
On Fri, May 01, 2026 at 11:11:44AM -0700, Viacheslav Dubeyko wrote:
> On Fri, 2026-05-01 at 21:53 +0400, Dhiraj Mishra wrote:
> > Sure noted, here is the patch.
> >
> > From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00
> > 2001
> > From: Dhiraj Mishra
> > Date: Fri, 1 May 2026 12:45:00 +0400
> > Subject: [PATCH] libceph: reject monitor replies with oversized data
> > segment
> >
> > Monitor messages can be allocated from preallocated reply messages or
> > with ceph_msg_new(), both of which may provide only front-buffer
> > storage
> > and no data items. The messenger receive path copies the wire header
> > into the selected ceph_msg and later uses hdr.data_len to decide
> > whether
> > to initialize a data cursor.
> >
> > If a malicious or compromised monitor advertises a non-zero data
> > segment
> > for one of these front-only replies, the receive path can call
> > ceph_msg_data_cursor_init() with length greater than msg->data_length
> > and
> > hit its BUG_ON() checks, crashing the client kernel.
> >
> > I verified the issue against v7.1-rc1-123-ge75a43c7cec4. The msgr2
> > trigger path is present since commit cd1a677cad99 ("libceph, ceph:
> > implement msgr2.1 protocol (crc and secure modes)"), which is
> > contained
> > in v5.11-rc1 and later. The monitor allocator pattern is older, but
> > I
> > have not tested older msgr1-only kernels.
> >
> > A concrete trigger is a monitor connection over msgr2 after
> > CEPH_CON_S_OPEN
> > where a FRAME_TAG_MESSAGE contains a monitor reply type handled by
> > mon_alloc_msg(), a valid front_len for that message type and data_len
> > = 1.
> > CEPH_MSG_MON_MAP is one such example: the message is allocated with
> > ceph_msg_new(), leaving msg->data_length and msg->num_data_items as
> > zero.
> >
> > Reject monitor replies whose wire data segment is larger than the
> > data
> > backing allocated for the selected ceph_msg, mirroring the existing
> > OSD
> > reply hardening.
> >
> > Signed-off-by: Dhiraj Mishra
> > ---
> > net/ceph/mon_client.c | 21 +++++++++++++++++++++
> > 1 file changed, 21 insertions(+)
> >
> > diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c
> > index d2cdc8ee3155..7f2293122bba 100644
> > --- a/net/ceph/mon_client.c
> > +++ b/net/ceph/mon_client.c
> > @@ -712,6 +712,7 @@ static struct ceph_msg *get_generic_reply(struct
> > ceph_connection *con,
> > struct ceph_mon_client *monc = con->private;
> > struct ceph_mon_generic_request *req;
> > u64 tid = le64_to_cpu(hdr->tid);
> > + u32 data_len = le32_to_cpu(hdr->data_len);
> > struct ceph_msg *m;
> >
> > mutex_lock(&monc->mutex);
> > @@ -720,6 +721,16 @@ static struct ceph_msg *get_generic_reply(struct
> > ceph_connection *con,
> > dout("get_generic_reply %lld dne\n", tid);
> > *skip = 1;
> > m = NULL;
> > + } else if (!req->reply) {
> > + pr_warn("%s tid %llu missing reply buffer, skipping\n",
> > + __func__, tid);
> > + *skip = 1;
> > + m = NULL;
> > + } else if (data_len > req->reply->data_length) {
> > + pr_warn("%s tid %llu data %u > preallocated %zu, skipping\n",
> > + __func__, tid, data_len, req->reply->data_length);
> > + *skip = 1;
> > + m = NULL;
> > } else {
> > dout("get_generic_reply %lld got %p\n", tid, req->reply);
> > *skip = 0;
> > @@ -1499,6 +1510,7 @@ static struct ceph_msg *mon_alloc_msg(struct
> > ceph_connection *con,
> > struct ceph_mon_client *monc = con->private;
> > int type = le16_to_cpu(hdr->type);
> > int front_len = le32_to_cpu(hdr->front_len);
> > + u32 data_len = le32_to_cpu(hdr->data_len);
> > struct ceph_msg *m = NULL;
> >
> > *skip = 0;
> > @@ -1544,6 +1556,15 @@ static struct ceph_msg *mon_alloc_msg(struct
> > ceph_connection *con,
> > ceph_msg_put(m);
> > m = ceph_msg_new(type, front_len, GFP_NOFS, false);
> > }
> > + if (m && data_len > m->data_length) {
> > + pr_warn("%s data %u > prealloc %zu (%u#%llu), skipping\n",
> > + __func__, data_len, m->data_length,
> > + (unsigned int)con->peer_name.type,
> > + le64_to_cpu(con->peer_name.num));
> > + ceph_msg_put(m);
> > + m = NULL;
> > + *skip = 1;
> > + }
> >
> > return m;
> > }
>
>
> I assume that the email has been sent not in plain text and
> ceph-devel@vger.kernel.org simply rejected the email. Could you please
> follow to the common practice of sending patches [1]?
>
> Thanks,
> Slava.
>
> [1] https://docs.kernel.org/process/submitting-patches.html
This one should help to fix your mail client's configuration:
Documentation/process/email-clients.rst
Willy
prev parent reply other threads:[~2026-05-01 18:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAG8b5tT0cqjS3D-q6Z=ufv73W69ZXfRA0FTm85uf9OEL34=-GQ@mail.gmail.com>
[not found] ` <2026050111-comprised-unreal-7b2a@gregkh>
[not found] ` <CAG8b5tSZX4OtkwLDgBCtWJPhWSoQgh9rHDzxW3bja9GkrciG0A@mail.gmail.com>
[not found] ` <afRoFf4QVANv3i-T@1wt.eu>
2026-05-01 17:03 ` [SECURITY] ceph: msgr2 monitor data_len mismatch can trigger client kernel panic Viacheslav Dubeyko
[not found] ` <CAG8b5tTm6XMXOW3gycj13PU4=jRvsvYtNKYzMzg7mQO2h+E85g@mail.gmail.com>
2026-05-01 18:11 ` Viacheslav Dubeyko
2026-05-01 18:23 ` Willy Tarreau [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=afTvlWJ_P1PSyqAB@1wt.eu \
--to=w@1wt.eu \
--cc=amarkuze@redhat.com \
--cc=ceph-devel@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=idryomov@gmail.com \
--cc=mishra.dhiraj95@gmail.com \
--cc=security@kernel.org \
--cc=slava@dubeyko.com \
/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