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.

Cc: stable@vger.kernel.org
Fixes: e1c9788cb397 ("ceph: don't rely on error_string to validate blocklisted session.")
Signed-off-by: Luís Henriques <lhenriques@suse.de>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>

authored by Luís Henriques and committed by Ilya Dryomov ea16567f 5e56776d

+9 -5
+9 -5
fs/ceph/mds_client.c
··· 3425 } 3426 3427 if (msg_version >= 5) { 3428 - u32 flags; 3429 - /* version >= 4, struct_v, struct_cv, len, metric_spec */ 3430 - ceph_decode_skip_n(&p, end, 2 + sizeof(u32) * 2, bad); 3431 /* version >= 5, flags */ 3432 - ceph_decode_32_safe(&p, end, flags, bad); 3433 if (flags & CEPH_SESSION_BLOCKLISTED) { 3434 - pr_warn("mds%d session blocklisted\n", session->s_mds); 3435 blocklisted = true; 3436 } 3437 }
··· 3425 } 3426 3427 if (msg_version >= 5) { 3428 + u32 flags, len; 3429 + 3430 + /* version >= 4 */ 3431 + ceph_decode_skip_16(&p, end, bad); /* struct_v, struct_cv */ 3432 + ceph_decode_32_safe(&p, end, len, bad); /* len */ 3433 + ceph_decode_skip_n(&p, end, len, bad); /* metric_spec */ 3434 + 3435 /* version >= 5, flags */ 3436 + ceph_decode_32_safe(&p, end, flags, bad); 3437 if (flags & CEPH_SESSION_BLOCKLISTED) { 3438 + pr_warn("mds%d session blocklisted\n", session->s_mds); 3439 blocklisted = true; 3440 } 3441 }