From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) (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 3412486334 for ; Wed, 6 Aug 2025 01:10:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754442635; cv=none; b=WvSMvbNrDI5DCqKkOJxUZs4s7L4gRhmPm1BhMt9rJ4G8gY+l6HzklYtoU6arjaDc91FWzXqFgUaRzHGF36Vs7bv64tJ5+QUOGSURKCxBJy0hP31nJvGjdVH8W2Iv6r75mes0c8s9nMgDLxcuICMiw0zReFQRd0JstUAw151c3Yg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754442635; c=relaxed/simple; bh=0DVPw6O45AkUZvlXgh5UxLzYAIkyrauQJO2LLg6jfAI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=uoXl/w9DFkXw+HJltvSjqJHy8Q92eiP8+tImuGU9Bhu+FzSH9rpY4Pyufuu0E33EAxcwnCWatV6zcFs568FM11Vhbpy3rVmhHxUXLqw4Tl2jdFpUNJ6XOxFOEvjXp87vY4KuLT4LYkGVMWHsfjVQhp6LT0ivIlAz3rN5vWlGwIw= 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=KIf78Jsp; arc=none smtp.client-ip=91.218.175.171 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="KIf78Jsp" 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=1754442622; 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=Pg+CB8rchBFVimAHaKPBm1B8BHU3IpcAVyad+HNZZ+Q=; b=KIf78Jspc/VfghXIDY12PjKgHGzsDl1NesqMgJm6ZnVrjOeWM8PsgFF9TQ4Qpg5VzEl3Is 7dpxemTY+8iVZIcyjzW4vtPNtI2wNmUAP8s0g2yyBT79BRxuBA9QlBYMUY6nqcRua4CZ3a /r5ff+W1nqnc3//K6yu6y/jlEQQF8T0= 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 v2] NFSD: Fix destination buffer size in nfsd4_ssc_setup_dul() Date: Wed, 6 Aug 2025 03:10:01 +0200 Message-ID: <20250806011000.62482-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 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 --- 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