summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorThorsten Blum <thorsten.blum@linux.dev>2025-08-06 03:10:01 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-10-29 14:01:13 +0100
commit393ccac22d3af3596ce641cefae519a9fc981d74 (patch)
treed15f067235dd50780ed8d31e4e2cff797147d475 /fs
parent55fa669239bf5c489bab03e4279921805459cc02 (diff)
downloadlinux-393ccac22d3af3596ce641cefae519a9fc981d74.tar.gz
linux-393ccac22d3af3596ce641cefae519a9fc981d74.tar.bz2
linux-393ccac22d3af3596ce641cefae519a9fc981d74.zip
NFSD: Fix destination buffer size in nfsd4_ssc_setup_dul()
commit ab1c282c010c4f327bd7addc3c0035fd8e3c1721 upstream. Commit 5304877936c0 ("NFSD: Fix strncpy() fortify warning") replaced strncpy(,, sizeof(..)) with strlcpy(,, sizeof(..) - 1), but strlcpy() already guaranteed NUL-termination of the destination buffer and subtracting one byte potentially truncated the source string. The incorrect size was then carried over in commit 72f78ae00a8e ("NFSD: move from strlcpy with unused retval to strscpy") when switching from strlcpy() to strscpy(). Fix this off-by-one error by using the full size of the destination buffer again. Cc: stable@vger.kernel.org Fixes: 5304877936c0 ("NFSD: Fix strncpy() fortify warning") Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfsd/nfs4proc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 1da06a15b13f..2c461a389b23 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1335,7 +1335,7 @@ try_again:
return 0;
}
if (work) {
- strscpy(work->nsui_ipaddr, ipaddr, sizeof(work->nsui_ipaddr) - 1);
+ strscpy(work->nsui_ipaddr, ipaddr, sizeof(work->nsui_ipaddr));
refcount_set(&work->nsui_refcnt, 2);
work->nsui_busy = true;
list_add_tail(&work->nsui_list, &nn->nfsd_ssc_mount_list);