Skip to content

Commit 020c69c

Browse files
dhowellsPaolo Abeni
authored andcommitted
rxrpc: Truncate UTS_RELEASE for rxrpc version
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: 44ba069 ("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> Reviewed-by: Jeffrey Altman <jaltman@auristor.com> Link: https://lore.kernel.org/r/654974.1685100894@warthog.procyon.org.uk Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 34dfde4 commit 020c69c

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

net/rxrpc/af_rxrpc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,7 @@ static int __init af_rxrpc_init(void)
980980
BUILD_BUG_ON(sizeof(struct rxrpc_skb_priv) > sizeof_field(struct sk_buff, cb));
981981

982982
ret = -ENOMEM;
983+
rxrpc_gen_version_string();
983984
rxrpc_call_jar = kmem_cache_create(
984985
"rxrpc_call_jar", sizeof(struct rxrpc_call), 0,
985986
SLAB_HWCACHE_ALIGN, NULL);

net/rxrpc/ar-internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,7 @@ int rxrpc_get_server_data_key(struct rxrpc_connection *, const void *, time64_t,
10681068
/*
10691069
* local_event.c
10701070
*/
1071+
void rxrpc_gen_version_string(void);
10711072
void rxrpc_send_version_request(struct rxrpc_local *local,
10721073
struct rxrpc_host_header *hdr,
10731074
struct sk_buff *skb);

net/rxrpc/local_event.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@
1616
#include <generated/utsrelease.h>
1717
#include "ar-internal.h"
1818

19-
static const char rxrpc_version_string[65] = "linux-" UTS_RELEASE " AF_RXRPC";
19+
static char rxrpc_version_string[65]; // "linux-" UTS_RELEASE " AF_RXRPC";
20+
21+
/*
22+
* Generate the VERSION packet string.
23+
*/
24+
void rxrpc_gen_version_string(void)
25+
{
26+
snprintf(rxrpc_version_string, sizeof(rxrpc_version_string),
27+
"linux-%.49s AF_RXRPC", UTS_RELEASE);
28+
}
2029

2130
/*
2231
* Reply to a version request

0 commit comments

Comments
 (0)