From 2cd74adb5a65d3ac44f103e0b4278d35db0b389f Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Mar 25 2024 01:19:36 +0000 Subject: net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr() (git-fixes). --- diff --git a/patches.suse/net-sunrpc-Fix-an-off-by-one-in-rpc_sockaddr2uaddr.patch b/patches.suse/net-sunrpc-Fix-an-off-by-one-in-rpc_sockaddr2uaddr.patch new file mode 100644 index 0000000..fddc8a9 --- /dev/null +++ b/patches.suse/net-sunrpc-Fix-an-off-by-one-in-rpc_sockaddr2uaddr.patch @@ -0,0 +1,36 @@ +From: Christophe JAILLET +Date: Tue, 24 Oct 2023 23:58:20 +0200 +Subject: [PATCH] net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr() +Git-commit: d6f4de70f73a106986ee315d7d512539f2f3303a +Patch-mainline: v6.9-rc1 +References: git-fixes + +The intent is to check if the strings' are truncated or not. So, >= should +be used instead of >, because strlcat() and snprintf() return the length of +the output, excluding the trailing NULL. + +Fixes: a02d69261134 ("SUNRPC: Provide functions for managing universal addresses") +Signed-off-by: Christophe JAILLET +Reviewed-by: Benjamin Coddington +Signed-off-by: Trond Myklebust +Acked-by: NeilBrown + +--- + net/sunrpc/addr.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/net/sunrpc/addr.c ++++ b/net/sunrpc/addr.c +@@ -283,10 +283,10 @@ char *rpc_sockaddr2uaddr(const struct so + } + + if (snprintf(portbuf, sizeof(portbuf), +- ".%u.%u", port >> 8, port & 0xff) > (int)sizeof(portbuf)) ++ ".%u.%u", port >> 8, port & 0xff) >= (int)sizeof(portbuf)) + return NULL; + +- if (strlcat(addrbuf, portbuf, sizeof(addrbuf)) > sizeof(addrbuf)) ++ if (strlcat(addrbuf, portbuf, sizeof(addrbuf)) >= sizeof(addrbuf)) + return NULL; + + return kstrdup(addrbuf, gfp_flags); diff --git a/series.conf b/series.conf index b2faa06..63d74d3 100644 --- a/series.conf +++ b/series.conf @@ -65022,6 +65022,7 @@ patches.suse/SUNRPC-fix-some-memleaks-in-gssx_dec_option_array.patch patches.suse/NFSD-Reset-cb_seq_status-after-NFS4ERR_DELAY.patch patches.suse/NFSD-Retransmit-callbacks-after-client-reconnects.patch + patches.suse/net-sunrpc-Fix-an-off-by-one-in-rpc_sockaddr2uaddr.patch # dhowells/linux-fs keys-uefi patches.suse/0001-KEYS-Allow-unrestricted-boot-time-addition-of-keys-t.patch