* [PATCH] nfsd: Replace simple_strtoul with kstrtoint in expkey_parse
@ 2025-05-27 9:25 Su Hui
2025-05-28 0:25 ` NeilBrown
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Su Hui @ 2025-05-27 9:25 UTC (permalink / raw)
To: chuck.lever, jlayton, neilb, okorniev, Dai.Ngo, tom
Cc: Su Hui, linux-nfs, linux-kernel, kernel-janitors
kstrtoint() is better because simple_strtoul() ignores overflow and the
type of 'fsidtype' is 'int' rather than 'unsigned long'.
Signed-off-by: Su Hui <suhui@nfschina.com>
---
fs/nfsd/export.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index 0363720280d4..1bc9bc20cac3 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -83,7 +83,6 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
struct auth_domain *dom = NULL;
int err;
int fsidtype;
- char *ep;
struct svc_expkey key;
struct svc_expkey *ek = NULL;
@@ -109,8 +108,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
err = -EINVAL;
if (qword_get(&mesg, buf, PAGE_SIZE) <= 0)
goto out;
- fsidtype = simple_strtoul(buf, &ep, 10);
- if (*ep)
+ if (kstrtoint(buf, 10, &fsidtype))
goto out;
dprintk("found fsidtype %d\n", fsidtype);
if (key_len(fsidtype)==0) /* invalid type */
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] nfsd: Replace simple_strtoul with kstrtoint in expkey_parse
2025-05-27 9:25 [PATCH] nfsd: Replace simple_strtoul with kstrtoint in expkey_parse Su Hui
@ 2025-05-28 0:25 ` NeilBrown
2025-05-29 2:15 ` Su Hui
2025-05-28 11:11 ` Jeff Layton
2025-05-28 14:10 ` cel
2 siblings, 1 reply; 5+ messages in thread
From: NeilBrown @ 2025-05-28 0:25 UTC (permalink / raw)
To: Su Hui
Cc: chuck.lever, jlayton, okorniev, Dai.Ngo, tom, Su Hui, linux-nfs,
linux-kernel, kernel-janitors
On Tue, 27 May 2025, Su Hui wrote:
> kstrtoint() is better because simple_strtoul() ignores overflow and the
> type of 'fsidtype' is 'int' rather than 'unsigned long'.
Thanks for the patch.
Reviewed-by: NeilBrown <neil@brown.name>
The valid values for fsidtype are actually 0-7 so it might be nice to
change the type to u8 everywhere and make this kstrtou8() but that isn't
really needed and shouldn't stop this patch landing.
Thanks,
NeilBrown
>
> Signed-off-by: Su Hui <suhui@nfschina.com>
> ---
> fs/nfsd/export.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
> index 0363720280d4..1bc9bc20cac3 100644
> --- a/fs/nfsd/export.c
> +++ b/fs/nfsd/export.c
> @@ -83,7 +83,6 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
> struct auth_domain *dom = NULL;
> int err;
> int fsidtype;
> - char *ep;
> struct svc_expkey key;
> struct svc_expkey *ek = NULL;
>
> @@ -109,8 +108,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
> err = -EINVAL;
> if (qword_get(&mesg, buf, PAGE_SIZE) <= 0)
> goto out;
> - fsidtype = simple_strtoul(buf, &ep, 10);
> - if (*ep)
> + if (kstrtoint(buf, 10, &fsidtype))
> goto out;
> dprintk("found fsidtype %d\n", fsidtype);
> if (key_len(fsidtype)==0) /* invalid type */
> --
> 2.30.2
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nfsd: Replace simple_strtoul with kstrtoint in expkey_parse
2025-05-27 9:25 [PATCH] nfsd: Replace simple_strtoul with kstrtoint in expkey_parse Su Hui
2025-05-28 0:25 ` NeilBrown
@ 2025-05-28 11:11 ` Jeff Layton
2025-05-28 14:10 ` cel
2 siblings, 0 replies; 5+ messages in thread
From: Jeff Layton @ 2025-05-28 11:11 UTC (permalink / raw)
To: Su Hui, chuck.lever, neilb, okorniev, Dai.Ngo, tom
Cc: linux-nfs, linux-kernel, kernel-janitors
On Tue, 2025-05-27 at 17:25 +0800, Su Hui wrote:
> kstrtoint() is better because simple_strtoul() ignores overflow and the
> type of 'fsidtype' is 'int' rather than 'unsigned long'.
>
> Signed-off-by: Su Hui <suhui@nfschina.com>
> ---
> fs/nfsd/export.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
> index 0363720280d4..1bc9bc20cac3 100644
> --- a/fs/nfsd/export.c
> +++ b/fs/nfsd/export.c
> @@ -83,7 +83,6 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
> struct auth_domain *dom = NULL;
> int err;
> int fsidtype;
> - char *ep;
> struct svc_expkey key;
> struct svc_expkey *ek = NULL;
>
> @@ -109,8 +108,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
> err = -EINVAL;
> if (qword_get(&mesg, buf, PAGE_SIZE) <= 0)
> goto out;
> - fsidtype = simple_strtoul(buf, &ep, 10);
> - if (*ep)
> + if (kstrtoint(buf, 10, &fsidtype))
> goto out;
> dprintk("found fsidtype %d\n", fsidtype);
> if (key_len(fsidtype)==0) /* invalid type */
Reviewed-by: Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nfsd: Replace simple_strtoul with kstrtoint in expkey_parse
2025-05-27 9:25 [PATCH] nfsd: Replace simple_strtoul with kstrtoint in expkey_parse Su Hui
2025-05-28 0:25 ` NeilBrown
2025-05-28 11:11 ` Jeff Layton
@ 2025-05-28 14:10 ` cel
2 siblings, 0 replies; 5+ messages in thread
From: cel @ 2025-05-28 14:10 UTC (permalink / raw)
To: jlayton, okorniev, Dai.Ngo, tom, NeilBrown, Su Hui
Cc: Chuck Lever, linux-nfs, linux-kernel, kernel-janitors
From: Chuck Lever <chuck.lever@oracle.com>
On Tue, 27 May 2025 17:25:49 +0800, Su Hui wrote:
> kstrtoint() is better because simple_strtoul() ignores overflow and the
> type of 'fsidtype' is 'int' rather than 'unsigned long'.
>
>
Applied to nfsd-testing, thanks!
[1/1] nfsd: Replace simple_strtoul with kstrtoint in expkey_parse
commit: 901218eec3b10a773edcdca717dfe5bedde03f46
--
Chuck Lever
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nfsd: Replace simple_strtoul with kstrtoint in expkey_parse
2025-05-28 0:25 ` NeilBrown
@ 2025-05-29 2:15 ` Su Hui
0 siblings, 0 replies; 5+ messages in thread
From: Su Hui @ 2025-05-29 2:15 UTC (permalink / raw)
To: NeilBrown
Cc: chuck.lever, jlayton, okorniev, Dai.Ngo, tom, linux-nfs,
linux-kernel, kernel-janitors, Su Hui
On 2025/5/28 08:25, NeilBrown wrote:
> On Tue, 27 May 2025, Su Hui wrote:
>> kstrtoint() is better because simple_strtoul() ignores overflow and the
>> type of 'fsidtype' is 'int' rather than 'unsigned long'.
> Thanks for the patch.
>
> Reviewed-by: NeilBrown <neil@brown.name>
>
> The valid values for fsidtype are actually 0-7 so it might be nice to
> change the type to u8 everywhere and make this kstrtou8() but that isn't
> really needed and shouldn't stop this patch landing.
Thanks for your suggestion.
I can try this next week in a new patch because this has been merged
into nfsd-testing and I need some time to view code.
Su Hui
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-05-29 2:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-27 9:25 [PATCH] nfsd: Replace simple_strtoul with kstrtoint in expkey_parse Su Hui
2025-05-28 0:25 ` NeilBrown
2025-05-29 2:15 ` Su Hui
2025-05-28 11:11 ` Jeff Layton
2025-05-28 14:10 ` cel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox