* [PATCH net-next v2] net: bridge: replace simple_strtoul with kstrtoul
@ 2026-05-05 7:45 Aadarsh Chandra
2026-05-05 7:54 ` Nikolay Aleksandrov
0 siblings, 1 reply; 2+ messages in thread
From: Aadarsh Chandra @ 2026-05-05 7:45 UTC (permalink / raw)
To: razor, idosch; +Cc: davem, kuba, netdev, bridge, linux-kernel, Aadarsh Chandra
The simple_strtoul() function is deprecated. It does not handle
errors or overflows correctly. Replace it with kstrtoul() in
brport_store() to ensure that invalid user input is caught and
returned as an error.
v2: target net-next and simplify by reusing the ret variable as
suggested by Nikolay Aleksandrov.
Signed-off-by: Aadarsh Chandra <aadarsh.official.xz@gmail.com>
---
net/bridge/br_sysfs_if.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c
index 1f57c36a7fc0..cdecc7d1260c 100644
--- a/net/bridge/br_sysfs_if.c
+++ b/net/bridge/br_sysfs_if.c
@@ -318,7 +318,6 @@ static ssize_t brport_store(struct kobject *kobj,
struct net_bridge_port *p = kobj_to_brport(kobj);
ssize_t ret = -EINVAL;
unsigned long val;
- char *endp;
if (!ns_capable(dev_net(p->dev)->user_ns, CAP_NET_ADMIN))
return -EPERM;
@@ -339,8 +338,8 @@ static ssize_t brport_store(struct kobject *kobj,
spin_unlock_bh(&p->br->lock);
kfree(buf_copy);
} else if (brport_attr->store) {
- val = simple_strtoul(buf, &endp, 0);
- if (endp == buf)
+ ret = kstrtoul(buf, 0, &val);
+ if (ret)
goto out_unlock;
spin_lock_bh(&p->br->lock);
ret = brport_attr->store(p, val);
--
2.54.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net-next v2] net: bridge: replace simple_strtoul with kstrtoul
2026-05-05 7:45 [PATCH net-next v2] net: bridge: replace simple_strtoul with kstrtoul Aadarsh Chandra
@ 2026-05-05 7:54 ` Nikolay Aleksandrov
0 siblings, 0 replies; 2+ messages in thread
From: Nikolay Aleksandrov @ 2026-05-05 7:54 UTC (permalink / raw)
To: Aadarsh Chandra, idosch; +Cc: davem, kuba, netdev, bridge, linux-kernel
On 05/05/2026 10:45, Aadarsh Chandra wrote:
> The simple_strtoul() function is deprecated. It does not handle
> errors or overflows correctly. Replace it with kstrtoul() in
> brport_store() to ensure that invalid user input is caught and
> returned as an error.
>
> v2: target net-next and simplify by reusing the ret variable as
> suggested by Nikolay Aleksandrov.
>
Nice that you've given us the changes, but it should be below...
> Signed-off-by: Aadarsh Chandra <aadarsh.official.xz@gmail.com>
> ---
... here, so it's not included in the commit message.
> net/bridge/br_sysfs_if.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c
> index 1f57c36a7fc0..cdecc7d1260c 100644
> --- a/net/bridge/br_sysfs_if.c
> +++ b/net/bridge/br_sysfs_if.c
> @@ -318,7 +318,6 @@ static ssize_t brport_store(struct kobject *kobj,
> struct net_bridge_port *p = kobj_to_brport(kobj);
> ssize_t ret = -EINVAL;
> unsigned long val;
> - char *endp;
>
> if (!ns_capable(dev_net(p->dev)->user_ns, CAP_NET_ADMIN))
> return -EPERM;
> @@ -339,8 +338,8 @@ static ssize_t brport_store(struct kobject *kobj,
> spin_unlock_bh(&p->br->lock);
> kfree(buf_copy);
> } else if (brport_attr->store) {
> - val = simple_strtoul(buf, &endp, 0);
> - if (endp == buf)
> + ret = kstrtoul(buf, 0, &val);
> + if (ret)
> goto out_unlock;
> spin_lock_bh(&p->br->lock);
> ret = brport_attr->store(p, val);
You should wait 24 hours before posting a new version.
The patch looks good to me, if there's a need for v3
please add my:
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Cheers,
Nik
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-05 7:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-05 7:45 [PATCH net-next v2] net: bridge: replace simple_strtoul with kstrtoul Aadarsh Chandra
2026-05-05 7:54 ` Nikolay Aleksandrov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox