net/bridge: replace simple_strtoul to kstrtol
Subsystems (3)
PATCH 1/1 net/bridge: replace simple_strtoul to kstrtol
simple_strtoull is obsolete, use kstrtol instead.
--- net/bridge/br_sysfs_br.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
net/bridge/br_sysfs_br.c +3 -4
@@ -36,15 +36,14 @@ static ssize_t store_bridge_parm(struct device *d,struct net_bridge *br =to_bridge (d);struct netlink_ext_ack extack = {0 };unsigned long val; -char *endp;int err;if (!ns_capable (dev_net (br->dev)->user_ns,CAP_NET_ADMIN ))return -EPERM ; - val =simple_strtoul (buf, &endp,0 ); -if (endp == buf) -return -EINVAL ; + err =kstrtoul (buf,10 , &val); +if (err !=0 ) +return err;if (!rtnl_trylock ())return restart_syscall ();
Signature · 1 line
2.33.1
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Quoted 6 lines · On Thu, 18 Nov 2021 18:06:42 -0800 you wrote:
simple_strtoullis obsolete, use kstrtol instead.Signed-off-by Bernard Zhao <[email protected]>--- net/bridge/br_sysfs_br.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
Here is the summary with links:
- net/bridge: replace simple_strtoul to kstrtol
https://git.kernel.org/netdev/net-next/c/520fbdf7fb19
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
From: Bernard Zhao
Quoted 3 lines
Sent: 19 November 2021 02:07
simple_strtoullis obsolete, use kstrtol instead.
I think the death announcement of simple_strtoull() has already been deemed premature.kstrtol() isn't a replacment in many cases.
Quoted 15 lines
Signed-off-by Bernard Zhao <[email protected]>--- net/bridge/br_sysfs_br.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)net/bridge/br_sysfs_br.c +0
-1@@ -36,15 +36,14 @@ static ssize_t store_bridge_parm(struct device *d,struct net_bridge *br =to_bridge (d);struct netlink_ext_ack extack = {0 };unsigned long val; -char *endp;int err;
net/bridge/br_sysfs_br.c static ssize_t store_bridge_parm(struct device *d, · line 46
Quoted 10 lines
net/bridge/br_sysfs_br.c +3
-3if (!ns_capable (dev_net (br->dev)->user_ns,CAP_NET_ADMIN ))return -EPERM ; - val =simple_strtoul (buf, &endp,0 ); -if (endp == buf) -return -EINVAL ; + err =kstrtoul (buf,10 , &val); +if (err !=0 ) +return err;
That changes the valid input strings.
So is a UAPI change.
Now it might be that no one passes in strings that now fail, but you can't tell.
Rightfully or not it used to ignore any trailing characters. So "10flobbs" would be treated as "10".
Did you also check what happens to 0x1234 and 012 ?
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Quoted 15 lines · Bernard Zhao
simple_strtoullis obsolete, use kstrtol instead.Signed-off-by Bernard Zhao <[email protected]>--- net/bridge/br_sysfs_br.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)net/bridge/br_sysfs_br.c +0
-0@@ -36,15 +36,14 @@ static ssize_t store_bridge_parm(struct device *d,struct net_bridge *br =to_bridge (d);struct netlink_ext_ack extack = {0 };unsigned long val;
net/bridge/br_sysfs_br.c static ssize_t store_bridge_parm(struct device *d, · line 44
Quoted 10 lines
net/bridge/br_sysfs_br.c +1
-4-char *endp;int err;if (!ns_capable (dev_net (br->dev)->user_ns,CAP_NET_ADMIN ))return -EPERM ; - val =simple_strtoul (buf, &endp,0 ); -if (endp == buf) -return -EINVAL ; + err =kstrtoul (buf,10 , &val);
Base 16 is valid.
Before this patch:
# ip link add name br0 type bridge vlan_filtering 1 # echo "0x88a8" > /sys/class/net/br0/bridge/vlan_protocol # echo $? 0
After this patch:
# ip link add name br0 type bridge vlan_filtering 1 # echo "0x88a8" > /sys/class/net/br0/bridge/vlan_protocol bash: echo: write error: Invalid argument
Quoted 8 lines
net/bridge/br_sysfs_br.c +2
-0+if (err !=0 ) +return err;if (!rtnl_trylock ())return restart_syscall ();Signature · 1 line
2.33.1
Quoted 36 lines · Ido Schimmel
Quoted 15 lines · Bernard Zhao
simple_strtoullis obsolete, use kstrtol instead.Signed-off-by Bernard Zhao <[email protected]>--- net/bridge/br_sysfs_br.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)net/bridge/br_sysfs_br.c +0
-0@@ -36,15 +36,14 @@ static ssize_t store_bridge_parm(struct device *d,struct net_bridge *br =to_bridge (d);struct netlink_ext_ack extack = {0 };unsigned long val;net/bridge/br_sysfs_br.c static ssize_t store_bridge_parm(struct device *d, · line 44
Quoted 10 lines
net/bridge/br_sysfs_br.c +1
-4-char *endp;int err;if (!ns_capable (dev_net (br->dev)->user_ns,CAP_NET_ADMIN ))return -EPERM ; - val =simple_strtoul (buf, &endp,0 ); -if (endp == buf) -return -EINVAL ; + err =kstrtoul (buf,10 , &val);Base 16 is valid.
Before this patch:
# ip link add name br0 type bridge vlan_filtering 1 # echo "0x88a8" > /sys/class/net/br0/bridge/vlan_protocol # echo $? 0
Quoted 6 lines
After this patch:
# ip link add name br0 type bridge vlan_filtering 1 # echo "0x88a8" > /sys/class/net/br0/bridge/vlan_protocol bash: echo: write error: Invalid argument
Good catch, Bernard please send a revert. Thanks.
Jakub Kicinski
maintainerQuoted 5 lines · On Mon, 22 Nov 2021 12:17:39 +0200 Nikolay Aleksandrov wrote:
Quoted 3 lines
# ip link add name br0 type bridge vlan_filtering 1 # echo "0x88a8" > /sys/class/net/br0/bridge/vlan_protocol bash: echo: write error: Invalid argumentGood catch, Bernard please send a revert. Thanks.
Doesn't look like he did, would you mind taking over?
Quoted 9 lines · Jakub Kicinski
Quoted 5 lines · On Mon, 22 Nov 2021 12:17:39 +0200 Nikolay Aleksandrov wrote:
Quoted 3 lines
# ip link add name br0 type bridge vlan_filtering 1 # echo "0x88a8" > /sys/class/net/br0/bridge/vlan_protocol bash: echo: write error: Invalid argumentGood catch, Bernard please send a revert. Thanks.
Doesn't look like he did, would you mind taking over?
Ido sent a patch to take care of it:
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/
Cheers,
Nik