All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ceph: fix decoding of client session messages flags
@ 2022-05-23 16:09 Luís Henriques
  2022-05-23 16:19 ` Jeff Layton
  0 siblings, 1 reply; 4+ messages in thread
From: Luís Henriques @ 2022-05-23 16:09 UTC (permalink / raw)
  To: Jeff Layton, Xiubo Li, Ilya Dryomov
  Cc: ceph-devel, linux-kernel, 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.")
Signed-off-by: Luís Henriques <lhenriques@suse.de>
---
 fs/ceph/mds_client.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 00c3de177dd6..1bd3e1bb0fdf 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -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;
 		}
 	}

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ceph: fix decoding of client session messages flags
  2022-05-23 16:09 [PATCH] ceph: fix decoding of client session messages flags Luís Henriques
@ 2022-05-23 16:19 ` Jeff Layton
  2022-05-23 16:34   ` Luís Henriques
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Layton @ 2022-05-23 16:19 UTC (permalink / raw)
  To: Luís Henriques, Xiubo Li, Ilya Dryomov; +Cc: ceph-devel, linux-kernel

On Mon, 2022-05-23 at 17:09 +0100, Luís Henriques wrote:
> 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.")
> Signed-off-by: Luís Henriques <lhenriques@suse.de>
> ---
>  fs/ceph/mds_client.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> index 00c3de177dd6..1bd3e1bb0fdf 100644
> --- a/fs/ceph/mds_client.c
> +++ b/fs/ceph/mds_client.c
> @@ -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;
>  		}
>  	}

Good catch! Should we send this to stable too?

Reviewed-by: Jeff Layton <jlayton@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ceph: fix decoding of client session messages flags
  2022-05-23 16:19 ` Jeff Layton
@ 2022-05-23 16:34   ` Luís Henriques
  2022-05-24  1:20     ` Xiubo Li
  0 siblings, 1 reply; 4+ messages in thread
From: Luís Henriques @ 2022-05-23 16:34 UTC (permalink / raw)
  To: Jeff Layton; +Cc: Xiubo Li, Ilya Dryomov, ceph-devel, linux-kernel

Jeff Layton <jlayton@kernel.org> writes:

> On Mon, 2022-05-23 at 17:09 +0100, Luís Henriques wrote:
>> 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.")
>> Signed-off-by: Luís Henriques <lhenriques@suse.de>
>> ---
>>  fs/ceph/mds_client.c | 14 +++++++++-----
>>  1 file changed, 9 insertions(+), 5 deletions(-)
>> 
>> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
>> index 00c3de177dd6..1bd3e1bb0fdf 100644
>> --- a/fs/ceph/mds_client.c
>> +++ b/fs/ceph/mds_client.c
>> @@ -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;
>>  		}
>>  	}
>
> 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.

> Reviewed-by: Jeff Layton <jlayton@kernel.org>

Cheers,
-- 
Luís

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ceph: fix decoding of client session messages flags
  2022-05-23 16:34   ` Luís Henriques
@ 2022-05-24  1:20     ` Xiubo Li
  0 siblings, 0 replies; 4+ messages in thread
From: Xiubo Li @ 2022-05-24  1:20 UTC (permalink / raw)
  To: Luís Henriques, Jeff Layton; +Cc: Ilya Dryomov, ceph-devel, linux-kernel


On 5/24/22 12:34 AM, Luís Henriques wrote:
> Jeff Layton <jlayton@kernel.org> writes:
>
>> On Mon, 2022-05-23 at 17:09 +0100, Luís Henriques wrote:
>>> 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.")
>>> Signed-off-by: Luís Henriques <lhenriques@suse.de>
>>> ---
>>>   fs/ceph/mds_client.c | 14 +++++++++-----
>>>   1 file changed, 9 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
>>> index 00c3de177dd6..1bd3e1bb0fdf 100644
>>> --- a/fs/ceph/mds_client.c
>>> +++ b/fs/ceph/mds_client.c
>>> @@ -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;
>>>   		}
>>>   	}
>> 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.

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

Thanks Luis.

-- Xiubo


>> Reviewed-by: Jeff Layton <jlayton@kernel.org>
> Cheers,


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-24  1:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-23 16:09 [PATCH] ceph: fix decoding of client session messages flags Luís Henriques
2022-05-23 16:19 ` Jeff Layton
2022-05-23 16:34   ` Luís Henriques
2022-05-24  1:20     ` Xiubo Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.