ceph-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: ceph-devel@vger.kernel.org
Cc: pdonnell@redhat.com, idryomov@gmail.com, xiubli@redhat.com
Subject: [PATCH] ceph: ensure we return an error when parsing corrupt mdsmap
Date: Mon, 30 Aug 2021 08:10:45 -0400	[thread overview]
Message-ID: <20210830121045.13994-1-jlayton@kernel.org> (raw)

Commit ba5e57de7b20 (ceph: reconnect to the export targets on new
mdsmaps) changed ceph_mdsmap_decode to "goto corrupt" when given a
bogus mds rank in the export targets. It did not set the err variable
however, which caused that function to return a NULL pointer instead of
a proper ERR_PTR value for the error.

Fix this by setting err before doing the "goto corrupt".

URL: https://tracker.ceph.com/issues/52436
Fixes: ba5e57de7b20 ("ceph: reconnect to the export targets on new mdsmaps")
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ceph/mdsmap.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

I'll plan to fold this change into the original patch since it hasn't
been merged yet. Let me know if you have objections.

diff --git a/fs/ceph/mdsmap.c b/fs/ceph/mdsmap.c
index d995cb02d30c..61d67cbcb367 100644
--- a/fs/ceph/mdsmap.c
+++ b/fs/ceph/mdsmap.c
@@ -263,8 +263,10 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end, bool msgr2)
 				goto nomem;
 			for (j = 0; j < num_export_targets; j++) {
 				target = ceph_decode_32(&pexport_targets);
-				if (target >= m->possible_max_rank)
+				if (target >= m->possible_max_rank) {
+					err = -EIO;
 					goto corrupt;
+				}
 				info->export_targets[j] = target;
 			}
 		} else {
-- 
2.31.1


             reply	other threads:[~2021-08-30 12:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-30 12:10 Jeff Layton [this message]
2021-08-30 13:01 ` [PATCH] ceph: ensure we return an error when parsing corrupt mdsmap Xiubo Li

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=20210830121045.13994-1-jlayton@kernel.org \
    --to=jlayton@kernel.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=idryomov@gmail.com \
    --cc=pdonnell@redhat.com \
    --cc=xiubli@redhat.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;
as well as URLs for NNTP newsgroup(s).