* [PATCH RESEND] autofs: replace manual symlink buffer allocation in autofs_dir_symlink
@ 2026-01-05 12:43 Thorsten Blum
0 siblings, 0 replies; 7+ messages in thread
From: Thorsten Blum @ 2026-01-05 12:43 UTC (permalink / raw)
To: Ian Kent; +Cc: Thorsten Blum, autofs, linux-kernel
The symlink name was previously duplicated using an explicit kmalloc()
followed by strcpy(), which is deprecated [1]. Replace this open-coded
string duplication with kstrdup(), which allocates and copies the
symlink name with a single helper function.
Remove the local variable 'size' and set 'i_size' directly using
strlen(cp), which is equivalent to the previous value of 'size'.
This simplifies the code, uses common string-handling helpers, and
removes the deprecated use of strcpy().
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
fs/autofs/root.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index 2c31002b314a..186e960f1e23 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -7,6 +7,7 @@
#include <linux/capability.h>
#include <linux/compat.h>
+#include <linux/string.h>
#include "autofs_i.h"
@@ -578,7 +579,6 @@ static int autofs_dir_symlink(struct mnt_idmap *idmap,
struct autofs_info *ino = autofs_dentry_ino(dentry);
struct autofs_info *p_ino;
struct inode *inode;
- size_t size = strlen(symname);
char *cp;
pr_debug("%s <- %pd\n", symname, dentry);
@@ -589,19 +589,17 @@ static int autofs_dir_symlink(struct mnt_idmap *idmap,
autofs_del_active(dentry);
- cp = kmalloc(size + 1, GFP_KERNEL);
+ cp = kstrdup(symname, GFP_KERNEL);
if (!cp)
return -ENOMEM;
- strcpy(cp, symname);
-
inode = autofs_get_inode(dir->i_sb, S_IFLNK | 0555);
if (!inode) {
kfree(cp);
return -ENOMEM;
}
inode->i_private = cp;
- inode->i_size = size;
+ inode->i_size = strlen(cp);
d_make_persistent(dentry, inode);
p_ino = autofs_dentry_ino(dentry->d_parent);
--
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH RESEND] autofs: replace manual symlink buffer allocation in autofs_dir_symlink
@ 2026-01-27 1:36 Thorsten Blum
2026-01-27 2:14 ` Ian Kent
0 siblings, 1 reply; 7+ messages in thread
From: Thorsten Blum @ 2026-01-27 1:36 UTC (permalink / raw)
To: Ian Kent; +Cc: Thorsten Blum, autofs, linux-kernel
The symlink name was previously duplicated using an explicit kmalloc()
followed by strcpy(), which is deprecated [1]. Replace this open-coded
string duplication with kstrdup(), which allocates and copies the
symlink name with a single helper function.
Remove the local variable 'size' and set 'i_size' directly using
strlen(cp), which is equivalent to the previous value of 'size'.
This simplifies the code, uses common string-handling helpers, and
removes the deprecated use of strcpy().
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
fs/autofs/root.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index 2c31002b314a..186e960f1e23 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -7,6 +7,7 @@
#include <linux/capability.h>
#include <linux/compat.h>
+#include <linux/string.h>
#include "autofs_i.h"
@@ -578,7 +579,6 @@ static int autofs_dir_symlink(struct mnt_idmap *idmap,
struct autofs_info *ino = autofs_dentry_ino(dentry);
struct autofs_info *p_ino;
struct inode *inode;
- size_t size = strlen(symname);
char *cp;
pr_debug("%s <- %pd\n", symname, dentry);
@@ -589,19 +589,17 @@ static int autofs_dir_symlink(struct mnt_idmap *idmap,
autofs_del_active(dentry);
- cp = kmalloc(size + 1, GFP_KERNEL);
+ cp = kstrdup(symname, GFP_KERNEL);
if (!cp)
return -ENOMEM;
- strcpy(cp, symname);
-
inode = autofs_get_inode(dir->i_sb, S_IFLNK | 0555);
if (!inode) {
kfree(cp);
return -ENOMEM;
}
inode->i_private = cp;
- inode->i_size = size;
+ inode->i_size = strlen(cp);
d_make_persistent(dentry, inode);
p_ino = autofs_dentry_ino(dentry->d_parent);
--
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH RESEND] autofs: replace manual symlink buffer allocation in autofs_dir_symlink
2026-01-27 1:36 Thorsten Blum
@ 2026-01-27 2:14 ` Ian Kent
2026-02-22 21:22 ` Thorsten Blum
0 siblings, 1 reply; 7+ messages in thread
From: Ian Kent @ 2026-01-27 2:14 UTC (permalink / raw)
To: Thorsten Blum; +Cc: autofs, linux-kernel, Christian Brauner
On 27/1/26 09:36, Thorsten Blum wrote:
> The symlink name was previously duplicated using an explicit kmalloc()
> followed by strcpy(), which is deprecated [1]. Replace this open-coded
> string duplication with kstrdup(), which allocates and copies the
> symlink name with a single helper function.
>
> Remove the local variable 'size' and set 'i_size' directly using
> strlen(cp), which is equivalent to the previous value of 'size'.
>
> This simplifies the code, uses common string-handling helpers, and
> removes the deprecated use of strcpy().
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> fs/autofs/root.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/fs/autofs/root.c b/fs/autofs/root.c
> index 2c31002b314a..186e960f1e23 100644
> --- a/fs/autofs/root.c
> +++ b/fs/autofs/root.c
> @@ -7,6 +7,7 @@
>
> #include <linux/capability.h>
> #include <linux/compat.h>
> +#include <linux/string.h>
>
> #include "autofs_i.h"
>
> @@ -578,7 +579,6 @@ static int autofs_dir_symlink(struct mnt_idmap *idmap,
> struct autofs_info *ino = autofs_dentry_ino(dentry);
> struct autofs_info *p_ino;
> struct inode *inode;
> - size_t size = strlen(symname);
> char *cp;
>
> pr_debug("%s <- %pd\n", symname, dentry);
> @@ -589,19 +589,17 @@ static int autofs_dir_symlink(struct mnt_idmap *idmap,
>
> autofs_del_active(dentry);
>
> - cp = kmalloc(size + 1, GFP_KERNEL);
> + cp = kstrdup(symname, GFP_KERNEL);
> if (!cp)
> return -ENOMEM;
>
> - strcpy(cp, symname);
> -
> inode = autofs_get_inode(dir->i_sb, S_IFLNK | 0555);
> if (!inode) {
> kfree(cp);
> return -ENOMEM;
> }
> inode->i_private = cp;
> - inode->i_size = size;
> + inode->i_size = strlen(cp);
>
> d_make_persistent(dentry, inode);
> p_ino = autofs_dentry_ino(dentry->d_parent);
Looks fine to me.
Acked by: Ian Kent <raven@themaw.net>
Christian, is there anything else I need to do for this?
Ian
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RESEND] autofs: replace manual symlink buffer allocation in autofs_dir_symlink
2026-01-27 2:14 ` Ian Kent
@ 2026-02-22 21:22 ` Thorsten Blum
0 siblings, 0 replies; 7+ messages in thread
From: Thorsten Blum @ 2026-02-22 21:22 UTC (permalink / raw)
To: Ian Kent; +Cc: autofs, linux-kernel, Christian Brauner
On 27. Jan 2026, at 03:14, Ian Kent wrote:
> On 27/1/26 09:36, Thorsten Blum wrote:
>> The symlink name was previously duplicated using an explicit kmalloc()
>> followed by strcpy(), which is deprecated [1]. Replace this open-coded
>> string duplication with kstrdup(), which allocates and copies the
>> symlink name with a single helper function.
>>
>> Remove the local variable 'size' and set 'i_size' directly using
>> strlen(cp), which is equivalent to the previous value of 'size'.
>>
>> This simplifies the code, uses common string-handling helpers, and
>> removes the deprecated use of strcpy().
>>
>> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
>> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
>> ---
>> fs/autofs/root.c | 8 +++-----
>> 1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> [...]
>
> Looks fine to me.
>
> Acked by: Ian Kent <raven@themaw.net>
Your tag is missing a hyphen and tools like b4 don't recognize it like
this. Correct would be:
Acked-by: Ian Kent <raven@themaw.net>
> Christian, is there anything else I need to do for this?
Thanks,
Thorsten
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH RESEND] autofs: replace manual symlink buffer allocation in autofs_dir_symlink
@ 2026-03-18 0:12 Thorsten Blum
2026-03-18 9:56 ` Christian Brauner
2026-03-18 9:56 ` Christian Brauner
0 siblings, 2 replies; 7+ messages in thread
From: Thorsten Blum @ 2026-03-18 0:12 UTC (permalink / raw)
To: Ian Kent; +Cc: Christian Brauner, Thorsten Blum, autofs, linux-kernel
The symlink name was previously duplicated using an explicit kmalloc()
followed by strcpy(), which is deprecated [1]. Replace this open-coded
string duplication with kstrdup(), which allocates and copies the
symlink name with a single helper function.
Remove the local variable 'size' and set 'i_size' directly using
strlen(cp), which is equivalent to the previous value of 'size'.
This simplifies the code, uses common string-handling helpers, and
removes the deprecated use of strcpy().
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
Acked-by: Ian Kent <raven@themaw.net>
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
fs/autofs/root.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index 2c31002b314a..186e960f1e23 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -7,6 +7,7 @@
#include <linux/capability.h>
#include <linux/compat.h>
+#include <linux/string.h>
#include "autofs_i.h"
@@ -578,7 +579,6 @@ static int autofs_dir_symlink(struct mnt_idmap *idmap,
struct autofs_info *ino = autofs_dentry_ino(dentry);
struct autofs_info *p_ino;
struct inode *inode;
- size_t size = strlen(symname);
char *cp;
pr_debug("%s <- %pd\n", symname, dentry);
@@ -589,19 +589,17 @@ static int autofs_dir_symlink(struct mnt_idmap *idmap,
autofs_del_active(dentry);
- cp = kmalloc(size + 1, GFP_KERNEL);
+ cp = kstrdup(symname, GFP_KERNEL);
if (!cp)
return -ENOMEM;
- strcpy(cp, symname);
-
inode = autofs_get_inode(dir->i_sb, S_IFLNK | 0555);
if (!inode) {
kfree(cp);
return -ENOMEM;
}
inode->i_private = cp;
- inode->i_size = size;
+ inode->i_size = strlen(cp);
d_make_persistent(dentry, inode);
p_ino = autofs_dentry_ino(dentry->d_parent);
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH RESEND] autofs: replace manual symlink buffer allocation in autofs_dir_symlink
2026-03-18 0:12 [PATCH RESEND] autofs: replace manual symlink buffer allocation in autofs_dir_symlink Thorsten Blum
@ 2026-03-18 9:56 ` Christian Brauner
2026-03-18 9:56 ` Christian Brauner
1 sibling, 0 replies; 7+ messages in thread
From: Christian Brauner @ 2026-03-18 9:56 UTC (permalink / raw)
To: Ian Kent, Thorsten Blum; +Cc: Christian Brauner, autofs, linux-kernel
On Wed, 18 Mar 2026 01:12:21 +0100, Thorsten Blum wrote:
> The symlink name was previously duplicated using an explicit kmalloc()
> followed by strcpy(), which is deprecated [1]. Replace this open-coded
> string duplication with kstrdup(), which allocates and copies the
> symlink name with a single helper function.
>
> Remove the local variable 'size' and set 'i_size' directly using
> strlen(cp), which is equivalent to the previous value of 'size'.
>
> [...]
Applied to the vfs-7.1.misc branch of the vfs/vfs.git tree.
Patches in the vfs-7.1.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-7.1.misc
[1/1] autofs: replace manual symlink buffer allocation in autofs_dir_symlink
https://git.kernel.org/vfs/vfs/c/f8909447894a
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RESEND] autofs: replace manual symlink buffer allocation in autofs_dir_symlink
2026-03-18 0:12 [PATCH RESEND] autofs: replace manual symlink buffer allocation in autofs_dir_symlink Thorsten Blum
2026-03-18 9:56 ` Christian Brauner
@ 2026-03-18 9:56 ` Christian Brauner
1 sibling, 0 replies; 7+ messages in thread
From: Christian Brauner @ 2026-03-18 9:56 UTC (permalink / raw)
To: Thorsten Blum; +Cc: Ian Kent, autofs, linux-kernel
On Wed, Mar 18, 2026 at 01:12:21AM +0100, Thorsten Blum wrote:
> The symlink name was previously duplicated using an explicit kmalloc()
> followed by strcpy(), which is deprecated [1]. Replace this open-coded
> string duplication with kstrdup(), which allocates and copies the
> symlink name with a single helper function.
>
> Remove the local variable 'size' and set 'i_size' directly using
> strlen(cp), which is equivalent to the previous value of 'size'.
>
> This simplifies the code, uses common string-handling helpers, and
> removes the deprecated use of strcpy().
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
> Acked-by: Ian Kent <raven@themaw.net>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
Ideally always Cc fsdevel. This way the tooling sees it right away.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-03-18 9:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-18 0:12 [PATCH RESEND] autofs: replace manual symlink buffer allocation in autofs_dir_symlink Thorsten Blum
2026-03-18 9:56 ` Christian Brauner
2026-03-18 9:56 ` Christian Brauner
-- strict thread matches above, loose matches on Subject: below --
2026-01-27 1:36 Thorsten Blum
2026-01-27 2:14 ` Ian Kent
2026-02-22 21:22 ` Thorsten Blum
2026-01-05 12:43 Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox