netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] rxrpc: Truncate UTS_RELEASE for rxrpc version
@ 2023-05-26 11:34 David Howells
  2023-05-27 11:59 ` Simon Horman
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: David Howells @ 2023-05-26 11:34 UTC (permalink / raw)
  To: netdev
  Cc: dhowells, Kenny Ho, Marc Dionne, Andrew Lunn, David Laight,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-afs, linux-kernel

    
UTS_RELEASE has a maximum length of 64 which can cause rxrpc_version to
exceed the 65 byte message limit.

Per the rx spec[1]: "If a server receives a packet with a type value of 13,
and the client-initiated flag set, it should respond with a 65-byte payload
containing a string that identifies the version of AFS software it is
running."

The current implementation causes a compile error when WERROR is turned on
and/or UTS_RELEASE exceeds the length of 49 (making the version string more
than 64 characters).

Fix this by generating the string during module initialisation and limiting
the UTS_RELEASE segment of the string does not exceed 49 chars.  We need to
make sure that the 64 bytes includes "linux-" at the front and " AF_RXRPC"
at the back as this may be used in pattern matching.

Fixes: 44ba06987c0b ("RxRPC: Handle VERSION Rx protocol packets")
Reported-by: Kenny Ho <Kenny.Ho@amd.com>
Link: https://lore.kernel.org/r/20230523223944.691076-1-Kenny.Ho@amd.com/
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Kenny Ho <Kenny.Ho@amd.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Andrew Lunn <andrew@lunn.ch>
cc: David Laight <David.Laight@ACULAB.COM>
cc: "David S. Miller" <davem@davemloft.net>
cc: Eric Dumazet <edumazet@google.com>
cc: Jakub Kicinski <kuba@kernel.org>
cc: Paolo Abeni <pabeni@redhat.com>
cc: linux-afs@lists.infradead.org
cc: netdev@vger.kernel.org
Link: https://web.mit.edu/kolya/afs/rx/rx-spec [1]
---
 net/rxrpc/af_rxrpc.c    |    1 +
 net/rxrpc/ar-internal.h |    1 +
 net/rxrpc/local_event.c |   11 ++++++++++-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
index 31f738d65f1c..da0b3b5157d5 100644
--- a/net/rxrpc/af_rxrpc.c
+++ b/net/rxrpc/af_rxrpc.c
@@ -980,6 +980,7 @@ static int __init af_rxrpc_init(void)
 	BUILD_BUG_ON(sizeof(struct rxrpc_skb_priv) > sizeof_field(struct sk_buff, cb));
 
 	ret = -ENOMEM;
+	rxrpc_gen_version_string();
 	rxrpc_call_jar = kmem_cache_create(
 		"rxrpc_call_jar", sizeof(struct rxrpc_call), 0,
 		SLAB_HWCACHE_ALIGN, NULL);
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index 5d44dc08f66d..e8e14c6f904d 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -1068,6 +1068,7 @@ int rxrpc_get_server_data_key(struct rxrpc_connection *, const void *, time64_t,
 /*
  * local_event.c
  */
+void rxrpc_gen_version_string(void);
 void rxrpc_send_version_request(struct rxrpc_local *local,
 				struct rxrpc_host_header *hdr,
 				struct sk_buff *skb);
diff --git a/net/rxrpc/local_event.c b/net/rxrpc/local_event.c
index 5e69ea6b233d..993c69f97488 100644
--- a/net/rxrpc/local_event.c
+++ b/net/rxrpc/local_event.c
@@ -16,7 +16,16 @@
 #include <generated/utsrelease.h>
 #include "ar-internal.h"
 
-static const char rxrpc_version_string[65] = "linux-" UTS_RELEASE " AF_RXRPC";
+static char rxrpc_version_string[65]; // "linux-" UTS_RELEASE " AF_RXRPC";
+
+/*
+ * Generate the VERSION packet string.
+ */
+void rxrpc_gen_version_string(void)
+{
+	snprintf(rxrpc_version_string, sizeof(rxrpc_version_string),
+		 "linux-%.49s AF_RXRPC", UTS_RELEASE);
+}
 
 /*
  * Reply to a version request


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

* Re: [PATCH net] rxrpc: Truncate UTS_RELEASE for rxrpc version
  2023-05-26 11:34 [PATCH net] rxrpc: Truncate UTS_RELEASE for rxrpc version David Howells
@ 2023-05-27 11:59 ` Simon Horman
  2023-05-27 14:20 ` Jeffrey E Altman
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2023-05-27 11:59 UTC (permalink / raw)
  To: David Howells
  Cc: netdev, Kenny Ho, Marc Dionne, Andrew Lunn, David Laight,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-afs, linux-kernel

On Fri, May 26, 2023 at 12:34:54PM +0100, David Howells wrote:
>     
> UTS_RELEASE has a maximum length of 64 which can cause rxrpc_version to
> exceed the 65 byte message limit.
> 
> Per the rx spec[1]: "If a server receives a packet with a type value of 13,
> and the client-initiated flag set, it should respond with a 65-byte payload
> containing a string that identifies the version of AFS software it is
> running."
> 
> The current implementation causes a compile error when WERROR is turned on
> and/or UTS_RELEASE exceeds the length of 49 (making the version string more
> than 64 characters).
> 
> Fix this by generating the string during module initialisation and limiting
> the UTS_RELEASE segment of the string does not exceed 49 chars.  We need to
> make sure that the 64 bytes includes "linux-" at the front and " AF_RXRPC"
> at the back as this may be used in pattern matching.
> 
> Fixes: 44ba06987c0b ("RxRPC: Handle VERSION Rx protocol packets")
> Reported-by: Kenny Ho <Kenny.Ho@amd.com>
> Link: https://lore.kernel.org/r/20230523223944.691076-1-Kenny.Ho@amd.com/
> Signed-off-by: David Howells <dhowells@redhat.com>
> Acked-by: Kenny Ho <Kenny.Ho@amd.com>
> cc: Marc Dionne <marc.dionne@auristor.com>
> cc: Andrew Lunn <andrew@lunn.ch>
> cc: David Laight <David.Laight@ACULAB.COM>
> cc: "David S. Miller" <davem@davemloft.net>
> cc: Eric Dumazet <edumazet@google.com>
> cc: Jakub Kicinski <kuba@kernel.org>
> cc: Paolo Abeni <pabeni@redhat.com>
> cc: linux-afs@lists.infradead.org
> cc: netdev@vger.kernel.org
> Link: https://web.mit.edu/kolya/afs/rx/rx-spec [1]

Reviewed-by: Simon Horman <simon.horman@corigine.com>


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

* Re: [PATCH net] rxrpc: Truncate UTS_RELEASE for rxrpc version
  2023-05-26 11:34 [PATCH net] rxrpc: Truncate UTS_RELEASE for rxrpc version David Howells
  2023-05-27 11:59 ` Simon Horman
@ 2023-05-27 14:20 ` Jeffrey E Altman
  2023-05-27 15:08 ` Jeffrey E Altman
  2023-05-30  8:10 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Jeffrey E Altman @ 2023-05-27 14:20 UTC (permalink / raw)
  To: David Howells, netdev
  Cc: Kenny Ho, Marc Dionne, Andrew Lunn, David Laight,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-afs, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3459 bytes --]

On 5/26/2023 7:34 AM, David Howells wrote:
>      
> UTS_RELEASE has a maximum length of 64 which can cause rxrpc_version to
> exceed the 65 byte message limit.
>
> Per the rx spec[1]: "If a server receives a packet with a type value of 13,
> and the client-initiated flag set, it should respond with a 65-byte payload
> containing a string that identifies the version of AFS software it is
> running."
>
> The current implementation causes a compile error when WERROR is turned on
> and/or UTS_RELEASE exceeds the length of 49 (making the version string more
> than 64 characters).
>
> Fix this by generating the string during module initialisation and limiting
> the UTS_RELEASE segment of the string does not exceed 49 chars.  We need to
> make sure that the 64 bytes includes "linux-" at the front and " AF_RXRPC"
> at the back as this may be used in pattern matching.
>
> Fixes: 44ba06987c0b ("RxRPC: Handle VERSION Rx protocol packets")
> Reported-by: Kenny Ho <Kenny.Ho@amd.com>
> Link: https://lore.kernel.org/r/20230523223944.691076-1-Kenny.Ho@amd.com/
> Signed-off-by: David Howells <dhowells@redhat.com>
> Acked-by: Kenny Ho <Kenny.Ho@amd.com>
> cc: Marc Dionne <marc.dionne@auristor.com>
> cc: Andrew Lunn <andrew@lunn.ch>
> cc: David Laight <David.Laight@ACULAB.COM>
> cc: "David S. Miller" <davem@davemloft.net>
> cc: Eric Dumazet <edumazet@google.com>
> cc: Jakub Kicinski <kuba@kernel.org>
> cc: Paolo Abeni <pabeni@redhat.com>
> cc: linux-afs@lists.infradead.org
> cc: netdev@vger.kernel.org
> Link: https://web.mit.edu/kolya/afs/rx/rx-spec [1]
> ---
>   net/rxrpc/af_rxrpc.c    |    1 +
>   net/rxrpc/ar-internal.h |    1 +
>   net/rxrpc/local_event.c |   11 ++++++++++-
>   3 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
> index 31f738d65f1c..da0b3b5157d5 100644
> --- a/net/rxrpc/af_rxrpc.c
> +++ b/net/rxrpc/af_rxrpc.c
> @@ -980,6 +980,7 @@ static int __init af_rxrpc_init(void)
>   	BUILD_BUG_ON(sizeof(struct rxrpc_skb_priv) > sizeof_field(struct sk_buff, cb));
>   
>   	ret = -ENOMEM;
> +	rxrpc_gen_version_string();
>   	rxrpc_call_jar = kmem_cache_create(
>   		"rxrpc_call_jar", sizeof(struct rxrpc_call), 0,
>   		SLAB_HWCACHE_ALIGN, NULL);
> diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
> index 5d44dc08f66d..e8e14c6f904d 100644
> --- a/net/rxrpc/ar-internal.h
> +++ b/net/rxrpc/ar-internal.h
> @@ -1068,6 +1068,7 @@ int rxrpc_get_server_data_key(struct rxrpc_connection *, const void *, time64_t,
>   /*
>    * local_event.c
>    */
> +void rxrpc_gen_version_string(void);
>   void rxrpc_send_version_request(struct rxrpc_local *local,
>   				struct rxrpc_host_header *hdr,
>   				struct sk_buff *skb);
> diff --git a/net/rxrpc/local_event.c b/net/rxrpc/local_event.c
> index 5e69ea6b233d..993c69f97488 100644
> --- a/net/rxrpc/local_event.c
> +++ b/net/rxrpc/local_event.c
> @@ -16,7 +16,16 @@
>   #include <generated/utsrelease.h>
>   #include "ar-internal.h"
>   
> -static const char rxrpc_version_string[65] = "linux-" UTS_RELEASE " AF_RXRPC";
> +static char rxrpc_version_string[65]; // "linux-" UTS_RELEASE " AF_RXRPC";
> +
> +/*
> + * Generate the VERSION packet string.
> + */
> +void rxrpc_gen_version_string(void)
> +{
> +	snprintf(rxrpc_version_string, sizeof(rxrpc_version_string),
> +		 "linux-%.49s AF_RXRPC", UTS_RELEASE);
> +}
>   
>   /*
>    * Reply to a version request
>
Reviewed-by: Jeffrey Altman <jaltman@auristor.com>



[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4039 bytes --]

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

* Re: [PATCH net] rxrpc: Truncate UTS_RELEASE for rxrpc version
  2023-05-26 11:34 [PATCH net] rxrpc: Truncate UTS_RELEASE for rxrpc version David Howells
  2023-05-27 11:59 ` Simon Horman
  2023-05-27 14:20 ` Jeffrey E Altman
@ 2023-05-27 15:08 ` Jeffrey E Altman
  2023-05-30  8:10 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Jeffrey E Altman @ 2023-05-27 15:08 UTC (permalink / raw)
  To: David Howells, netdev
  Cc: Kenny Ho, Marc Dionne, Andrew Lunn, David Laight,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-afs, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3392 bytes --]

On 5/26/2023 7:34 AM, David Howells wrote:
> UTS_RELEASE has a maximum length of 64 which can cause rxrpc_version to
> exceed the 65 byte message limit.
>
> Per the rx spec[1]: "If a server receives a packet with a type value 
> of 13,
> and the client-initiated flag set, it should respond with a 65-byte 
> payload
> containing a string that identifies the version of AFS software it is
> running."
>
> The current implementation causes a compile error when WERROR is turned on
> and/or UTS_RELEASE exceeds the length of 49 (making the version string 
> more
> than 64 characters).
>
> Fix this by generating the string during module initialisation and 
> limiting
> the UTS_RELEASE segment of the string does not exceed 49 chars. We need to
> make sure that the 64 bytes includes "linux-" at the front and " AF_RXRPC"
> at the back as this may be used in pattern matching.
>
> Fixes: 44ba06987c0b ("RxRPC: Handle VERSION Rx protocol packets")
> Reported-by: Kenny Ho <Kenny.Ho@amd.com>
> Link: https://lore.kernel.org/r/20230523223944.691076-1-Kenny.Ho@amd.com/
> Signed-off-by: David Howells <dhowells@redhat.com>
> Acked-by: Kenny Ho <Kenny.Ho@amd.com>
> cc: Marc Dionne <marc.dionne@auristor.com>
> cc: Andrew Lunn <andrew@lunn.ch>
> cc: David Laight <David.Laight@ACULAB.COM>
> cc: "David S. Miller" <davem@davemloft.net>
> cc: Eric Dumazet <edumazet@google.com>
> cc: Jakub Kicinski <kuba@kernel.org>
> cc: Paolo Abeni <pabeni@redhat.com>
> cc: linux-afs@lists.infradead.org
> cc: netdev@vger.kernel.org
> Link: https://web.mit.edu/kolya/afs/rx/rx-spec [1]
> ---
> net/rxrpc/af_rxrpc.c | 1 +
> net/rxrpc/ar-internal.h | 1 +
> net/rxrpc/local_event.c | 11 ++++++++++-
> 3 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
> index 31f738d65f1c..da0b3b5157d5 100644
> --- a/net/rxrpc/af_rxrpc.c
> +++ b/net/rxrpc/af_rxrpc.c
> @@ -980,6 +980,7 @@ static int __init af_rxrpc_init(void)
> BUILD_BUG_ON(sizeof(struct rxrpc_skb_priv) > sizeof_field(struct 
> sk_buff, cb));
> ret = -ENOMEM;
> + rxrpc_gen_version_string();
> rxrpc_call_jar = kmem_cache_create(
> "rxrpc_call_jar", sizeof(struct rxrpc_call), 0,
> SLAB_HWCACHE_ALIGN, NULL);
> diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
> index 5d44dc08f66d..e8e14c6f904d 100644
> --- a/net/rxrpc/ar-internal.h
> +++ b/net/rxrpc/ar-internal.h
> @@ -1068,6 +1068,7 @@ int rxrpc_get_server_data_key(struct 
> rxrpc_connection *, const void *, time64_t,
> /*
> * local_event.c
> */
> +void rxrpc_gen_version_string(void);
> void rxrpc_send_version_request(struct rxrpc_local *local,
> struct rxrpc_host_header *hdr,
> struct sk_buff *skb);
> diff --git a/net/rxrpc/local_event.c b/net/rxrpc/local_event.c
> index 5e69ea6b233d..993c69f97488 100644
> --- a/net/rxrpc/local_event.c
> +++ b/net/rxrpc/local_event.c
> @@ -16,7 +16,16 @@
> #include <generated/utsrelease.h>
> #include "ar-internal.h"
> -static const char rxrpc_version_string[65] = "linux-" UTS_RELEASE " 
> AF_RXRPC";
> +static char rxrpc_version_string[65]; // "linux-" UTS_RELEASE " 
> AF_RXRPC";
> +
> +/*
> + * Generate the VERSION packet string.
> + */
> +void rxrpc_gen_version_string(void)
> +{
> + snprintf(rxrpc_version_string, sizeof(rxrpc_version_string),
> + "linux-%.49s AF_RXRPC", UTS_RELEASE);
> +}
> /*
> * Reply to a version request
>
Reviewed-by: Jeffrey Altman <jaltman@auristor.com>





[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4039 bytes --]

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

* Re: [PATCH net] rxrpc: Truncate UTS_RELEASE for rxrpc version
  2023-05-26 11:34 [PATCH net] rxrpc: Truncate UTS_RELEASE for rxrpc version David Howells
                   ` (2 preceding siblings ...)
  2023-05-27 15:08 ` Jeffrey E Altman
@ 2023-05-30  8:10 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-05-30  8:10 UTC (permalink / raw)
  To: David Howells
  Cc: netdev, Kenny.Ho, marc.dionne, andrew, David.Laight, davem,
	edumazet, kuba, pabeni, linux-afs, linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Fri, 26 May 2023 12:34:54 +0100 you wrote:
> UTS_RELEASE has a maximum length of 64 which can cause rxrpc_version to
> exceed the 65 byte message limit.
> 
> Per the rx spec[1]: "If a server receives a packet with a type value of 13,
> and the client-initiated flag set, it should respond with a 65-byte payload
> containing a string that identifies the version of AFS software it is
> running."
> 
> [...]

Here is the summary with links:
  - [net] rxrpc: Truncate UTS_RELEASE for rxrpc version
    https://git.kernel.org/netdev/net/c/020c69c1a793

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-05-30  8:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-26 11:34 [PATCH net] rxrpc: Truncate UTS_RELEASE for rxrpc version David Howells
2023-05-27 11:59 ` Simon Horman
2023-05-27 14:20 ` Jeffrey E Altman
2023-05-27 15:08 ` Jeffrey E Altman
2023-05-30  8:10 ` patchwork-bot+netdevbpf

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).