Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocfs2: replace deprecated strcpy with strscpy

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]
Link: https://lkml.kernel.org/r/20251126114419.92539-1-thorsten.blum@linux.dev
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Jun Piao <piaojun@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Thorsten Blum and committed by
Andrew Morton
d86fea42 4ac577ae

+16 -11
+3 -2
fs/ocfs2/alloc.c
··· 10 10 #include <linux/fs.h> 11 11 #include <linux/types.h> 12 12 #include <linux/slab.h> 13 + #include <linux/string.h> 13 14 #include <linux/highmem.h> 14 15 #include <linux/swap.h> 15 16 #include <linux/quotaops.h> ··· 1038 1037 memset(bhs[i]->b_data, 0, osb->sb->s_blocksize); 1039 1038 eb = (struct ocfs2_extent_block *) bhs[i]->b_data; 1040 1039 /* Ok, setup the minimal stuff here. */ 1041 - strcpy(eb->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE); 1040 + strscpy(eb->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE); 1042 1041 eb->h_blkno = cpu_to_le64(first_blkno); 1043 1042 eb->h_fs_generation = cpu_to_le32(osb->fs_generation); 1044 1043 eb->h_suballoc_slot = ··· 6747 6746 /* We can't guarantee that buffer head is still cached, so 6748 6747 * polutlate the extent block again. 6749 6748 */ 6750 - strcpy(eb->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE); 6749 + strscpy(eb->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE); 6751 6750 eb->h_blkno = cpu_to_le64(bf->free_blk); 6752 6751 eb->h_fs_generation = cpu_to_le32(osb->fs_generation); 6753 6752 eb->h_suballoc_slot = cpu_to_le16(real_slot);
+2 -1
fs/ocfs2/cluster/nodemanager.c
··· 4 4 */ 5 5 6 6 #include <linux/slab.h> 7 + #include <linux/string.h> 7 8 #include <linux/kernel.h> 8 9 #include <linux/module.h> 9 10 #include <linux/configfs.h> ··· 591 590 if (node == NULL) 592 591 return ERR_PTR(-ENOMEM); 593 592 594 - strcpy(node->nd_name, name); /* use item.ci_namebuf instead? */ 593 + strscpy(node->nd_name, name); /* use item.ci_namebuf instead? */ 595 594 config_item_init_type_name(&node->nd_item, name, &o2nm_node_type); 596 595 spin_lock_init(&node->nd_lock); 597 596
+5 -5
fs/ocfs2/dir.c
··· 136 136 struct ocfs2_dir_block_trailer *trailer; 137 137 138 138 trailer = ocfs2_trailer_from_bh(bh, inode->i_sb); 139 - strcpy(trailer->db_signature, OCFS2_DIR_TRAILER_SIGNATURE); 139 + strscpy(trailer->db_signature, OCFS2_DIR_TRAILER_SIGNATURE); 140 140 trailer->db_compat_rec_len = 141 141 cpu_to_le16(sizeof(struct ocfs2_dir_block_trailer)); 142 142 trailer->db_parent_dinode = cpu_to_le64(OCFS2_I(inode)->ip_blkno); ··· 2213 2213 de->name_len = 1; 2214 2214 de->rec_len = 2215 2215 cpu_to_le16(OCFS2_DIR_REC_LEN(de->name_len)); 2216 - strcpy(de->name, "."); 2216 + strscpy(de->name, "."); 2217 2217 ocfs2_set_de_type(de, S_IFDIR); 2218 2218 2219 2219 de = (struct ocfs2_dir_entry *) ((char *)de + le16_to_cpu(de->rec_len)); 2220 2220 de->inode = cpu_to_le64(OCFS2_I(parent)->ip_blkno); 2221 2221 de->rec_len = cpu_to_le16(size - OCFS2_DIR_REC_LEN(1)); 2222 2222 de->name_len = 2; 2223 - strcpy(de->name, ".."); 2223 + strscpy(de->name, ".."); 2224 2224 ocfs2_set_de_type(de, S_IFDIR); 2225 2225 2226 2226 return de; ··· 2378 2378 2379 2379 dx_root = (struct ocfs2_dx_root_block *)dx_root_bh->b_data; 2380 2380 memset(dx_root, 0, osb->sb->s_blocksize); 2381 - strcpy(dx_root->dr_signature, OCFS2_DX_ROOT_SIGNATURE); 2381 + strscpy(dx_root->dr_signature, OCFS2_DX_ROOT_SIGNATURE); 2382 2382 dx_root->dr_suballoc_slot = cpu_to_le16(meta_ac->ac_alloc_slot); 2383 2383 dx_root->dr_suballoc_loc = cpu_to_le64(suballoc_loc); 2384 2384 dx_root->dr_suballoc_bit = cpu_to_le16(dr_suballoc_bit); ··· 2454 2454 dx_leaf = (struct ocfs2_dx_leaf *) bh->b_data; 2455 2455 2456 2456 memset(dx_leaf, 0, osb->sb->s_blocksize); 2457 - strcpy(dx_leaf->dl_signature, OCFS2_DX_LEAF_SIGNATURE); 2457 + strscpy(dx_leaf->dl_signature, OCFS2_DX_LEAF_SIGNATURE); 2458 2458 dx_leaf->dl_fs_generation = cpu_to_le32(osb->fs_generation); 2459 2459 dx_leaf->dl_blkno = cpu_to_le64(bh->b_blocknr); 2460 2460 dx_leaf->dl_list.de_count =
+2 -1
fs/ocfs2/namei.c
··· 23 23 #include <linux/fs.h> 24 24 #include <linux/types.h> 25 25 #include <linux/slab.h> 26 + #include <linux/string.h> 26 27 #include <linux/highmem.h> 27 28 #include <linux/quotaops.h> 28 29 #include <linux/iversion.h> ··· 569 568 ocfs2_set_links_count(fe, inode->i_nlink); 570 569 571 570 fe->i_last_eb_blk = 0; 572 - strcpy(fe->i_signature, OCFS2_INODE_SIGNATURE); 571 + strscpy(fe->i_signature, OCFS2_INODE_SIGNATURE); 573 572 fe->i_flags |= cpu_to_le32(OCFS2_VALID_FL); 574 573 ktime_get_coarse_real_ts64(&ts); 575 574 fe->i_atime = fe->i_ctime = fe->i_mtime =
+2 -1
fs/ocfs2/stackglue.c
··· 10 10 11 11 #include <linux/list.h> 12 12 #include <linux/spinlock.h> 13 + #include <linux/string.h> 13 14 #include <linux/module.h> 14 15 #include <linux/slab.h> 15 16 #include <linux/kmod.h> ··· 671 670 { 672 671 int ret; 673 672 674 - strcpy(cluster_stack_name, OCFS2_STACK_PLUGIN_O2CB); 673 + strscpy(cluster_stack_name, OCFS2_STACK_PLUGIN_O2CB); 675 674 676 675 ocfs2_table_header = register_sysctl("fs/ocfs2/nm", ocfs2_nm_table); 677 676 if (!ocfs2_table_header) {
+2 -1
fs/ocfs2/suballoc.c
··· 11 11 #include <linux/fs.h> 12 12 #include <linux/types.h> 13 13 #include <linux/slab.h> 14 + #include <linux/string.h> 14 15 #include <linux/highmem.h> 15 16 16 17 #include <cluster/masklog.h> ··· 373 372 } 374 373 375 374 memset(bg, 0, sb->s_blocksize); 376 - strcpy(bg->bg_signature, OCFS2_GROUP_DESC_SIGNATURE); 375 + strscpy(bg->bg_signature, OCFS2_GROUP_DESC_SIGNATURE); 377 376 bg->bg_generation = cpu_to_le32(osb->fs_generation); 378 377 bg->bg_size = cpu_to_le16(ocfs2_group_bitmap_size(sb, 1, 379 378 osb->s_feature_incompat));