Skip to contentSkip to conversation

ceph: fix decoding of client session messages flags

PATCH In review Luís Henriques 3 participants 4 messages May 23, 2022 – May 24, 2022 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: fix decoding of client session messages flags

The cephfs kernel client started to show the message:

ceph: mds0 session blocklisted

when mounting a filesystem. This is due to the fact that the session messages are being incorrectly decoded: the skip needs to take into account the 'len'.

While there, fixed some whitespaces too.

Fixes e1c9788cb397 ("ceph: don't rely on error_string to validate blocklisted session.")
---
 fs/ceph/mds_client.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
fs/ceph/mds_client.c +9 -5
index 00c3de177dd6..1bd3e1bb0fdf 100644
@@ -3375,13 +3375,17 @@ static void handle_session(struct ceph_mds_session *session,
 	}
 
 	if (msg_version >= 5) {
-		u32 flags;
-		/* version >= 4, struct_v, struct_cv, len, metric_spec */
-	        ceph_decode_skip_n(&p, end, 2 + sizeof(u32) * 2, bad);
+		u32 flags, len;
+
+		/* version >= 4 */
+		ceph_decode_skip_16(&p, end, bad); /* struct_v, struct_cv */
+		ceph_decode_32_safe(&p, end, len, bad); /* len */
+		ceph_decode_skip_n(&p, end, len, bad); /* metric_spec */
+
 		/* version >= 5, flags   */
-                ceph_decode_32_safe(&p, end, flags, bad);
+		ceph_decode_32_safe(&p, end, flags, bad);
 		if (flags & CEPH_SESSION_BLOCKLISTED) {
-		        pr_warn("mds%d session blocklisted\n", session->s_mds);
+			pr_warn("mds%d session blocklisted\n", session->s_mds);
 			blocklisted = true;
 		}
 	}
Reviewed-by on v1 1/1
#1 lore raw
Quoted 33 lines · Luís Henriques

The cephfs kernel client started to show the message:

ceph: mds0 session blocklisted

when mounting a filesystem. This is due to the fact that the session messages are being incorrectly decoded: the skip needs to take into account the 'len'.

While there, fixed some whitespaces too.

Fixes e1c9788cb397 ("ceph: don't rely on error_string to validate blocklisted session.")
---
 fs/ceph/mds_client.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
fs/ceph/mds_client.c +6 -3
index 00c3de177dd6..1bd3e1bb0fdf 100644
@@ -3375,13 +3375,17 @@ static void handle_session(struct ceph_mds_session *session,
 	}
 
 	if (msg_version >= 5) {
-		u32 flags;
-		/* version >= 4, struct_v, struct_cv, len, metric_spec */
-	        ceph_decode_skip_n(&p, end, 2 + sizeof(u32) * 2, bad);
+		u32 flags, len;
+
+		/* version >= 4 */
+		ceph_decode_skip_16(&p, end, bad); /* struct_v, struct_cv */
+		ceph_decode_32_safe(&p, end, len, bad); /* len */
+		ceph_decode_skip_n(&p, end, len, bad); /* metric_spec */

fs/ceph/mds_client.c static void handle_session(struct ceph_mds_session *session, · line 3391

Quoted 10 lines
fs/ceph/mds_client.c +3 -2
+
 		/* version >= 5, flags   */
-                ceph_decode_32_safe(&p, end, flags, bad);
+		ceph_decode_32_safe(&p, end, flags, bad);
 		if (flags & CEPH_SESSION_BLOCKLISTED) {
-		        pr_warn("mds%d session blocklisted\n", session->s_mds);
+			pr_warn("mds%d session blocklisted\n", session->s_mds);
 			blocklisted = true;
 		}
 	}

Good catch! Should we send this to stable too?

#2 lore raw
Quoted 38 lines · Jeff Layton
Quoted 37 lines · Luís Henriques

The cephfs kernel client started to show the message:

ceph: mds0 session blocklisted

when mounting a filesystem. This is due to the fact that the session messages are being incorrectly decoded: the skip needs to take into account the 'len'.

While there, fixed some whitespaces too.

Fixes e1c9788cb397 ("ceph: don't rely on error_string to validate blocklisted session.")
---
 fs/ceph/mds_client.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
fs/ceph/mds_client.c +8 -4
index 00c3de177dd6..1bd3e1bb0fdf 100644
@@ -3375,13 +3375,17 @@ static void handle_session(struct ceph_mds_session *session,
 	}
 
 	if (msg_version >= 5) {
-		u32 flags;
-		/* version >= 4, struct_v, struct_cv, len, metric_spec */
-	        ceph_decode_skip_n(&p, end, 2 + sizeof(u32) * 2, bad);
+		u32 flags, len;
+
+		/* version >= 4 */
+		ceph_decode_skip_16(&p, end, bad); /* struct_v, struct_cv */
+		ceph_decode_32_safe(&p, end, len, bad); /* len */
+		ceph_decode_skip_n(&p, end, len, bad); /* metric_spec */
+
 		/* version >= 5, flags   */
-                ceph_decode_32_safe(&p, end, flags, bad);
+		ceph_decode_32_safe(&p, end, flags, bad);
Quoted 8 lines

fs/ceph/mds_client.c static void handle_session(struct ceph_mds_session *session, · line 3391

Quoted 6 lines
fs/ceph/mds_client.c +1 -1
 		if (flags & CEPH_SESSION_BLOCKLISTED) {
-		        pr_warn("mds%d session blocklisted\n", session->s_mds);
+			pr_warn("mds%d session blocklisted\n", session->s_mds);
 			blocklisted = true;
 		}
 	}

Good catch! Should we send this to stable too?

Ah, yeah. I didn't explicitly tagged it as I assumed the 'Fixes:' would be enough for that. But it's probably better to do add the 'Cc: stable' too.

Quoted 1 line

Cheers,

Signature · 1 line
Luís
#3 lore raw
Quoted 47 lines · Luís Henriques
Quoted 37 lines · Jeff Layton
Quoted 36 lines · Luís Henriques

The cephfs kernel client started to show the message:

ceph: mds0 session blocklisted

when mounting a filesystem. This is due to the fact that the session messages are being incorrectly decoded: the skip needs to take into account the 'len'.

While there, fixed some whitespaces too.

Fixes e1c9788cb397 ("ceph: don't rely on error_string to validate blocklisted session.")
---
  fs/ceph/mds_client.c | 14 +++++++++-----
  1 file changed, 9 insertions(+), 5 deletions(-)
fs/ceph/mds_client.c +7 -4
index 00c3de177dd6..1bd3e1bb0fdf 100644
@@ -3375,13 +3375,17 @@ static void handle_session(struct ceph_mds_session *session,
  	}
 
  	if (msg_version >= 5) {
-		u32 flags;
-		/* version >= 4, struct_v, struct_cv, len, metric_spec */
-	        ceph_decode_skip_n(&p, end, 2 + sizeof(u32) * 2, bad);
+		u32 flags, len;
+
+		/* version >= 4 */
+		ceph_decode_skip_16(&p, end, bad); /* struct_v, struct_cv */
+		ceph_decode_32_safe(&p, end, len, bad); /* len */
+		ceph_decode_skip_n(&p, end, len, bad); /* metric_spec */
+
  		/* version >= 5, flags   */
-                ceph_decode_32_safe(&p, end, flags, bad);
Quoted 8 lines

fs/ceph/mds_client.c static void handle_session(struct ceph_mds_session *session, · line 3391

Quoted 7 lines
fs/ceph/mds_client.c +2 -1
+		ceph_decode_32_safe(&p, end, flags, bad);
  		if (flags & CEPH_SESSION_BLOCKLISTED) {
-		        pr_warn("mds%d session blocklisted\n", session->s_mds);
+			pr_warn("mds%d session blocklisted\n", session->s_mds);
  			blocklisted = true;
  		}
  	}

Good catch! Should we send this to stable too?

Quoted 3 lines

Ah, yeah. I didn't explicitly tagged it as I assumed the 'Fixes:' would be enough for that. But it's probably better to do add the 'Cc: stable' too.

Good catch! Merged into the testing branch and added the 'Cc: stable'.

Thanks Luis.

-- Xiubo

Quoted 2 lines
Quoted 1 line

Cheers,