From: Thorsten Blum <thorsten.blum@linux.dev>
To: Tyler Hicks <code@tyhicks.com>,
Christian Brauner <brauner@kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Ankit Chauhan <ankitchauhan2065@gmail.com>,
Eric Biggers <ebiggers@kernel.org>,
Ard Biesheuvel <ardb@kernel.org>
Cc: Thorsten Blum <thorsten.blum@linux.dev>,
ecryptfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] ecryptfs: Replace strcpy with strscpy in ecryptfs_validate_options
Date: Sat, 13 Dec 2025 12:04:54 +0100 [thread overview]
Message-ID: <20251213110502.302950-6-thorsten.blum@linux.dev> (raw)
In-Reply-To: <20251213110502.302950-2-thorsten.blum@linux.dev>
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 <thorsten.blum@linux.dev>
---
fs/ecryptfs/main.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 16ea14dd2c62..636aff7a48cf 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -22,6 +22,7 @@
#include <linux/fs_stack.h>
#include <linux/sysfs.h>
#include <linux/slab.h>
+#include <linux/string.h>
#include <linux/magic.h>
#include "ecryptfs_kernel.h"
@@ -353,13 +354,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)
--
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
next prev parent reply other threads:[~2025-12-13 11:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-13 11:04 [PATCH 1/3] ecryptfs: Replace strcpy with strscpy in ecryptfs_set_default_crypt_stat_vals Thorsten Blum
2025-12-13 11:04 ` [PATCH 2/3] ecryptfs: Replace strcpy with strscpy in ecryptfs_cipher_code_to_string Thorsten Blum
2025-12-23 20:59 ` Tyler Hicks
2025-12-13 11:04 ` Thorsten Blum [this message]
2025-12-23 21:00 ` [PATCH 3/3] ecryptfs: Replace strcpy with strscpy in ecryptfs_validate_options Tyler Hicks
2025-12-23 20:57 ` [PATCH 1/3] ecryptfs: Replace strcpy with strscpy in ecryptfs_set_default_crypt_stat_vals Tyler Hicks
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251213110502.302950-6-thorsten.blum@linux.dev \
--to=thorsten.blum@linux.dev \
--cc=ankitchauhan2065@gmail.com \
--cc=ardb@kernel.org \
--cc=brauner@kernel.org \
--cc=code@tyhicks.com \
--cc=ebiggers@kernel.org \
--cc=ecryptfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.