mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joseph Qi <joseph.qi@linux.alibaba.com>
To: Thorsten Blum <thorsten.blum@linux.dev>,
	Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>,
	akpm <akpm@linux-foundation.org>
Cc: ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] ocfs2: Replace deprecated strcpy with strscpy
Date: Wed, 19 Nov 2025 13:33:14 +0800	[thread overview]
Message-ID: <ee0a75f2-6090-4dd9-8a95-575fdd859dc3@linux.alibaba.com> (raw)
In-Reply-To: <20251118185345.132411-3-thorsten.blum@linux.dev>



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);


  reply	other threads:[~2025-11-19  5:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2025-11-19  5:31 ` [PATCH 1/2] ocfs2: Replace deprecated strcpy in ocfs2_create_xattr_block Joseph Qi

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=ee0a75f2-6090-4dd9-8a95-575fdd859dc3@linux.alibaba.com \
    --to=joseph.qi@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=jlbec@evilplan.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark@fasheh.com \
    --cc=ocfs2-devel@lists.linux.dev \
    --cc=thorsten.blum@linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®