* [PATCH] net/bridge: replace simple_strtoul to kstrtol
@ 2021-11-19 2:06 Bernard Zhao
2021-11-19 14:20 ` patchwork-bot+netdevbpf
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Bernard Zhao @ 2021-11-19 2:06 UTC (permalink / raw)
To: Roopa Prabhu, Nikolay Aleksandrov, David S. Miller,
Jakub Kicinski, bridge, netdev, linux-kernel
Cc: Bernard Zhao
simple_strtoull is obsolete, use kstrtol instead.
Signed-off-by: Bernard Zhao <bernard@vivo.com>
---
net/bridge/br_sysfs_br.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
index d9a89ddd0331..11c490694296 100644
--- a/net/bridge/br_sysfs_br.c
+++ b/net/bridge/br_sysfs_br.c
@@ -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();
--
2.33.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] net/bridge: replace simple_strtoul to kstrtol
2021-11-19 2:06 [PATCH] net/bridge: replace simple_strtoul to kstrtol Bernard Zhao
@ 2021-11-19 14:20 ` patchwork-bot+netdevbpf
2021-11-20 21:57 ` David Laight
2021-11-22 10:04 ` Ido Schimmel
2 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-11-19 14:20 UTC (permalink / raw)
To: Bernard Zhao; +Cc: roopa, nikolay, davem, kuba, bridge, netdev, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:
On Thu, 18 Nov 2021 18:06:42 -0800 you wrote:
> simple_strtoull is obsolete, use kstrtol instead.
>
> Signed-off-by: Bernard Zhao <bernard@vivo.com>
> ---
> 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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH] net/bridge: replace simple_strtoul to kstrtol
2021-11-19 2:06 [PATCH] net/bridge: replace simple_strtoul to kstrtol Bernard Zhao
2021-11-19 14:20 ` patchwork-bot+netdevbpf
@ 2021-11-20 21:57 ` David Laight
2021-11-22 10:04 ` Ido Schimmel
2 siblings, 0 replies; 7+ messages in thread
From: David Laight @ 2021-11-20 21:57 UTC (permalink / raw)
To: 'Bernard Zhao',
Roopa Prabhu, Nikolay Aleksandrov, David S. Miller,
Jakub Kicinski, bridge, netdev, linux-kernel
From: Bernard Zhao
> Sent: 19 November 2021 02:07
>
> simple_strtoull is 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.
> Signed-off-by: Bernard Zhao <bernard@vivo.com>
> ---
> net/bridge/br_sysfs_br.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
> index d9a89ddd0331..11c490694296 100644
> --- a/net/bridge/br_sysfs_br.c
> +++ b/net/bridge/br_sysfs_br.c
> @@ -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;
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)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] net/bridge: replace simple_strtoul to kstrtol
2021-11-19 2:06 [PATCH] net/bridge: replace simple_strtoul to kstrtol Bernard Zhao
2021-11-19 14:20 ` patchwork-bot+netdevbpf
2021-11-20 21:57 ` David Laight
@ 2021-11-22 10:04 ` Ido Schimmel
2021-11-22 10:17 ` Nikolay Aleksandrov
2 siblings, 1 reply; 7+ messages in thread
From: Ido Schimmel @ 2021-11-22 10:04 UTC (permalink / raw)
To: Bernard Zhao
Cc: Roopa Prabhu, Nikolay Aleksandrov, David S. Miller,
Jakub Kicinski, bridge, netdev, linux-kernel
On Thu, Nov 18, 2021 at 06:06:42PM -0800, Bernard Zhao wrote:
> simple_strtoull is obsolete, use kstrtol instead.
>
> Signed-off-by: Bernard Zhao <bernard@vivo.com>
> ---
> net/bridge/br_sysfs_br.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
> index d9a89ddd0331..11c490694296 100644
> --- a/net/bridge/br_sysfs_br.c
> +++ b/net/bridge/br_sysfs_br.c
> @@ -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);
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
> + if (err != 0)
> + return err;
>
> if (!rtnl_trylock())
> return restart_syscall();
> --
> 2.33.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] net/bridge: replace simple_strtoul to kstrtol
2021-11-22 10:04 ` Ido Schimmel
@ 2021-11-22 10:17 ` Nikolay Aleksandrov
2021-11-24 4:13 ` Jakub Kicinski
0 siblings, 1 reply; 7+ messages in thread
From: Nikolay Aleksandrov @ 2021-11-22 10:17 UTC (permalink / raw)
To: Ido Schimmel, Bernard Zhao
Cc: Roopa Prabhu, David S. Miller, Jakub Kicinski, bridge, netdev,
linux-kernel
On 22/11/2021 12:04, Ido Schimmel wrote:
> On Thu, Nov 18, 2021 at 06:06:42PM -0800, Bernard Zhao wrote:
>> simple_strtoull is obsolete, use kstrtol instead.
>>
>> Signed-off-by: Bernard Zhao <bernard@vivo.com>
>> ---
>> net/bridge/br_sysfs_br.c | 7 +++----
>> 1 file changed, 3 insertions(+), 4 deletions(-)
>>
>> diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
>> index d9a89ddd0331..11c490694296 100644
>> --- a/net/bridge/br_sysfs_br.c
>> +++ b/net/bridge/br_sysfs_br.c
>> @@ -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);
>
> 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
>
Good catch, Bernard please send a revert. Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] net/bridge: replace simple_strtoul to kstrtol
2021-11-22 10:17 ` Nikolay Aleksandrov
@ 2021-11-24 4:13 ` Jakub Kicinski
2021-11-24 10:18 ` Nikolay Aleksandrov
0 siblings, 1 reply; 7+ messages in thread
From: Jakub Kicinski @ 2021-11-24 4:13 UTC (permalink / raw)
To: Nikolay Aleksandrov
Cc: Ido Schimmel, Bernard Zhao, Roopa Prabhu, David S. Miller,
bridge, netdev, linux-kernel
On Mon, 22 Nov 2021 12:17:39 +0200 Nikolay Aleksandrov wrote:
> > # 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.
Doesn't look like he did, would you mind taking over?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] net/bridge: replace simple_strtoul to kstrtol
2021-11-24 4:13 ` Jakub Kicinski
@ 2021-11-24 10:18 ` Nikolay Aleksandrov
0 siblings, 0 replies; 7+ messages in thread
From: Nikolay Aleksandrov @ 2021-11-24 10:18 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Ido Schimmel, Bernard Zhao, Roopa Prabhu, David S. Miller,
bridge, netdev, linux-kernel
On 24/11/2021 06:13, Jakub Kicinski wrote:
> On Mon, 22 Nov 2021 12:17:39 +0200 Nikolay Aleksandrov wrote:
>>> # 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.
>
> 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/20211124101122.3321496-1-idosch@idosch.org/
Cheers,
Nik
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-11-24 10:18 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-19 2:06 [PATCH] net/bridge: replace simple_strtoul to kstrtol Bernard Zhao
2021-11-19 14:20 ` patchwork-bot+netdevbpf
2021-11-20 21:57 ` David Laight
2021-11-22 10:04 ` Ido Schimmel
2021-11-22 10:17 ` Nikolay Aleksandrov
2021-11-24 4:13 ` Jakub Kicinski
2021-11-24 10:18 ` Nikolay Aleksandrov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).