From mboxrd@z Thu Jan 1 00:00:00 1970 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 503222F8BF0 for ; Tue, 24 Mar 2026 15:46:21 +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=1774367183; cv=none; b=N5cAQr9Ubp06/CxDdoI6fsg3hLRuEo1d7UufE3cGN+o+kSP+ZXQoyKBWhTH6/WpVXd5gwWnxdy7Yy+HhJktG62wa6EkQzVEMVXibRQ06ndsJ5Ho0p8DRjEl+I3kSf01pSjkQMxSoTDbNSB66mfavpt8+zosk3Q6U6N3odLQg/ls= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774367183; c=relaxed/simple; bh=XffSarZaEBOeolZgHFQs/5tTASW346HgQ/YR6cRcqHE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=B5VmWNi/MpjiAERYfNHnTl3kD419C382Y4Do4zjp5GRE7Onva377ja22yCoLYdLgCOQk8ekJ9mibwRq8ow/wNO6a3gUgtcjp+m5h5p+Lwqz4jHCpTBZAcOhcraxP348NsBpFisDpehqxZoY1F/g1MoXZ1Iuu2bOWtGg6bqpSx6c= 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=FkjH1pz8; 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="FkjH1pz8" 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=1774367179; 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=B5E1Y6XKH+HpqxbJwzX9N37GmFffE75VCtQ9DolZ5M8=; b=FkjH1pz8Bf0mEV19lwsD57dqSvQzvdrizdbRSHtj18PBKQU9j76PcP3C8JHZFZEdccxn15 2m3V6YQaOnVtw3kdAGlmfVZaPw+yXAngFQ58fXMW684N7o8yTLDjd7T+Q2McwARnqnzzwt 9iiDLsMavIbEWj8zEA5u8Qrf4eq5thU= From: Thorsten Blum To: David Howells , Marc Dionne Cc: Thorsten Blum , linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] afs: replace deprecated strcpy with strscpy in afs_lookup_atsys Date: Tue, 24 Mar 2026 16:45:16 +0100 Message-ID: <20260324154515.205796-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=1535; i=thorsten.blum@linux.dev; h=from:subject; bh=XffSarZaEBOeolZgHFQs/5tTASW346HgQ/YR6cRcqHE=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDJmHNnb/u7wsWOHmlIC5NWYBN+Ve3a2LrTS4Vcu+9/y5V y1bnGY/7ihlYRDjYpAVU2R5MOvHDN/SmspNJhE7YeawMoEMYeDiFICJPD3K8D+jtrBaOb54mce0 L99/tP7ZGXKtaFGpR4H58VRXx001en0M/6sm1Es8ecxbL7Fz989ljYYff/68XCU1++OeNeWelyc F+XADAA== 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. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1] 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 78caef3f1338..89d5c9c354d4 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -914,7 +915,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(""); @@ -935,13 +936,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;