netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Truncate UTS_RELEASE for rxrpc version
@ 2023-05-25 21:13 Kenny Ho
  2023-05-25 22:09 ` David Howells
  0 siblings, 1 reply; 5+ messages in thread
From: Kenny Ho @ 2023-05-25 21:13 UTC (permalink / raw)
  To: David Laight, Jakub Kicinski, Andrew Lunn, Marc Dionne, Kenny Ho,
	David Howells, David S. Miller, Eric Dumazet, Paolo Abeni,
	linux-afs, netdev, linux-kernel, alexander.deucher
  Cc: Kenny Ho

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

Per https://web.mit.edu/kolya/afs/rx/rx-spec
"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."

Current implementation causes compile error when WERROR is turned on and
when UTS_RELEASE exceed the length of 49 (making the version string more
than 64 characters.)

Signed-off-by: Kenny Ho <Kenny.Ho@amd.com>
---
 net/rxrpc/local_event.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/rxrpc/local_event.c b/net/rxrpc/local_event.c
index 19e929c7c38b..90af6fbb9266 100644
--- a/net/rxrpc/local_event.c
+++ b/net/rxrpc/local_event.c
@@ -16,8 +16,6 @@
 #include <generated/utsrelease.h>
 #include "ar-internal.h"
 
-static const char rxrpc_version_string[65] = "linux-" UTS_RELEASE " AF_RXRPC";
-
 /*
  * Reply to a version request
  */
@@ -30,6 +28,7 @@ static void rxrpc_send_version_request(struct rxrpc_local *local,
 	struct sockaddr_rxrpc srx;
 	struct msghdr msg;
 	struct kvec iov[2];
+	static char rxrpc_version_string[65];
 	size_t len;
 	int ret;
 
@@ -38,6 +37,12 @@ static void rxrpc_send_version_request(struct rxrpc_local *local,
 	if (rxrpc_extract_addr_from_skb(&srx, skb) < 0)
 		return;
 
+	if (!rxrpc_version_string[0])
+		snprintf(rxrpc_version_string,
+				sizeof(rxrpc_version_string),
+				"linux-%.49s AF_RXRPC",
+				UTS_RELEASE);
+
 	msg.msg_name	= &srx.transport;
 	msg.msg_namelen	= srx.transport_len;
 	msg.msg_control	= NULL;
-- 
2.25.1


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

end of thread, other threads:[~2023-05-26  9:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-25 21:13 [PATCH] Truncate UTS_RELEASE for rxrpc version Kenny Ho
2023-05-25 22:09 ` David Howells
2023-05-25 22:28   ` Kenny Ho
2023-05-25 22:52   ` David Howells
2023-05-26  9:38   ` Simon Horman

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