* [PATCH -next 1/3] powerpc/rtas: Replaced simple_strtoull() with kstrtoull()
@ 2021-05-26 9:20 ` Chen Huang
0 siblings, 0 replies; 15+ messages in thread
From: Chen Huang @ 2021-05-26 9:20 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Boris Ostrovsky, Juergen Gross, Stefano Stabellini, Mark Fasheh,
Joel Becker, Joseph Qi, Nathan Lynch, Andrew Donnellan,
Alexey Kardashevskiy, Andrew Morton, Stephen Rothwell,
Jens Axboe, Yang Yingliang, Masahiro Yamada, Dan Carpenter
Cc: xen-devel, Chen Huang, linuxppc-dev, linux-kernel, ocfs2-devel
The simple_strtoull() function is deprecated in some situation, since
it does not check for the range overflow, use kstrtoull() instead.
Signed-off-by: Chen Huang <chenhuang5@huawei.com>
---
arch/powerpc/kernel/rtas-proc.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/arch/powerpc/kernel/rtas-proc.c b/arch/powerpc/kernel/rtas-proc.c
index 6857a5b0a1c3..117886782ebd 100644
--- a/arch/powerpc/kernel/rtas-proc.c
+++ b/arch/powerpc/kernel/rtas-proc.c
@@ -259,7 +259,6 @@ __initcall(proc_rtas_init);
static int parse_number(const char __user *p, size_t count, u64 *val)
{
char buf[40];
- char *end;
if (count > 39)
return -EINVAL;
@@ -269,11 +268,7 @@ static int parse_number(const char __user *p, size_t count, u64 *val)
buf[count] = 0;
- *val = simple_strtoull(buf, &end, 10);
- if (*end && *end != '\n')
- return -EINVAL;
-
- return 0;
+ return kstrtoull(buf, 10, val);
}
/* ****************************************************************** */
--
2.25.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Ocfs2-devel] [PATCH -next 1/3] powerpc/rtas: Replaced simple_strtoull() with kstrtoull()
@ 2021-05-26 9:20 ` Chen Huang
0 siblings, 0 replies; 15+ messages in thread
From: Chen Huang @ 2021-05-26 9:20 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Boris Ostrovsky, Juergen Gross, Stefano Stabellini, Mark Fasheh,
Joel Becker, Joseph Qi, Nathan Lynch, Andrew Donnellan,
Alexey Kardashevskiy, Andrew Morton, Stephen Rothwell,
Jens Axboe, Yang Yingliang, Masahiro Yamada, Dan Carpenter
Cc: xen-devel, Chen Huang, linuxppc-dev, linux-kernel, ocfs2-devel
The simple_strtoull() function is deprecated in some situation, since
it does not check for the range overflow, use kstrtoull() instead.
Signed-off-by: Chen Huang <chenhuang5@huawei.com>
---
arch/powerpc/kernel/rtas-proc.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/arch/powerpc/kernel/rtas-proc.c b/arch/powerpc/kernel/rtas-proc.c
index 6857a5b0a1c3..117886782ebd 100644
--- a/arch/powerpc/kernel/rtas-proc.c
+++ b/arch/powerpc/kernel/rtas-proc.c
@@ -259,7 +259,6 @@ __initcall(proc_rtas_init);
static int parse_number(const char __user *p, size_t count, u64 *val)
{
char buf[40];
- char *end;
if (count > 39)
return -EINVAL;
@@ -269,11 +268,7 @@ static int parse_number(const char __user *p, size_t count, u64 *val)
buf[count] = 0;
- *val = simple_strtoull(buf, &end, 10);
- if (*end && *end != '\n')
- return -EINVAL;
-
- return 0;
+ return kstrtoull(buf, 10, val);
}
/* ****************************************************************** */
--
2.25.1
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH -next 2/3] xen: balloon: Replaced simple_strtoull() with kstrtoull()
2021-05-26 9:20 ` [Ocfs2-devel] " Chen Huang
(?)
@ 2021-05-26 9:20 ` Chen Huang
-1 siblings, 0 replies; 15+ messages in thread
From: Chen Huang @ 2021-05-26 9:20 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Boris Ostrovsky, Juergen Gross, Stefano Stabellini, Mark Fasheh,
Joel Becker, Joseph Qi, Nathan Lynch, Andrew Donnellan,
Alexey Kardashevskiy, Andrew Morton, Stephen Rothwell,
Jens Axboe, Yang Yingliang, Masahiro Yamada, Dan Carpenter
Cc: linuxppc-dev, linux-kernel, xen-devel, ocfs2-devel, Chen Huang
The simple_strtoull() function is deprecated in some situation, since
it does not check for the range overflow, use kstrtoull() instead.
Signed-off-by: Chen Huang <chenhuang5@huawei.com>
---
drivers/xen/xen-balloon.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/xen/xen-balloon.c b/drivers/xen/xen-balloon.c
index a8d24433c8e9..1fba838963d2 100644
--- a/drivers/xen/xen-balloon.c
+++ b/drivers/xen/xen-balloon.c
@@ -163,13 +163,16 @@ static ssize_t store_target_kb(struct device *dev,
const char *buf,
size_t count)
{
- char *endchar;
+ ssize_t ret;
unsigned long long target_bytes;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- target_bytes = simple_strtoull(buf, &endchar, 0) * 1024;
+ ret = kstrtoull(buf, 0, &target_bytes);
+ if (ret)
+ return ret;
+ target_bytes *= 1024;
balloon_set_new_target(target_bytes >> PAGE_SHIFT);
--
2.25.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH -next 2/3] xen: balloon: Replaced simple_strtoull() with kstrtoull()
@ 2021-05-26 9:20 ` Chen Huang
0 siblings, 0 replies; 15+ messages in thread
From: Chen Huang @ 2021-05-26 9:20 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Boris Ostrovsky, Juergen Gross, Stefano Stabellini, Mark Fasheh,
Joel Becker, Joseph Qi, Nathan Lynch, Andrew Donnellan,
Alexey Kardashevskiy, Andrew Morton, Stephen Rothwell,
Jens Axboe, Yang Yingliang, Masahiro Yamada, Dan Carpenter
Cc: xen-devel, Chen Huang, linuxppc-dev, linux-kernel, ocfs2-devel
The simple_strtoull() function is deprecated in some situation, since
it does not check for the range overflow, use kstrtoull() instead.
Signed-off-by: Chen Huang <chenhuang5@huawei.com>
---
drivers/xen/xen-balloon.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/xen/xen-balloon.c b/drivers/xen/xen-balloon.c
index a8d24433c8e9..1fba838963d2 100644
--- a/drivers/xen/xen-balloon.c
+++ b/drivers/xen/xen-balloon.c
@@ -163,13 +163,16 @@ static ssize_t store_target_kb(struct device *dev,
const char *buf,
size_t count)
{
- char *endchar;
+ ssize_t ret;
unsigned long long target_bytes;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- target_bytes = simple_strtoull(buf, &endchar, 0) * 1024;
+ ret = kstrtoull(buf, 0, &target_bytes);
+ if (ret)
+ return ret;
+ target_bytes *= 1024;
balloon_set_new_target(target_bytes >> PAGE_SHIFT);
--
2.25.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Ocfs2-devel] [PATCH -next 2/3] xen: balloon: Replaced simple_strtoull() with kstrtoull()
@ 2021-05-26 9:20 ` Chen Huang
0 siblings, 0 replies; 15+ messages in thread
From: Chen Huang @ 2021-05-26 9:20 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Boris Ostrovsky, Juergen Gross, Stefano Stabellini, Mark Fasheh,
Joel Becker, Joseph Qi, Nathan Lynch, Andrew Donnellan,
Alexey Kardashevskiy, Andrew Morton, Stephen Rothwell,
Jens Axboe, Yang Yingliang, Masahiro Yamada, Dan Carpenter
Cc: xen-devel, Chen Huang, linuxppc-dev, linux-kernel, ocfs2-devel
The simple_strtoull() function is deprecated in some situation, since
it does not check for the range overflow, use kstrtoull() instead.
Signed-off-by: Chen Huang <chenhuang5@huawei.com>
---
drivers/xen/xen-balloon.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/xen/xen-balloon.c b/drivers/xen/xen-balloon.c
index a8d24433c8e9..1fba838963d2 100644
--- a/drivers/xen/xen-balloon.c
+++ b/drivers/xen/xen-balloon.c
@@ -163,13 +163,16 @@ static ssize_t store_target_kb(struct device *dev,
const char *buf,
size_t count)
{
- char *endchar;
+ ssize_t ret;
unsigned long long target_bytes;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- target_bytes = simple_strtoull(buf, &endchar, 0) * 1024;
+ ret = kstrtoull(buf, 0, &target_bytes);
+ if (ret)
+ return ret;
+ target_bytes *= 1024;
balloon_set_new_target(target_bytes >> PAGE_SHIFT);
--
2.25.1
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
^ permalink raw reply related [flat|nested] 15+ messages in thread
* RE: [PATCH -next 2/3] xen: balloon: Replaced simple_strtoull() with kstrtoull()
2021-05-26 9:20 ` [Ocfs2-devel] " Chen Huang
(?)
@ 2021-05-27 14:10 ` David Laight
-1 siblings, 0 replies; 15+ messages in thread
From: David Laight @ 2021-05-27 14:10 UTC (permalink / raw)
To: 'Chen Huang',
Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Boris Ostrovsky, Juergen Gross, Stefano Stabellini, Mark Fasheh,
Joel Becker, Joseph Qi, Nathan Lynch, Andrew Donnellan,
Alexey Kardashevskiy, Andrew Morton, Stephen Rothwell,
Jens Axboe, Yang Yingliang, Masahiro Yamada, Dan Carpenter
Cc: linuxppc-dev, linux-kernel, xen-devel, ocfs2-devel
From: Chen Huang
> Sent: 26 May 2021 10:20
>
> The simple_strtoull() function is deprecated in some situation, since
> it does not check for the range overflow, use kstrtoull() instead.
>
...
> - target_bytes = simple_strtoull(buf, &endchar, 0) * 1024;
> + ret = kstrtoull(buf, 0, &target_bytes);
> + if (ret)
> + return ret;
> + target_bytes *= 1024;
I'd have thought it was more important to check *endchar
than overflow.
If you are worried about overflow you need a range check
before the multiply.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [PATCH -next 2/3] xen: balloon: Replaced simple_strtoull() with kstrtoull()
@ 2021-05-27 14:10 ` David Laight
0 siblings, 0 replies; 15+ messages in thread
From: David Laight @ 2021-05-27 14:10 UTC (permalink / raw)
To: 'Chen Huang',
Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Boris Ostrovsky, Juergen Gross, Stefano Stabellini, Mark Fasheh,
Joel Becker, Joseph Qi, Nathan Lynch, Andrew Donnellan,
Alexey Kardashevskiy, Andrew Morton, Stephen Rothwell,
Jens Axboe, Yang Yingliang, Masahiro Yamada, Dan Carpenter
Cc: xen-devel, linuxppc-dev, linux-kernel, ocfs2-devel
From: Chen Huang
> Sent: 26 May 2021 10:20
>
> The simple_strtoull() function is deprecated in some situation, since
> it does not check for the range overflow, use kstrtoull() instead.
>
...
> - target_bytes = simple_strtoull(buf, &endchar, 0) * 1024;
> + ret = kstrtoull(buf, 0, &target_bytes);
> + if (ret)
> + return ret;
> + target_bytes *= 1024;
I'd have thought it was more important to check *endchar
than overflow.
If you are worried about overflow you need a range check
before the multiply.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Ocfs2-devel] [PATCH -next 2/3] xen: balloon: Replaced simple_strtoull() with kstrtoull()
@ 2021-05-27 14:10 ` David Laight
0 siblings, 0 replies; 15+ messages in thread
From: David Laight @ 2021-05-27 14:10 UTC (permalink / raw)
To: 'Chen Huang',
Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Boris Ostrovsky, Juergen Gross, Stefano Stabellini, Mark Fasheh,
Joel Becker, Joseph Qi, Nathan Lynch, Andrew Donnellan,
Alexey Kardashevskiy, Andrew Morton, Stephen Rothwell,
Jens Axboe, Yang Yingliang, Masahiro Yamada, Dan Carpenter
Cc: xen-devel, linuxppc-dev, linux-kernel, ocfs2-devel
From: Chen Huang
> Sent: 26 May 2021 10:20
>
> The simple_strtoull() function is deprecated in some situation, since
> it does not check for the range overflow, use kstrtoull() instead.
>
...
> - target_bytes = simple_strtoull(buf, &endchar, 0) * 1024;
> + ret = kstrtoull(buf, 0, &target_bytes);
> + if (ret)
> + return ret;
> + target_bytes *= 1024;
I'd have thought it was more important to check *endchar
than overflow.
If you are worried about overflow you need a range check
before the multiply.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH -next 2/3] xen: balloon: Replaced simple_strtoull() with kstrtoull()
2021-05-27 14:10 ` [Ocfs2-devel] " David Laight
(?)
@ 2021-05-27 14:37 ` Dan Carpenter
-1 siblings, 0 replies; 15+ messages in thread
From: Dan Carpenter @ 2021-05-27 14:37 UTC (permalink / raw)
To: David Laight
Cc: 'Chen Huang',
Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Boris Ostrovsky, Juergen Gross, Stefano Stabellini, Mark Fasheh,
Joel Becker, Joseph Qi, Nathan Lynch, Andrew Donnellan,
Alexey Kardashevskiy, Andrew Morton, Stephen Rothwell,
Jens Axboe, Yang Yingliang, Masahiro Yamada, linuxppc-dev,
linux-kernel, xen-devel, ocfs2-devel
On Thu, May 27, 2021 at 02:10:21PM +0000, David Laight wrote:
> From: Chen Huang
> > Sent: 26 May 2021 10:20
> >
> > The simple_strtoull() function is deprecated in some situation, since
> > it does not check for the range overflow, use kstrtoull() instead.
> >
> ...
> > - target_bytes = simple_strtoull(buf, &endchar, 0) * 1024;
> > + ret = kstrtoull(buf, 0, &target_bytes);
> > + if (ret)
> > + return ret;
> > + target_bytes *= 1024;
>
> I'd have thought it was more important to check *endchar
> than overflow.
That's one of the differences between simple_strtoull() and kstrtoull().
The simple_strtoull() will accept a string like "123ABC", but kstrtoull()
will only accept NUL terminated numbers or a newline followed by a NUL
terminator. Which is fine in this context because users will be doing
"echo 1234 > /sys/foo".
> If you are worried about overflow you need a range check
> before the multiply.
This is probably a case where if the users cause an integer overflow
then they get what they deserve.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH -next 2/3] xen: balloon: Replaced simple_strtoull() with kstrtoull()
@ 2021-05-27 14:37 ` Dan Carpenter
0 siblings, 0 replies; 15+ messages in thread
From: Dan Carpenter @ 2021-05-27 14:37 UTC (permalink / raw)
To: David Laight
Cc: Alexey Kardashevskiy, Joseph Qi, Paul Mackerras,
Stephen Rothwell, Stefano Stabellini, Mark Fasheh,
Yang Yingliang, xen-devel, Nathan Lynch, Jens Axboe,
Andrew Donnellan, 'Chen Huang',
Joel Becker, Boris Ostrovsky, Juergen Gross, linux-kernel,
Andrew Morton, linuxppc-dev, Masahiro Yamada, ocfs2-devel
On Thu, May 27, 2021 at 02:10:21PM +0000, David Laight wrote:
> From: Chen Huang
> > Sent: 26 May 2021 10:20
> >
> > The simple_strtoull() function is deprecated in some situation, since
> > it does not check for the range overflow, use kstrtoull() instead.
> >
> ...
> > - target_bytes = simple_strtoull(buf, &endchar, 0) * 1024;
> > + ret = kstrtoull(buf, 0, &target_bytes);
> > + if (ret)
> > + return ret;
> > + target_bytes *= 1024;
>
> I'd have thought it was more important to check *endchar
> than overflow.
That's one of the differences between simple_strtoull() and kstrtoull().
The simple_strtoull() will accept a string like "123ABC", but kstrtoull()
will only accept NUL terminated numbers or a newline followed by a NUL
terminator. Which is fine in this context because users will be doing
"echo 1234 > /sys/foo".
> If you are worried about overflow you need a range check
> before the multiply.
This is probably a case where if the users cause an integer overflow
then they get what they deserve.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Ocfs2-devel] [PATCH -next 2/3] xen: balloon: Replaced simple_strtoull() with kstrtoull()
@ 2021-05-27 14:37 ` Dan Carpenter
0 siblings, 0 replies; 15+ messages in thread
From: Dan Carpenter @ 2021-05-27 14:37 UTC (permalink / raw)
To: David Laight
Cc: Alexey Kardashevskiy, Benjamin Herrenschmidt, Paul Mackerras,
Stephen Rothwell, Stefano Stabellini, Michael Ellerman,
Yang Yingliang, xen-devel, Nathan Lynch, Jens Axboe,
Andrew Donnellan, 'Chen Huang',
Boris Ostrovsky, Juergen Gross, linux-kernel, linuxppc-dev,
Masahiro Yamada, ocfs2-devel
On Thu, May 27, 2021 at 02:10:21PM +0000, David Laight wrote:
> From: Chen Huang
> > Sent: 26 May 2021 10:20
> >
> > The simple_strtoull() function is deprecated in some situation, since
> > it does not check for the range overflow, use kstrtoull() instead.
> >
> ...
> > - target_bytes = simple_strtoull(buf, &endchar, 0) * 1024;
> > + ret = kstrtoull(buf, 0, &target_bytes);
> > + if (ret)
> > + return ret;
> > + target_bytes *= 1024;
>
> I'd have thought it was more important to check *endchar
> than overflow.
That's one of the differences between simple_strtoull() and kstrtoull().
The simple_strtoull() will accept a string like "123ABC", but kstrtoull()
will only accept NUL terminated numbers or a newline followed by a NUL
terminator. Which is fine in this context because users will be doing
"echo 1234 > /sys/foo".
> If you are worried about overflow you need a range check
> before the multiply.
This is probably a case where if the users cause an integer overflow
then they get what they deserve.
regards,
dan carpenter
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH -next 3/3] ocfs2: Replaced simple_strtoull() with kstrtoull()
2021-05-26 9:20 ` [Ocfs2-devel] " Chen Huang
(?)
@ 2021-05-26 9:20 ` Chen Huang
-1 siblings, 0 replies; 15+ messages in thread
From: Chen Huang @ 2021-05-26 9:20 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Boris Ostrovsky, Juergen Gross, Stefano Stabellini, Mark Fasheh,
Joel Becker, Joseph Qi, Nathan Lynch, Andrew Donnellan,
Alexey Kardashevskiy, Andrew Morton, Stephen Rothwell,
Jens Axboe, Yang Yingliang, Masahiro Yamada, Dan Carpenter
Cc: linuxppc-dev, linux-kernel, xen-devel, ocfs2-devel, Chen Huang
The simple_strtoull() function is deprecated in some situation since
it does not check for the range overflow, use kstrtoull() instead.
Signed-off-by: Chen Huang <chenhuang5@huawei.com>
---
fs/ocfs2/cluster/heartbeat.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 1169c8dc9106..f89ffcbd585f 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1596,12 +1596,13 @@ static ssize_t o2hb_region_start_block_store(struct config_item *item,
struct o2hb_region *reg = to_o2hb_region(item);
unsigned long long tmp;
char *p = (char *)page;
+ ssize_t ret;
if (reg->hr_bdev)
return -EINVAL;
- tmp = simple_strtoull(p, &p, 0);
- if (!p || (*p && (*p != '\n')))
+ ret = kstrtoull(p, 0, &tmp);
+ if (ret)
return -EINVAL;
reg->hr_start_block = tmp;
--
2.25.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH -next 3/3] ocfs2: Replaced simple_strtoull() with kstrtoull()
@ 2021-05-26 9:20 ` Chen Huang
0 siblings, 0 replies; 15+ messages in thread
From: Chen Huang @ 2021-05-26 9:20 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Boris Ostrovsky, Juergen Gross, Stefano Stabellini, Mark Fasheh,
Joel Becker, Joseph Qi, Nathan Lynch, Andrew Donnellan,
Alexey Kardashevskiy, Andrew Morton, Stephen Rothwell,
Jens Axboe, Yang Yingliang, Masahiro Yamada, Dan Carpenter
Cc: xen-devel, Chen Huang, linuxppc-dev, linux-kernel, ocfs2-devel
The simple_strtoull() function is deprecated in some situation since
it does not check for the range overflow, use kstrtoull() instead.
Signed-off-by: Chen Huang <chenhuang5@huawei.com>
---
fs/ocfs2/cluster/heartbeat.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 1169c8dc9106..f89ffcbd585f 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1596,12 +1596,13 @@ static ssize_t o2hb_region_start_block_store(struct config_item *item,
struct o2hb_region *reg = to_o2hb_region(item);
unsigned long long tmp;
char *p = (char *)page;
+ ssize_t ret;
if (reg->hr_bdev)
return -EINVAL;
- tmp = simple_strtoull(p, &p, 0);
- if (!p || (*p && (*p != '\n')))
+ ret = kstrtoull(p, 0, &tmp);
+ if (ret)
return -EINVAL;
reg->hr_start_block = tmp;
--
2.25.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Ocfs2-devel] [PATCH -next 3/3] ocfs2: Replaced simple_strtoull() with kstrtoull()
@ 2021-05-26 9:20 ` Chen Huang
0 siblings, 0 replies; 15+ messages in thread
From: Chen Huang @ 2021-05-26 9:20 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Boris Ostrovsky, Juergen Gross, Stefano Stabellini, Mark Fasheh,
Joel Becker, Joseph Qi, Nathan Lynch, Andrew Donnellan,
Alexey Kardashevskiy, Andrew Morton, Stephen Rothwell,
Jens Axboe, Yang Yingliang, Masahiro Yamada, Dan Carpenter
Cc: xen-devel, Chen Huang, linuxppc-dev, linux-kernel, ocfs2-devel
The simple_strtoull() function is deprecated in some situation since
it does not check for the range overflow, use kstrtoull() instead.
Signed-off-by: Chen Huang <chenhuang5@huawei.com>
---
fs/ocfs2/cluster/heartbeat.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 1169c8dc9106..f89ffcbd585f 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1596,12 +1596,13 @@ static ssize_t o2hb_region_start_block_store(struct config_item *item,
struct o2hb_region *reg = to_o2hb_region(item);
unsigned long long tmp;
char *p = (char *)page;
+ ssize_t ret;
if (reg->hr_bdev)
return -EINVAL;
- tmp = simple_strtoull(p, &p, 0);
- if (!p || (*p && (*p != '\n')))
+ ret = kstrtoull(p, 0, &tmp);
+ if (ret)
return -EINVAL;
reg->hr_start_block = tmp;
--
2.25.1
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
^ permalink raw reply related [flat|nested] 15+ messages in thread