[PATCH net-next] ipv6: Add sanity checks on ipv6_devconf.seg6_enabled

Yue Haibing posted 1 patch 4 weeks, 1 day ago
There is a newer version of this series
net/ipv6/addrconf.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH net-next] ipv6: Add sanity checks on ipv6_devconf.seg6_enabled
Posted by Yue Haibing 4 weeks, 1 day ago
In ipv6_srh_rcv() we use min(net->ipv6.devconf_all->seg6_enabled,
idev->cnf.seg6_enabled) is intended to return 0 when either value is zero,
but if one of the values is negative it will in fact return non-zero.

Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
---
 net/ipv6/addrconf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 40e9c336f6c5..87f14532cb7e 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -7193,6 +7193,8 @@ static const struct ctl_table addrconf_sysctl[] = {
 		.maxlen		= sizeof(int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
+		.extra1		= SYSCTL_ZERO,
+		.extra2		= SYSCTL_ONE,
 	},
 #ifdef CONFIG_IPV6_SEG6_HMAC
 	{
-- 
2.34.1
Re: [PATCH net-next] ipv6: Add sanity checks on ipv6_devconf.seg6_enabled
Posted by Yue Haibing 4 weeks, 1 day ago
Sorry, pls ignore this error patch.

On 2025/9/3 17:39, Yue Haibing wrote:
> In ipv6_srh_rcv() we use min(net->ipv6.devconf_all->seg6_enabled,
> idev->cnf.seg6_enabled) is intended to return 0 when either value is zero,
> but if one of the values is negative it will in fact return non-zero.
> 
> Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
> ---
>  net/ipv6/addrconf.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index 40e9c336f6c5..87f14532cb7e 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -7193,6 +7193,8 @@ static const struct ctl_table addrconf_sysctl[] = {
>  		.maxlen		= sizeof(int),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dointvec,
> +		.extra1		= SYSCTL_ZERO,
> +		.extra2		= SYSCTL_ONE,
>  	},
>  #ifdef CONFIG_IPV6_SEG6_HMAC
>  	{