From nobody Sat Feb 7 20:40:34 2026 Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.172]) (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 69C8D343D64 for ; Wed, 12 Nov 2025 17:26:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762968419; cv=none; b=LapOJ7Bhb2SOyy11xA/vilX430Bzjv+oCvd8qbKXgoNwqT8N9INVlBOuPy2Hrs4T7RknlnVbnduiZLstoZbOlZpMYYMWT4dm3dGLmMOI/W76GMJ+aN+YvlLCz1aW4IiuoFKtyTgUKHR+wXB8pqTfBfTxOnJb23vMXBW3oI981q4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762968419; c=relaxed/simple; bh=Vww80A/tmPmtlGgln5DXCkTxy836HcNmtk+7zPO6H60=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Ccu2ymf+TlY0n0yLQxbyHsvJh/7VYjit58EV16yfke5GQfrhwzQgF4O0+jUv2UCVyt0d1RIjhg8J2WuOxFdYT4hNzHCIApDnb2j7WJjTUpKfotJeqMb8Hi6MPcox1wPPkc3qUgzfbX1H2O/tRZdBUeZ2CgvoXuKtAwHmOHdJ12Q= 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=QUUHmyd/; arc=none smtp.client-ip=95.215.58.172 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="QUUHmyd/" 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=1762968415; 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=Vw+aWUqyEnl9n5yqdS3oYeHCoeQauABP394dxgMfzUY=; b=QUUHmyd/5tAWR0FQBPuySPzvW6XNgvqHZl9b3SVLUqO8EHK/+PXRDMguZxRrWREUTg0Jhh YvGDEGdGs7tbrNCClAIvmFwjYs25UafE4BpKmtlh/7fcz6EvIiC4GqWDWl1FiSdg37DcY7 zfXhsuXVgCfBNppzt4++EjI+TjU0MhU= From: Thorsten Blum To: David Howells , Jarkko Sakkinen , Paul Moore , James Morris , "Serge E. Hallyn" Cc: Thorsten Blum , keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] keys: Replace memcpy with strscpy in proc_keys_show Date: Wed, 12 Nov 2025 18:26:21 +0100 Message-ID: <20251112172620.4254-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" Use strscpy() to copy strings into the fixed-size buffer 'xbuf' instead of hardcoding the number of bytes to copy. This improves maintainability and ensures the buffer is always NUL-terminated. Signed-off-by: Thorsten Blum --- security/keys/proc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/security/keys/proc.c b/security/keys/proc.c index 4f4e2c1824f1..1d380766f45d 100644 --- a/security/keys/proc.c +++ b/security/keys/proc.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "internal.h" =20 @@ -199,9 +200,9 @@ static int proc_keys_show(struct seq_file *m, void *v) /* come up with a suitable timeout value */ expiry =3D READ_ONCE(key->expiry); if (expiry =3D=3D TIME64_MAX) { - memcpy(xbuf, "perm", 5); + strscpy(xbuf, "perm"); } else if (now >=3D expiry) { - memcpy(xbuf, "expd", 5); + strscpy(xbuf, "expd"); } else { timo =3D expiry - now; =20 --=20 2.51.0