Re: [PATCH] fs/xfs: replace strncpy with memtostr_pad()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 4, 2025 at 2:22 PM Carlos Maiolino <cem@xxxxxxxxxx> wrote:
>
> On Fri, Jul 04, 2025 at 12:56:04PM +0530, Pranav Tyagi wrote:
> > Replace the deprecated strncpy() with memtostr_pad(). This also avoids
> > the need for separate zeroing using memset(). Mark sb_fname buffer with
> > __nonstring as its size is XFSLABEL_MAX and so no terminating NULL for
> > sb_fname.
> >
> > Signed-off-by: Pranav Tyagi <pranav.tyagi03@xxxxxxxxx>
> > Reported-by: kernel test robot <oliver.sang@xxxxxxxxx>
> > Closes: https://lore.kernel.org/oe-lkp/202506300953.8b18c4e0-lkp@xxxxxxxxx
>
> Hi Pranav.
>
> Please Read the kernel-test-robot email:
>
> "
> If you fix the issue in a separate patch/commit (i.e. not just a new
> version of the same patch/commit), kindly add following tags...
> "
>
> Those tags shouldn't be added here as you are not fixing anything, your
> previous patch have not been committed.
>
> Cheers,
> Carlos
>
Hi Carlos,

Thanks for the clarification. I was confused and thought that "separate
patch" referred to correcting the original one and resending it separately.
I’ll remove the tags and send a v2 shortly.

Regards
Pranav Tyagi

> > ---
> >  fs/xfs/libxfs/xfs_format.h | 2 +-
> >  fs/xfs/xfs_ioctl.c         | 3 +--
> >  2 files changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
> > index 9566a7623365..779dac59b1f3 100644
> > --- a/fs/xfs/libxfs/xfs_format.h
> > +++ b/fs/xfs/libxfs/xfs_format.h
> > @@ -112,7 +112,7 @@ typedef struct xfs_sb {
> >       uint16_t        sb_sectsize;    /* volume sector size, bytes */
> >       uint16_t        sb_inodesize;   /* inode size, bytes */
> >       uint16_t        sb_inopblock;   /* inodes per block */
> > -     char            sb_fname[XFSLABEL_MAX]; /* file system name */
> > +     char            sb_fname[XFSLABEL_MAX] __nonstring; /* file system name */
> >       uint8_t         sb_blocklog;    /* log2 of sb_blocksize */
> >       uint8_t         sb_sectlog;     /* log2 of sb_sectsize */
> >       uint8_t         sb_inodelog;    /* log2 of sb_inodesize */
> > diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> > index d250f7f74e3b..c3e8c5c1084f 100644
> > --- a/fs/xfs/xfs_ioctl.c
> > +++ b/fs/xfs/xfs_ioctl.c
> > @@ -990,9 +990,8 @@ xfs_ioc_getlabel(
> >       BUILD_BUG_ON(sizeof(sbp->sb_fname) > FSLABEL_MAX);
> >
> >       /* 1 larger than sb_fname, so this ensures a trailing NUL char */
> > -     memset(label, 0, sizeof(label));
> >       spin_lock(&mp->m_sb_lock);
> > -     strncpy(label, sbp->sb_fname, XFSLABEL_MAX);
> > +     memtostr_pad(label, sbp->sb_fname);
> >       spin_unlock(&mp->m_sb_lock);
> >
> >       if (copy_to_user(user_label, label, sizeof(label)))
> > --
> > 2.49.0
> >





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux