All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ocfs2: Replace deprecated strcpy in ocfs2_create_xattr_block
@ 2025-11-18 18:53 Thorsten Blum
  2025-11-18 18:53 ` [PATCH 2/2] ocfs2: Replace deprecated strcpy with strscpy Thorsten Blum
  2025-11-19  5:31 ` [PATCH 1/2] ocfs2: Replace deprecated strcpy in ocfs2_create_xattr_block Joseph Qi
  0 siblings, 2 replies; 4+ messages in thread
From: Thorsten Blum @ 2025-11-18 18:53 UTC (permalink / raw)
  To: Mark Fasheh, Joel Becker, Joseph Qi
  Cc: Thorsten Blum, ocfs2-devel, linux-kernel

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(), and copy directly into '->xb_signature'
instead of using the start of the struct as the destination buffer.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 fs/ocfs2/xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index d70a20d29e3e..73c028f452ac 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -2908,7 +2908,7 @@ static int ocfs2_create_xattr_block(struct inode *inode,
 	/* Initialize ocfs2_xattr_block */
 	xblk = (struct ocfs2_xattr_block *)new_bh->b_data;
 	memset(xblk, 0, inode->i_sb->s_blocksize);
-	strcpy((void *)xblk, OCFS2_XATTR_BLOCK_SIGNATURE);
+	strscpy(xblk->xb_signature, OCFS2_XATTR_BLOCK_SIGNATURE);
 	xblk->xb_suballoc_slot = cpu_to_le16(ctxt->meta_ac->ac_alloc_slot);
 	xblk->xb_suballoc_loc = cpu_to_le64(suballoc_loc);
 	xblk->xb_suballoc_bit = cpu_to_le16(suballoc_bit_start);
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] ocfs2: Replace deprecated strcpy with strscpy
  2025-11-18 18:53 [PATCH 1/2] ocfs2: Replace deprecated strcpy in ocfs2_create_xattr_block Thorsten Blum
@ 2025-11-18 18:53 ` Thorsten Blum
  2025-11-19  5:33   ` Joseph Qi
  2025-11-19  5:31 ` [PATCH 1/2] ocfs2: Replace deprecated strcpy in ocfs2_create_xattr_block Joseph Qi
  1 sibling, 1 reply; 4+ messages in thread
From: Thorsten Blum @ 2025-11-18 18:53 UTC (permalink / raw)
  To: Mark Fasheh, Joel Becker, Joseph Qi
  Cc: Thorsten Blum, ocfs2-devel, linux-kernel

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(), and copy directly into '->rf_signature'
instead of using the start of the struct as the destination buffer.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 fs/ocfs2/refcounttree.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 267b50e8e42e..c92e0ea85bca 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -34,6 +34,7 @@
 #include <linux/pagevec.h>
 #include <linux/swap.h>
 #include <linux/security.h>
+#include <linux/string.h>
 #include <linux/fsnotify.h>
 #include <linux/quotaops.h>
 #include <linux/namei.h>
@@ -621,7 +622,7 @@ static int ocfs2_create_refcount_tree(struct inode *inode,
 	/* Initialize ocfs2_refcount_block. */
 	rb = (struct ocfs2_refcount_block *)new_bh->b_data;
 	memset(rb, 0, inode->i_sb->s_blocksize);
-	strcpy((void *)rb, OCFS2_REFCOUNT_BLOCK_SIGNATURE);
+	strscpy(rb->rf_signature, OCFS2_REFCOUNT_BLOCK_SIGNATURE);
 	rb->rf_suballoc_slot = cpu_to_le16(meta_ac->ac_alloc_slot);
 	rb->rf_suballoc_loc = cpu_to_le64(suballoc_loc);
 	rb->rf_suballoc_bit = cpu_to_le16(suballoc_bit_start);
@@ -1562,7 +1563,7 @@ static int ocfs2_new_leaf_refcount_block(handle_t *handle,
 	/* Initialize ocfs2_refcount_block. */
 	new_rb = (struct ocfs2_refcount_block *)new_bh->b_data;
 	memset(new_rb, 0, sb->s_blocksize);
-	strcpy((void *)new_rb, OCFS2_REFCOUNT_BLOCK_SIGNATURE);
+	strscpy(new_rb->rf_signature, OCFS2_REFCOUNT_BLOCK_SIGNATURE);
 	new_rb->rf_suballoc_slot = cpu_to_le16(meta_ac->ac_alloc_slot);
 	new_rb->rf_suballoc_loc = cpu_to_le64(suballoc_loc);
 	new_rb->rf_suballoc_bit = cpu_to_le16(suballoc_bit_start);
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] ocfs2: Replace deprecated strcpy in ocfs2_create_xattr_block
  2025-11-18 18:53 [PATCH 1/2] ocfs2: Replace deprecated strcpy in ocfs2_create_xattr_block Thorsten Blum
  2025-11-18 18:53 ` [PATCH 2/2] ocfs2: Replace deprecated strcpy with strscpy Thorsten Blum
@ 2025-11-19  5:31 ` Joseph Qi
  1 sibling, 0 replies; 4+ messages in thread
From: Joseph Qi @ 2025-11-19  5:31 UTC (permalink / raw)
  To: Thorsten Blum, Mark Fasheh, Joel Becker, akpm; +Cc: ocfs2-devel, linux-kernel



On 2025/11/19 02:53, Thorsten Blum wrote:
> 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(), and copy directly into '->xb_signature'
> instead of using the start of the struct as the destination buffer.
> 
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>

Looks good.
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>

> ---
>  fs/ocfs2/xattr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
> index d70a20d29e3e..73c028f452ac 100644
> --- a/fs/ocfs2/xattr.c
> +++ b/fs/ocfs2/xattr.c
> @@ -2908,7 +2908,7 @@ static int ocfs2_create_xattr_block(struct inode *inode,
>  	/* Initialize ocfs2_xattr_block */
>  	xblk = (struct ocfs2_xattr_block *)new_bh->b_data;
>  	memset(xblk, 0, inode->i_sb->s_blocksize);
> -	strcpy((void *)xblk, OCFS2_XATTR_BLOCK_SIGNATURE);
> +	strscpy(xblk->xb_signature, OCFS2_XATTR_BLOCK_SIGNATURE);
>  	xblk->xb_suballoc_slot = cpu_to_le16(ctxt->meta_ac->ac_alloc_slot);
>  	xblk->xb_suballoc_loc = cpu_to_le64(suballoc_loc);
>  	xblk->xb_suballoc_bit = cpu_to_le16(suballoc_bit_start);


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] ocfs2: Replace deprecated strcpy with strscpy
  2025-11-18 18:53 ` [PATCH 2/2] ocfs2: Replace deprecated strcpy with strscpy Thorsten Blum
@ 2025-11-19  5:33   ` Joseph Qi
  0 siblings, 0 replies; 4+ messages in thread
From: Joseph Qi @ 2025-11-19  5:33 UTC (permalink / raw)
  To: Thorsten Blum, Mark Fasheh, Joel Becker, akpm; +Cc: ocfs2-devel, linux-kernel



On 2025/11/19 02:53, Thorsten Blum wrote:
> 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(), and copy directly into '->rf_signature'
> instead of using the start of the struct as the destination buffer.
> 
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>

Looks fine.
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>

> ---
>  fs/ocfs2/refcounttree.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
> index 267b50e8e42e..c92e0ea85bca 100644
> --- a/fs/ocfs2/refcounttree.c
> +++ b/fs/ocfs2/refcounttree.c
> @@ -34,6 +34,7 @@
>  #include <linux/pagevec.h>
>  #include <linux/swap.h>
>  #include <linux/security.h>
> +#include <linux/string.h>
>  #include <linux/fsnotify.h>
>  #include <linux/quotaops.h>
>  #include <linux/namei.h>
> @@ -621,7 +622,7 @@ static int ocfs2_create_refcount_tree(struct inode *inode,
>  	/* Initialize ocfs2_refcount_block. */
>  	rb = (struct ocfs2_refcount_block *)new_bh->b_data;
>  	memset(rb, 0, inode->i_sb->s_blocksize);
> -	strcpy((void *)rb, OCFS2_REFCOUNT_BLOCK_SIGNATURE);
> +	strscpy(rb->rf_signature, OCFS2_REFCOUNT_BLOCK_SIGNATURE);
>  	rb->rf_suballoc_slot = cpu_to_le16(meta_ac->ac_alloc_slot);
>  	rb->rf_suballoc_loc = cpu_to_le64(suballoc_loc);
>  	rb->rf_suballoc_bit = cpu_to_le16(suballoc_bit_start);
> @@ -1562,7 +1563,7 @@ static int ocfs2_new_leaf_refcount_block(handle_t *handle,
>  	/* Initialize ocfs2_refcount_block. */
>  	new_rb = (struct ocfs2_refcount_block *)new_bh->b_data;
>  	memset(new_rb, 0, sb->s_blocksize);
> -	strcpy((void *)new_rb, OCFS2_REFCOUNT_BLOCK_SIGNATURE);
> +	strscpy(new_rb->rf_signature, OCFS2_REFCOUNT_BLOCK_SIGNATURE);
>  	new_rb->rf_suballoc_slot = cpu_to_le16(meta_ac->ac_alloc_slot);
>  	new_rb->rf_suballoc_loc = cpu_to_le64(suballoc_loc);
>  	new_rb->rf_suballoc_bit = cpu_to_le16(suballoc_bit_start);


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-11-19  5:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-18 18:53 [PATCH 1/2] ocfs2: Replace deprecated strcpy in ocfs2_create_xattr_block Thorsten Blum
2025-11-18 18:53 ` [PATCH 2/2] ocfs2: Replace deprecated strcpy with strscpy Thorsten Blum
2025-11-19  5:33   ` Joseph Qi
2025-11-19  5:31 ` [PATCH 1/2] ocfs2: Replace deprecated strcpy in ocfs2_create_xattr_block Joseph Qi

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.