* [PATCH v2 0/2] fs: fuse: use strscpy instead of strcpy
@ 2025-09-29 13:02 Miquel Sabaté Solà
2025-09-29 13:02 ` [PATCH v2 1/2] fs: fuse: Use " Miquel Sabaté Solà
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Miquel Sabaté Solà @ 2025-09-29 13:02 UTC (permalink / raw)
To: linux-fsdevel; +Cc: miklos, linux-kernel, Miquel Sabaté Solà
Changes in v2:
- Add a commit to rename 'namelen' to 'namesize', as suggested by Miklos
Szeredi.
Miquel Sabaté Solà (2):
fs: fuse: Use strscpy instead of strcpy
fs: fuse: rename 'namelen' to 'namesize'
fs/fuse/dir.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] fs: fuse: Use strscpy instead of strcpy
2025-09-29 13:02 [PATCH v2 0/2] fs: fuse: use strscpy instead of strcpy Miquel Sabaté Solà
@ 2025-09-29 13:02 ` Miquel Sabaté Solà
2025-09-29 13:02 ` [PATCH v2 2/2] fs: fuse: rename 'namelen' to 'namesize' Miquel Sabaté Solà
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Miquel Sabaté Solà @ 2025-09-29 13:02 UTC (permalink / raw)
To: linux-fsdevel; +Cc: miklos, linux-kernel, Miquel Sabaté Solà
As pointed out in [1], strcpy() is deprecated in favor of
strscpy().
Furthermore, the length of the name to be copied is well known at this
point since we are going to move the pointer by that much on the next
line. Hence, it's safe to assume 'namelen' for the length of the string
to be copied.
[1] https://github.com/KSPP/linux/issues/88
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
---
fs/fuse/dir.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index ecaec0fea3a1..3809e280b157 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -504,7 +504,7 @@ static int get_security_context(struct dentry *entry, umode_t mode,
fctx->size = lsmctx.len;
ptr += sizeof(*fctx);
- strcpy(ptr, name);
+ strscpy(ptr, name, namelen);
ptr += namelen;
memcpy(ptr, lsmctx.context, lsmctx.len);
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] fs: fuse: rename 'namelen' to 'namesize'
2025-09-29 13:02 [PATCH v2 0/2] fs: fuse: use strscpy instead of strcpy Miquel Sabaté Solà
2025-09-29 13:02 ` [PATCH v2 1/2] fs: fuse: Use " Miquel Sabaté Solà
@ 2025-09-29 13:02 ` Miquel Sabaté Solà
2025-10-15 9:40 ` [PATCH v2 0/2] fs: fuse: use strscpy instead of strcpy Miquel Sabaté Solà
2025-11-13 9:38 ` Miklos Szeredi
3 siblings, 0 replies; 5+ messages in thread
From: Miquel Sabaté Solà @ 2025-09-29 13:02 UTC (permalink / raw)
To: linux-fsdevel; +Cc: miklos, linux-kernel, Miquel Sabaté Solà
By "length of a string" usually the number of non-null chars is
meant (i.e. strlen(str)). So the variable 'namelen' was confusingly
named, whereas 'namesize' refers more to what's being done in
'get_security_context'.
Suggested-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
---
fs/fuse/dir.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 3809e280b157..697be71de5a5 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -471,7 +471,7 @@ static int get_security_context(struct dentry *entry, umode_t mode,
u32 total_len = sizeof(*header);
int err, nr_ctx = 0;
const char *name = NULL;
- size_t namelen;
+ size_t namesize = 0;
err = security_dentry_init_security(entry, mode, &entry->d_name,
&name, &lsmctx);
@@ -482,12 +482,12 @@ static int get_security_context(struct dentry *entry, umode_t mode,
if (lsmctx.len) {
nr_ctx = 1;
- namelen = strlen(name) + 1;
+ namesize = strlen(name) + 1;
err = -EIO;
- if (WARN_ON(namelen > XATTR_NAME_MAX + 1 ||
+ if (WARN_ON(namesize > XATTR_NAME_MAX + 1 ||
lsmctx.len > S32_MAX))
goto out_err;
- total_len += FUSE_REC_ALIGN(sizeof(*fctx) + namelen +
+ total_len += FUSE_REC_ALIGN(sizeof(*fctx) + namesize +
lsmctx.len);
}
@@ -504,8 +504,8 @@ static int get_security_context(struct dentry *entry, umode_t mode,
fctx->size = lsmctx.len;
ptr += sizeof(*fctx);
- strscpy(ptr, name, namelen);
- ptr += namelen;
+ strscpy(ptr, name, namesize);
+ ptr += namesize;
memcpy(ptr, lsmctx.context, lsmctx.len);
}
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/2] fs: fuse: use strscpy instead of strcpy
2025-09-29 13:02 [PATCH v2 0/2] fs: fuse: use strscpy instead of strcpy Miquel Sabaté Solà
2025-09-29 13:02 ` [PATCH v2 1/2] fs: fuse: Use " Miquel Sabaté Solà
2025-09-29 13:02 ` [PATCH v2 2/2] fs: fuse: rename 'namelen' to 'namesize' Miquel Sabaté Solà
@ 2025-10-15 9:40 ` Miquel Sabaté Solà
2025-11-13 9:38 ` Miklos Szeredi
3 siblings, 0 replies; 5+ messages in thread
From: Miquel Sabaté Solà @ 2025-10-15 9:40 UTC (permalink / raw)
To: linux-fsdevel; +Cc: miklos, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 402 bytes --]
Hello,
Miquel Sabaté Solà @ 2025-09-29 15:02 +02:
> Changes in v2:
> - Add a commit to rename 'namelen' to 'namesize', as suggested by Miklos
> Szeredi.
>
> Miquel Sabaté Solà (2):
> fs: fuse: Use strscpy instead of strcpy
> fs: fuse: rename 'namelen' to 'namesize'
>
> fs/fuse/dir.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
Gently ping :)
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 897 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/2] fs: fuse: use strscpy instead of strcpy
2025-09-29 13:02 [PATCH v2 0/2] fs: fuse: use strscpy instead of strcpy Miquel Sabaté Solà
` (2 preceding siblings ...)
2025-10-15 9:40 ` [PATCH v2 0/2] fs: fuse: use strscpy instead of strcpy Miquel Sabaté Solà
@ 2025-11-13 9:38 ` Miklos Szeredi
3 siblings, 0 replies; 5+ messages in thread
From: Miklos Szeredi @ 2025-11-13 9:38 UTC (permalink / raw)
To: Miquel Sabaté Solà; +Cc: linux-fsdevel, linux-kernel
On Mon, 29 Sept 2025 at 15:03, Miquel Sabaté Solà <mssola@mssola.com> wrote:
>
> Changes in v2:
> - Add a commit to rename 'namelen' to 'namesize', as suggested by Miklos
> Szeredi.
Applied, thanks.
Miklos
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-11-13 9:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-29 13:02 [PATCH v2 0/2] fs: fuse: use strscpy instead of strcpy Miquel Sabaté Solà
2025-09-29 13:02 ` [PATCH v2 1/2] fs: fuse: Use " Miquel Sabaté Solà
2025-09-29 13:02 ` [PATCH v2 2/2] fs: fuse: rename 'namelen' to 'namesize' Miquel Sabaté Solà
2025-10-15 9:40 ` [PATCH v2 0/2] fs: fuse: use strscpy instead of strcpy Miquel Sabaté Solà
2025-11-13 9:38 ` Miklos Szeredi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).