* [PATCH v2] NFSD: Fix destination buffer size in nfsd4_ssc_setup_dul()
@ 2025-08-06 1:10 Thorsten Blum
2025-08-08 14:40 ` Chuck Lever
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2025-08-06 1:10 UTC (permalink / raw)
To: Chuck Lever, Jeff Layton, NeilBrown, Olga Kornievskaia, Dai Ngo,
Tom Talpey
Cc: Thorsten Blum, stable, linux-nfs, linux-kernel
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>
---
Changes in v2:
- Use three parameter variant of strscpy() for easier backporting
- Link to v1: https://lore.kernel.org/lkml/20250805175302.29386-2-thorsten.blum@linux.dev/
---
fs/nfsd/nfs4proc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 71b428efcbb5..954543e92988 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1469,7 +1469,7 @@ static __be32 nfsd4_ssc_setup_dul(struct nfsd_net *nn, char *ipaddr,
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);
--
2.50.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] NFSD: Fix destination buffer size in nfsd4_ssc_setup_dul()
2025-08-06 1:10 [PATCH v2] NFSD: Fix destination buffer size in nfsd4_ssc_setup_dul() Thorsten Blum
@ 2025-08-08 14:40 ` Chuck Lever
0 siblings, 0 replies; 2+ messages in thread
From: Chuck Lever @ 2025-08-08 14:40 UTC (permalink / raw)
To: Jeff Layton, NeilBrown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
Thorsten Blum
Cc: Chuck Lever, stable, linux-nfs, linux-kernel
From: Chuck Lever <chuck.lever@oracle.com>
On Wed, 06 Aug 2025 03:10:01 +0200, Thorsten Blum wrote:
> 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().
>
> [...]
Applied to nfsd-testing, thanks!
[1/1] NFSD: Fix destination buffer size in nfsd4_ssc_setup_dul()
commit: 387d7905fb60d28ae3f2ff8956de626c797e4508
--
Chuck Lever
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-08 14:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-06 1:10 [PATCH v2] NFSD: Fix destination buffer size in nfsd4_ssc_setup_dul() Thorsten Blum
2025-08-08 14:40 ` Chuck Lever
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).