From: Thorsten Blum Date: Sat, 13 Dec 2025 11:04:54 +0000 (+0100) Subject: ecryptfs: Replace strcpy with strscpy in ecryptfs_validate_options X-Git-Tag: v7.0-rc1~34^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0529a804095b22bf4fe8502d1a1eb09a25a5b954;p=thirdparty%2Fkernel%2Flinux.git ecryptfs: Replace strcpy with strscpy in ecryptfs_validate_options 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(). Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1] Signed-off-by: Thorsten Blum Signed-off-by: Tyler Hicks --- diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index c12dc680f8fe..7d51e6b60f53 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "ecryptfs_kernel.h" @@ -354,13 +355,13 @@ static int ecryptfs_validate_options(struct fs_context *fc) int cipher_name_len = strlen(ECRYPTFS_DEFAULT_CIPHER); BUG_ON(cipher_name_len > ECRYPTFS_MAX_CIPHER_NAME_SIZE); - strcpy(mount_crypt_stat->global_default_cipher_name, - ECRYPTFS_DEFAULT_CIPHER); + strscpy(mount_crypt_stat->global_default_cipher_name, + ECRYPTFS_DEFAULT_CIPHER); } if ((mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES) && !ctx->fn_cipher_name_set) - strcpy(mount_crypt_stat->global_default_fn_cipher_name, - mount_crypt_stat->global_default_cipher_name); + strscpy(mount_crypt_stat->global_default_fn_cipher_name, + mount_crypt_stat->global_default_cipher_name); if (!ctx->cipher_key_bytes_set) mount_crypt_stat->global_default_cipher_key_size = 0; if ((mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES)