Skip to contentSkip to conversation

xfs: replace strncpy with memcpy in xattr listing

PATCH Applied Pranav Tyagi 3 participants 9 messages Jun 17, 2025 – Jul 8, 2025 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: replace strncpy with memcpy in xattr listing

Use memcpy() in place of strncpy() in __xfs_xattr_put_listent(). The length is known and a null byte is added manually.

No functional change intended.

---
 fs/xfs/xfs_xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_xattr.c +1 -1
index 0f641a9091ec..ac5cecec9aa1 100644
@@ -243,7 +243,7 @@ __xfs_xattr_put_listent(
 	offset = context->buffer + context->count;
 	memcpy(offset, prefix, prefix_len);
 	offset += prefix_len;
-	strncpy(offset, (char *)name, namelen);			/* real name */
+	memcpy(offset, (char *)name, namelen);			/* real name */
 	offset += namelen;
 	*offset = '\0';
 
Signature · 1 line
2.49.0
maintainer
#1 lore raw
Quoted 15 lines · Pranav Tyagi

Use memcpy() in place of strncpy() in __xfs_xattr_put_listent(). The length is known and a null byte is added manually.

No functional change intended.

---
 fs/xfs/xfs_xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_xattr.c +0 -0
index 0f641a9091ec..ac5cecec9aa1 100644

fs/xfs/xfs_xattr.c __xfs_xattr_put_listent( · line 248

Quoted 7 lines
fs/xfs/xfs_xattr.c +1 -1
@@ -243,7 +243,7 @@ __xfs_xattr_put_listent(
 	offset = context->buffer + context->count;
 	memcpy(offset, prefix, prefix_len);
 	offset += prefix_len;
-	strncpy(offset, (char *)name, namelen);			/* real name */
+	memcpy(offset, (char *)name, namelen);			/* real name */
 	offset += namelen;
 	*offset = '\0';

What difference does it make?

Quoted 4 lines
fs/xfs/xfs_xattr.c +0 -1
--

2.49.0

#2 lore raw
Quoted 12 lines · Carlos Maiolino
Quoted 10 lines · Pranav Tyagi

Use memcpy() in place of strncpy() in __xfs_xattr_put_listent(). The length is known and a null byte is added manually.

No functional change intended.

---
 fs/xfs/xfs_xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

fs/xfs/xfs_xattr.c __xfs_xattr_put_listent( · line 248

Quoted 12 lines
fs/xfs/xfs_xattr.c +1 -1
index 0f641a9091ec..ac5cecec9aa1 100644
@@ -243,7 +243,7 @@ __xfs_xattr_put_listent(
      offset = context->buffer + context->count;
      memcpy(offset, prefix, prefix_len);
      offset += prefix_len;
-     strncpy(offset, (char *)name, namelen);                 /* real name */
+     memcpy(offset, (char *)name, namelen);                  /* real name */
      offset += namelen;
      *offset = '\0';

What difference does it make?

I intended this to be a cleanup patch as strncpy() is deprecated and its use discouraged.

Regards
Pranav Tyagi

Quoted 6 lines
Quoted 6 lines
fs/xfs/xfs_xattr.c +0 -1
--

2.49.0

maintainer Reviewed-by
#3 lore raw
Quoted 28 lines · Pranav Tyagi
Quoted 12 lines · Carlos Maiolino
Quoted 10 lines · Pranav Tyagi

Use memcpy() in place of strncpy() in __xfs_xattr_put_listent(). The length is known and a null byte is added manually.

No functional change intended.

---
 fs/xfs/xfs_xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

fs/xfs/xfs_xattr.c __xfs_xattr_put_listent( · line 248

Quoted 12 lines
fs/xfs/xfs_xattr.c +1 -1
index 0f641a9091ec..ac5cecec9aa1 100644
@@ -243,7 +243,7 @@ __xfs_xattr_put_listent(
      offset = context->buffer + context->count;
      memcpy(offset, prefix, prefix_len);
      offset += prefix_len;
-     strncpy(offset, (char *)name, namelen);                 /* real name */
+     memcpy(offset, (char *)name, namelen);                  /* real name */
      offset += namelen;
      *offset = '\0';

What difference does it make?

Quoted 2 lines

I intended this to be a cleanup patch as strncpy() is deprecated and its use discouraged.

Fair enough. This is the kind of information that's worth to add to the patch description on your future patches.

No need to re-send this again.

Quoted 9 lines

Regards
Pranav Tyagi

Quoted 6 lines
Quoted 6 lines
fs/xfs/xfs_xattr.c +0 -1
--

2.49.0

#4 lore raw
Quoted 33 lines · Carlos Maiolino
Quoted 28 lines · Pranav Tyagi
Quoted 12 lines · Carlos Maiolino
Quoted 10 lines · Pranav Tyagi

Use memcpy() in place of strncpy() in __xfs_xattr_put_listent(). The length is known and a null byte is added manually.

No functional change intended.

---
 fs/xfs/xfs_xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

fs/xfs/xfs_xattr.c __xfs_xattr_put_listent( · line 248

Quoted 12 lines
fs/xfs/xfs_xattr.c +1 -1
index 0f641a9091ec..ac5cecec9aa1 100644
@@ -243,7 +243,7 @@ __xfs_xattr_put_listent(
      offset = context->buffer + context->count;
      memcpy(offset, prefix, prefix_len);
      offset += prefix_len;
-     strncpy(offset, (char *)name, namelen);                 /* real name */
+     memcpy(offset, (char *)name, namelen);                  /* real name */
      offset += namelen;
      *offset = '\0';

What difference does it make?

Quoted 2 lines

I intended this to be a cleanup patch as strncpy() is deprecated and its use discouraged.

Quoted 6 lines

Fair enough. This is the kind of information that's worth to add to the patch description on your future patches.

No need to re-send this again.

Thanks Darrick and Carlos for the Reviewed-by tag.

I also wanted to ask if this patch has been queued for merging.

Regards
Pranav Tyagi

Quoted 10 lines
Quoted 10 lines

Regards
Pranav Tyagi

Quoted 6 lines
Quoted 6 lines
fs/xfs/xfs_xattr.c +0 -1
--

2.49.0

maintainer
#5 lore raw
Quoted 37 lines · Pranav Tyagi
Quoted 36 lines · Carlos Maiolino
Quoted 28 lines · Pranav Tyagi
Quoted 12 lines · Carlos Maiolino
Quoted 10 lines · Pranav Tyagi

Use memcpy() in place of strncpy() in __xfs_xattr_put_listent(). The length is known and a null byte is added manually.

No functional change intended.

---
 fs/xfs/xfs_xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

fs/xfs/xfs_xattr.c __xfs_xattr_put_listent( · line 248

Quoted 12 lines
fs/xfs/xfs_xattr.c +1 -1
index 0f641a9091ec..ac5cecec9aa1 100644
@@ -243,7 +243,7 @@ __xfs_xattr_put_listent(
      offset = context->buffer + context->count;
      memcpy(offset, prefix, prefix_len);
      offset += prefix_len;
-     strncpy(offset, (char *)name, namelen);                 /* real name */
+     memcpy(offset, (char *)name, namelen);                  /* real name */
      offset += namelen;
      *offset = '\0';

What difference does it make?

Quoted 2 lines

I intended this to be a cleanup patch as strncpy() is deprecated and its use discouraged.

Fair enough. This is the kind of information that's worth to add to the patch description on your future patches.

Quoted 7 lines
Quoted 3 lines

No need to re-send this again.

Thanks Darrick and Carlos for the Reviewed-by tag.

I also wanted to ask if this patch has been queued for merging.

xfs teams sends an ANNOUNCE email every merge done to the for-next branch, you can check if your patches are mentioned there, if not they are not queued up yet.

Also, you'll likely receive a message saying your patch has been pushed into for-next.

Note though that just because your patch has been added to for-next, doesn't automatically mean it will be merged. Several tests still happens on patches pushed to for-next branch (which are merged into linux-next) and linux-next 'after' your patch has been merged into.

So your patch(es) being merged are conditional to that.

Carlos

Quoted 14 lines

Regards
Pranav Tyagi

Quoted 10 lines
Quoted 10 lines

Regards
Pranav Tyagi

Quoted 6 lines
Quoted 6 lines
fs/xfs/xfs_xattr.c +0 -1
--

2.49.0

#6 lore raw
Quoted 54 lines · Carlos Maiolino
Quoted 37 lines · Pranav Tyagi
Quoted 36 lines · Carlos Maiolino
Quoted 28 lines · Pranav Tyagi
Quoted 12 lines · Carlos Maiolino
Quoted 10 lines · Pranav Tyagi

Use memcpy() in place of strncpy() in __xfs_xattr_put_listent(). The length is known and a null byte is added manually.

No functional change intended.

---
 fs/xfs/xfs_xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

fs/xfs/xfs_xattr.c __xfs_xattr_put_listent( · line 248

Quoted 12 lines
fs/xfs/xfs_xattr.c +1 -1
index 0f641a9091ec..ac5cecec9aa1 100644
@@ -243,7 +243,7 @@ __xfs_xattr_put_listent(
      offset = context->buffer + context->count;
      memcpy(offset, prefix, prefix_len);
      offset += prefix_len;
-     strncpy(offset, (char *)name, namelen);                 /* real name */
+     memcpy(offset, (char *)name, namelen);                  /* real name */
      offset += namelen;
      *offset = '\0';

What difference does it make?

Quoted 2 lines

I intended this to be a cleanup patch as strncpy() is deprecated and its use discouraged.

Fair enough. This is the kind of information that's worth to add to the patch description on your future patches.

Quoted 7 lines
Quoted 3 lines

No need to re-send this again.

Thanks Darrick and Carlos for the Reviewed-by tag.

I also wanted to ask if this patch has been queued for merging.

xfs teams sends an ANNOUNCE email every merge done to the for-next branch, you can check if your patches are mentioned there, if not they are not queued up yet.

Also, you'll likely receive a message saying your patch has been pushed into for-next.

Quoted 9 lines

Note though that just because your patch has been added to for-next, doesn't automatically mean it will be merged. Several tests still happens on patches pushed to for-next branch (which are merged into linux-next) and linux-next 'after' your patch has been merged into.

So your patch(es) being merged are conditional to that.

Carlos

Hi,

Thanks for the clarification. I'll keep an eye on the announce emails and wait to see if my patch gets mentioned or pushed to the for-next branch.

Appreciate the insight into the review and testing process. That helps a lot.

Regards
Pranav Tyagi

Quoted 14 lines
Quoted 14 lines

Regards
Pranav Tyagi

Quoted 10 lines
Quoted 10 lines

Regards
Pranav Tyagi

Quoted 6 lines
Quoted 6 lines
fs/xfs/xfs_xattr.c +0 -1
--

2.49.0

Reviewed-by on v1 1/1
#7 lore raw
In reply to Pranav Tyagi
Quoted 6 lines · Pranav Tyagi

Use memcpy() in place of strncpy() in __xfs_xattr_put_listent(). The length is known and a null byte is added manually.

No functional change intended.

'tis better than the three previous attempts at this (compliments on working out that *name isn't a null terminated string!), so

--D

Quoted 21 lines
---
 fs/xfs/xfs_xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_xattr.c +1 -1
index 0f641a9091ec..ac5cecec9aa1 100644
@@ -243,7 +243,7 @@ __xfs_xattr_put_listent(
 	offset = context->buffer + context->count;
 	memcpy(offset, prefix, prefix_len);
 	offset += prefix_len;
-	strncpy(offset, (char *)name, namelen);			/* real name */
+	memcpy(offset, (char *)name, namelen);			/* real name */
 	offset += namelen;
 	*offset = '\0';
 
Signature · 1 line
2.49.0
maintainer Applied
#8 lore raw
In reply to Pranav Tyagi
Quoted 6 lines · Pranav Tyagi

Use memcpy() in place of strncpy() in __xfs_xattr_put_listent(). The length is known and a null byte is added manually.

No functional change intended.

Applied to for-next, thanks!

[1/1] xfs: replace strncpy with memcpy in xattr listing

      commit: f2eb2796b95118b877b63d9fcd3459e70494a498

Best regards,

Signature · 1 line
Carlos Maiolino <[email protected]>