* [PATCH v3 0/2] net: replace deprecated simple_strto* parsers
@ 2026-03-24 15:30 Eric-Terminal
2026-03-24 15:30 ` [PATCH v3 1/2] net: bridge: replace deprecated simple_strtoul with kstrtoul Eric-Terminal
2026-03-24 15:30 ` [PATCH v3 2/2] net: sunrpc: replace deprecated simple_strtol with kstrtouint Eric-Terminal
0 siblings, 2 replies; 3+ messages in thread
From: Eric-Terminal @ 2026-03-24 15:30 UTC (permalink / raw)
To: horms, davem, kuba; +Cc: netdev, bridge, linux-nfs, Yufan Chen
From: Yufan Chen <ericterminal@gmail.com>
Hi,
This series replaces deprecated simple_strto* parsers in two net paths
with kstrto* helpers and tightens parse semantics.
The series has been split from a previous mixed 9p/net series to ease
review and align with subsystem boundaries.
Patch 1 switches bridge brport_store() to kstrtoul() to ensure strict
input validation before taking locks.
Patch 2 updates sunrpc proc_dodebug() to use kstrtouint() for full-token
conversion, improving error reporting consistency in sysctl paths.
Testing:
- Verified migration to kstrto* ensures that sysfs/procfs interfaces now
properly validate the entire input string, rejecting malformed input.
v3:
- Split into a dedicated net series for bridge and sunrpc.
- No functional changes since v2.
Yufan Chen (2):
net: bridge: replace deprecated simple_strtoul with kstrtoul
net: sunrpc: replace deprecated simple_strtol with kstrtouint
net/bridge/br_sysfs_if.c | 5 +++--
net/sunrpc/sysctl.c | 24 ++++++++++++------------
2 files changed, 15 insertions(+), 14 deletions(-)
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v3 1/2] net: bridge: replace deprecated simple_strtoul with kstrtoul
2026-03-24 15:30 [PATCH v3 0/2] net: replace deprecated simple_strto* parsers Eric-Terminal
@ 2026-03-24 15:30 ` Eric-Terminal
2026-03-24 15:30 ` [PATCH v3 2/2] net: sunrpc: replace deprecated simple_strtol with kstrtouint Eric-Terminal
1 sibling, 0 replies; 3+ messages in thread
From: Eric-Terminal @ 2026-03-24 15:30 UTC (permalink / raw)
To: horms, davem, kuba; +Cc: netdev, bridge, linux-nfs, Yufan Chen
From: Yufan Chen <ericterminal@gmail.com>
In brport_store(), switch to kstrtoul() so parse failures and range errors
return standard errno directly before taking the bridge lock.
This removes a deprecated API and improves error reporting consistency.
Signed-off-by: Yufan Chen <ericterminal@gmail.com>
---
v3:
- Split from mixed series into a dedicated net series.
- No functional changes since v2.
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 1f57c36a7..cdecc7d12 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.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v3 2/2] net: sunrpc: replace deprecated simple_strtol with kstrtouint
2026-03-24 15:30 [PATCH v3 0/2] net: replace deprecated simple_strto* parsers Eric-Terminal
2026-03-24 15:30 ` [PATCH v3 1/2] net: bridge: replace deprecated simple_strtoul with kstrtoul Eric-Terminal
@ 2026-03-24 15:30 ` Eric-Terminal
1 sibling, 0 replies; 3+ messages in thread
From: Eric-Terminal @ 2026-03-24 15:30 UTC (permalink / raw)
To: horms, davem, kuba; +Cc: netdev, bridge, linux-nfs, Yufan Chen
From: Yufan Chen <ericterminal@gmail.com>
In proc_dodebug(), trim trailing whitespace and use kstrtouint() for
full-token conversion, preserving acceptance of surrounding whitespace
while rejecting malformed input.
This replaces the deprecated simple_strtol(), improves error reporting
consistency, and avoids partially parsed values in control paths.
Signed-off-by: Yufan Chen <ericterminal@gmail.com>
---
v3:
- Split from mixed series into a dedicated net series.
- No functional changes since v2.
net/sunrpc/sysctl.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c
index bdb587a72..07072218b 100644
--- a/net/sunrpc/sysctl.c
+++ b/net/sunrpc/sysctl.c
@@ -12,6 +12,7 @@
#include <linux/linkage.h>
#include <linux/ctype.h>
#include <linux/fs.h>
+#include <linux/kernel.h>
#include <linux/sysctl.h>
#include <linux/module.h>
@@ -65,10 +66,11 @@ static int
proc_dodebug(const struct ctl_table *table, int write, void *buffer, size_t *lenp,
loff_t *ppos)
{
- char tmpbuf[20], *s = NULL;
+ char tmpbuf[20];
char *p;
unsigned int value;
size_t left, len;
+ int ret;
if ((*ppos && !write) || !*lenp) {
*lenp = 0;
@@ -89,19 +91,17 @@ proc_dodebug(const struct ctl_table *table, int write, void *buffer, size_t *len
if (left > sizeof(tmpbuf) - 1)
return -EINVAL;
memcpy(tmpbuf, p, left);
+
+ while (left && isspace(tmpbuf[left - 1]))
+ left--;
tmpbuf[left] = '\0';
+ if (!tmpbuf[0])
+ goto done;
- value = simple_strtol(tmpbuf, &s, 0);
- if (s) {
- left -= (s - tmpbuf);
- if (left && !isspace(*s))
- return -EINVAL;
- while (left && isspace(*s)) {
- left--;
- s++;
- }
- } else
- left = 0;
+ ret = kstrtouint(tmpbuf, 0, &value);
+ if (ret)
+ return ret;
+ left = 0;
*(unsigned int *) table->data = value;
/* Display the RPC tasks on writing to rpc_debug */
if (strcmp(table->procname, "rpc_debug") == 0)
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-24 15:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-24 15:30 [PATCH v3 0/2] net: replace deprecated simple_strto* parsers Eric-Terminal
2026-03-24 15:30 ` [PATCH v3 1/2] net: bridge: replace deprecated simple_strtoul with kstrtoul Eric-Terminal
2026-03-24 15:30 ` [PATCH v3 2/2] net: sunrpc: replace deprecated simple_strtol with kstrtouint Eric-Terminal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox