From nobody Mon Dec 1 22:35:44 2025 Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) (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 7F9CB322DD1 for ; Wed, 26 Nov 2025 11:44:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764157483; cv=none; b=o1OqWBHYYqbzDk0QuBCKDkNrYiepPo15V9E7xOTxJoH0FL48u0hCpM+IgZY0UROS6A5ERFAL88uqxSDYjJah3hN5LLStbcU/6fCBvx2Q3n/P1ifEIxvAWecJfu4svnTlZmxFs5ZYRa4ouF7ailIhCQPOQMAxkT+bILSRR78bVpw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764157483; c=relaxed/simple; bh=PovGOu+ng2ff7batpOmbwC5wyvQBlTfjHOgS/NSXJaI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=mcd8hj963KQ0iLVOqix7nfNdSkOHfq8JaDW+bjabKeT4WZwtrJgFiIxIbf9wBTB07mCWt12E6/Kn1drbh4LIWRjSF2ReOMZRMhTKYXeSdDrhpAEnkm7ddlK+oh89N/hF3JDHL4xgUpLv8oVMyGXNfwXx+uzCTd59aIT1omfQSEg= 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=qAIFz2ld; arc=none smtp.client-ip=95.215.58.188 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="qAIFz2ld" 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=1764157468; 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=+sOOZHFPAZ3S4mQVgj3ivWqQgtNn2xlRIdwQR8B/Ksc=; b=qAIFz2ld3oxQGp/rOe+MnbPgDjm9iLvNnHUzdua13vvBWmos1EymY0rDK2GQsfW929XEdL QTcOAYkZCZcLqAa2Do4gUyDU4LbUvgkHMYGtndIKA6CgT5NklJ74oqdqVKA/MUbqjcNGv8 nMZd9fCroNStOnrz8kyqJzVyKEylMcg= From: Thorsten Blum To: Mark Fasheh , Joel Becker , Joseph Qi Cc: Thorsten Blum , ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] ocfs2: Replace deprecated strcpy with strscpy Date: Wed, 26 Nov 2025 12:44:15 +0100 Message-ID: <20251126114419.92539-1-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" 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(). No functional changes. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy= [1] Signed-off-by: Thorsten Blum Reviewed-by: Joseph Qi --- fs/ocfs2/alloc.c | 5 +++-- fs/ocfs2/cluster/nodemanager.c | 3 ++- fs/ocfs2/dir.c | 10 +++++----- fs/ocfs2/namei.c | 3 ++- fs/ocfs2/stackglue.c | 3 ++- fs/ocfs2/suballoc.c | 3 ++- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 162711cc5b20..c1bd531955bc 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -1037,7 +1038,7 @@ static int ocfs2_create_new_meta_bhs(handle_t *handle, memset(bhs[i]->b_data, 0, osb->sb->s_blocksize); eb =3D (struct ocfs2_extent_block *) bhs[i]->b_data; /* Ok, setup the minimal stuff here. */ - strcpy(eb->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE); + strscpy(eb->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE); eb->h_blkno =3D cpu_to_le64(first_blkno); eb->h_fs_generation =3D cpu_to_le32(osb->fs_generation); eb->h_suballoc_slot =3D @@ -6744,7 +6745,7 @@ static int ocfs2_reuse_blk_from_dealloc(handle_t *han= dle, /* We can't guarantee that buffer head is still cached, so * polutlate the extent block again. */ - strcpy(eb->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE); + strscpy(eb->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE); eb->h_blkno =3D cpu_to_le64(bf->free_blk); eb->h_fs_generation =3D cpu_to_le32(osb->fs_generation); eb->h_suballoc_slot =3D cpu_to_le16(real_slot); diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c index 2f61d39e4e50..6bc4e064ace4 100644 --- a/fs/ocfs2/cluster/nodemanager.c +++ b/fs/ocfs2/cluster/nodemanager.c @@ -4,6 +4,7 @@ */ =20 #include +#include #include #include #include @@ -590,7 +591,7 @@ static struct config_item *o2nm_node_group_make_item(st= ruct config_group *group, if (node =3D=3D NULL) return ERR_PTR(-ENOMEM); =20 - strcpy(node->nd_name, name); /* use item.ci_namebuf instead? */ + strscpy(node->nd_name, name); /* use item.ci_namebuf instead? */ config_item_init_type_name(&node->nd_item, name, &o2nm_node_type); spin_lock_init(&node->nd_lock); =20 diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index 8c9c4825f984..53db86c6fe9c 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c @@ -136,7 +136,7 @@ static void ocfs2_init_dir_trailer(struct inode *inode, struct ocfs2_dir_block_trailer *trailer; =20 trailer =3D ocfs2_trailer_from_bh(bh, inode->i_sb); - strcpy(trailer->db_signature, OCFS2_DIR_TRAILER_SIGNATURE); + strscpy(trailer->db_signature, OCFS2_DIR_TRAILER_SIGNATURE); trailer->db_compat_rec_len =3D cpu_to_le16(sizeof(struct ocfs2_dir_block_trailer)); trailer->db_parent_dinode =3D cpu_to_le64(OCFS2_I(inode)->ip_blkno); @@ -2192,14 +2192,14 @@ static struct ocfs2_dir_entry *ocfs2_fill_initial_d= irents(struct inode *inode, de->name_len =3D 1; de->rec_len =3D cpu_to_le16(OCFS2_DIR_REC_LEN(de->name_len)); - strcpy(de->name, "."); + strscpy(de->name, "."); ocfs2_set_de_type(de, S_IFDIR); =20 de =3D (struct ocfs2_dir_entry *) ((char *)de + le16_to_cpu(de->rec_len)); de->inode =3D cpu_to_le64(OCFS2_I(parent)->ip_blkno); de->rec_len =3D cpu_to_le16(size - OCFS2_DIR_REC_LEN(1)); de->name_len =3D 2; - strcpy(de->name, ".."); + strscpy(de->name, ".."); ocfs2_set_de_type(de, S_IFDIR); =20 return de; @@ -2357,7 +2357,7 @@ static int ocfs2_dx_dir_attach_index(struct ocfs2_sup= er *osb, =20 dx_root =3D (struct ocfs2_dx_root_block *)dx_root_bh->b_data; memset(dx_root, 0, osb->sb->s_blocksize); - strcpy(dx_root->dr_signature, OCFS2_DX_ROOT_SIGNATURE); + strscpy(dx_root->dr_signature, OCFS2_DX_ROOT_SIGNATURE); dx_root->dr_suballoc_slot =3D cpu_to_le16(meta_ac->ac_alloc_slot); dx_root->dr_suballoc_loc =3D cpu_to_le64(suballoc_loc); dx_root->dr_suballoc_bit =3D cpu_to_le16(dr_suballoc_bit); @@ -2433,7 +2433,7 @@ static int ocfs2_dx_dir_format_cluster(struct ocfs2_s= uper *osb, dx_leaf =3D (struct ocfs2_dx_leaf *) bh->b_data; =20 memset(dx_leaf, 0, osb->sb->s_blocksize); - strcpy(dx_leaf->dl_signature, OCFS2_DX_LEAF_SIGNATURE); + strscpy(dx_leaf->dl_signature, OCFS2_DX_LEAF_SIGNATURE); dx_leaf->dl_fs_generation =3D cpu_to_le32(osb->fs_generation); dx_leaf->dl_blkno =3D cpu_to_le64(bh->b_blocknr); dx_leaf->dl_list.de_count =3D diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index c90b254da75e..4ec6dbed65a8 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -568,7 +569,7 @@ static int __ocfs2_mknod_locked(struct inode *dir, ocfs2_set_links_count(fe, inode->i_nlink); =20 fe->i_last_eb_blk =3D 0; - strcpy(fe->i_signature, OCFS2_INODE_SIGNATURE); + strscpy(fe->i_signature, OCFS2_INODE_SIGNATURE); fe->i_flags |=3D cpu_to_le32(OCFS2_VALID_FL); ktime_get_coarse_real_ts64(&ts); fe->i_atime =3D fe->i_ctime =3D fe->i_mtime =3D diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c index a28c127b9934..fca2fd07c881 100644 --- a/fs/ocfs2/stackglue.c +++ b/fs/ocfs2/stackglue.c @@ -10,6 +10,7 @@ =20 #include #include +#include #include #include #include @@ -670,7 +671,7 @@ static int __init ocfs2_stack_glue_init(void) { int ret; =20 - strcpy(cluster_stack_name, OCFS2_STACK_PLUGIN_O2CB); + strscpy(cluster_stack_name, OCFS2_STACK_PLUGIN_O2CB); =20 ocfs2_table_header =3D register_sysctl("fs/ocfs2/nm", ocfs2_nm_table); if (!ocfs2_table_header) { diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index 6ac4dcd54588..4b9d0ecd0981 100644 --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c @@ -11,6 +11,7 @@ #include #include #include +#include #include =20 #include @@ -372,7 +373,7 @@ static int ocfs2_block_group_fill(handle_t *handle, } =20 memset(bg, 0, sb->s_blocksize); - strcpy(bg->bg_signature, OCFS2_GROUP_DESC_SIGNATURE); + strscpy(bg->bg_signature, OCFS2_GROUP_DESC_SIGNATURE); bg->bg_generation =3D cpu_to_le32(osb->fs_generation); bg->bg_size =3D cpu_to_le16(ocfs2_group_bitmap_size(sb, 1, osb->s_feature_incompat)); --=20 Thorsten Blum GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4