From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-177.mta1.migadu.com (out-177.mta1.migadu.com [95.215.58.177]) (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 A6798314B62 for ; Sat, 6 Jun 2026 21:23:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780781036; cv=none; b=Rx0mMMr/VNCKzaN5A+OHr4MXEn1L7qKo0FFYFOlSoHe3hCXH1Rj3H2NN/Vfd2uv2prZZrTts902qm5EX9df2o51WN+qtSzhKDgNCRGgBjz8byRezXK1yMk304veH8vVkyJzUyiaTsl+IbLYdfwMWkrcE/+srQHyyBtF9SewYjWY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780781036; c=relaxed/simple; bh=l6LPN4L5iHk9VXpuj5EylZDhS7gfTxDy1gB4FHwqGDQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=f+KM9CHXWCvjnrQKITGszYkIZnwyuW5oeQ5hS4vXFUB8WheBm0lZ+9vBvTPROoPDcuqu0HKpPk/stV0z6lNBjlgdSu12Pv3xvjH1nro0ERZeRMidObwaKzc7+NXjb/i9YY7xx2vEAKA1HpRDTU1XWsmVw6bY1tUYjjc3Oh/viKY= 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=V6rfSGPY; arc=none smtp.client-ip=95.215.58.177 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="V6rfSGPY" 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=1780781033; 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=Q+plRHeESeNSsPrqGxgKvrlmi464+/Ue73vQvqfrtzI=; b=V6rfSGPYhcwuqj7ngIsxUjnjt827rW2Ib52Tu3KIT/vLdKcP9G3v0rHMxc9C7PZm5KKv5C oH9G80jtCCN3Nup0rizgazF2KF9/BQKC4KUREYxYO5Nhx5gfexgdsY0kEUOi2hPlkkQ+J8 AU7c/xgSDmz/jmNewpIIsTNZjH28rRc= From: Thorsten Blum To: David Howells , Marc Dionne Cc: Thorsten Blum , linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND 1/2] afs: replace deprecated strcpy with strscpy in afs_lookup_atsys Date: Sat, 6 Jun 2026 23:23:16 +0200 Message-ID: <20260606212315.21574-4-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1531; i=thorsten.blum@linux.dev; h=from:subject; bh=l6LPN4L5iHk9VXpuj5EylZDhS7gfTxDy1gB4FHwqGDQ=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDFkq/YcTNqUahUqZO03ykpEJXsPF6NXT6/XBo2edm0JvK 8PBA6wdpSwMYlwMsmKKLA9m/ZjhW1pTuckkYifMHFYmkCEMXJwCMJEJNowMM3yvlWy8sH9Zi9V5 RdPsPEZdHo7Gh76lZ7/ObxcPTqtbwciwVbH/CdtWbv5/F6wvv13DbXdz17vAaKXUTV9+nfes2KL NCAA= X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT strcpy() has been deprecated [1] because it performs no bounds checking on the destination buffer, which can lead to buffer overflows. Replace it with the safer strscpy(), drop the manual length check and the now-unused local length variable. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy Signed-off-by: Thorsten Blum --- fs/afs/dir.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index 498b99ccdf0e..080664b67861 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -901,7 +902,7 @@ static struct dentry *afs_lookup_atsys(struct inode *dir, struct dentry *dentry) struct afs_net *net = afs_i2net(dir); struct dentry *ret; char *buf, *p, *name; - int len, i; + int i; _enter(""); @@ -922,13 +923,11 @@ static struct dentry *afs_lookup_atsys(struct inode *dir, struct dentry *dentry) for (i = 0; i < subs->nr; i++) { name = subs->subs[i]; - len = dentry->d_name.len - 4 + strlen(name); - if (len >= AFSNAMEMAX) { + if (strscpy(p, name, AFSNAMEMAX - (p - buf)) < 0) { ret = ERR_PTR(-ENAMETOOLONG); goto out_s; } - strcpy(p, name); ret = lookup_noperm(&QSTR(buf), dentry->d_parent); if (IS_ERR(ret) || d_is_positive(ret)) goto out_s;