From nobody Sun Oct 5 10:51:29 2025 Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C888295504 for ; Tue, 5 Aug 2025 17:55:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754416519; cv=none; b=Xhtcqjhtv7iYy+5k5Qv6NL8xKo8y3VnfjxMKWho9x2Ri6uRvUmtkuuvxe4yDc8GcDk/plCrhN2Rya5soD2hAveK39CY6goDNLPX1QwliT4BI776tzaeJjl+fwAmGqFl2KXy95eB0WyL3arafaMTQauVuEeSjAByD9sAx6Smf/J4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754416519; c=relaxed/simple; bh=TZly8mud1T3RB8nAlENz1FLPsbjtlRIUVXzbtKTHP5c=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Kn//wHn7grLF5wOodGLTmF+ehHNa6Jcsdl+xOEo4QmjpzO+GjXmEbCSp+cCTGOOtsw5q0eHqGHatfzYY/lsobzsEQg2h0W7tdnyZko4tfmqi80rb+kK1bynMUNIcZAHRDQ7mLei2h0Tn56jDWtHjEa/ulnpPZa3A/1xgQXMxJQ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=V5dtunmS; arc=none smtp.client-ip=95.215.58.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="V5dtunmS" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1754416504; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=vulfXIFmexpfA5lwRoGk96ZZXlWrhV40376EMZHa1Sg=; b=V5dtunmSPVsFyztOawBJbnTGI5dGhqjdJaE8bb5+Pzlq6mrdXLk7eD/7IsU23iBkUH6fU9 akb7ZYhXaHqkK1w84zPx0rbsX0RpjqPs5z5uierAVEB6wwMscyCtyvvW2Jwa8EQyOATjv4 s8QaAhSD4yQS0x7xd/f/BERBA/tZVEI= From: Thorsten Blum To: Chuck Lever , Jeff Layton , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: Thorsten Blum , stable@vger.kernel.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] NFSD: Fix destination buffer size in nfsd4_ssc_setup_dul() Date: Tue, 5 Aug 2025 19:53:02 +0200 Message-ID: <20250805175302.29386-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" 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 --- 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..32be002a248f 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); refcount_set(&work->nsui_refcnt, 2); work->nsui_busy =3D true; list_add_tail(&work->nsui_list, &nn->nfsd_ssc_mount_list); --=20 2.50.1