* [PATCH][net-next] ipv6: fix incorrect bitwise operator used on rt6i_flags
@ 2017-10-10 17:55 Colin King
2017-10-10 18:05 ` NACK: " Colin Ian King
2017-10-10 18:10 ` Martin KaFai Lau
0 siblings, 2 replies; 5+ messages in thread
From: Colin King @ 2017-10-10 17:55 UTC (permalink / raw)
To: David S . Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI, netdev
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
The use of the | operator always leads to true on the expression
(rt->rt6i_flags | RTF_CACHE) which looks rather suspect to me. I
believe this is fixed by using & instead to just check the
RTF_CACHE entry bit.
Detected by CoverityScan, CID#1457747 ("Wrong operator used")
Fixes: 35732d01fe31 ("ipv6: introduce a hash table to store dst cache")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
net/ipv6/route.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 6db1541eaa7b..0556d1ee189c 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1425,7 +1425,7 @@ int rt6_remove_exception_rt(struct rt6_info *rt)
int err;
if (!from ||
- !(rt->rt6i_flags | RTF_CACHE))
+ !(rt->rt6i_flags & RTF_CACHE))
return -EINVAL;
if (!rcu_access_pointer(from->rt6i_exception_bucket))
--
2.14.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* NACK: [PATCH][net-next] ipv6: fix incorrect bitwise operator used on rt6i_flags
2017-10-10 17:55 [PATCH][net-next] ipv6: fix incorrect bitwise operator used on rt6i_flags Colin King
@ 2017-10-10 18:05 ` Colin Ian King
2017-10-10 18:10 ` Martin KaFai Lau
1 sibling, 0 replies; 5+ messages in thread
From: Colin Ian King @ 2017-10-10 18:05 UTC (permalink / raw)
To: David S . Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI, netdev
Cc: kernel-janitors, linux-kernel
On 10/10/17 18:55, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The use of the | operator always leads to true on the expression
> (rt->rt6i_flags | RTF_CACHE) which looks rather suspect to me. I
> believe this is fixed by using & instead to just check the
> RTF_CACHE entry bit.
>
> Detected by CoverityScan, CID#1457747 ("Wrong operator used")
>
> Fixes: 35732d01fe31 ("ipv6: introduce a hash table to store dst cache")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> net/ipv6/route.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 6db1541eaa7b..0556d1ee189c 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -1425,7 +1425,7 @@ int rt6_remove_exception_rt(struct rt6_info *rt)
> int err;
>
> if (!from ||
> - !(rt->rt6i_flags | RTF_CACHE))
> + !(rt->rt6i_flags & RTF_CACHE))
> return -EINVAL;
>
> if (!rcu_access_pointer(from->rt6i_exception_bucket))
>
Nack that, seems like this occurs more than once and I failed to spot
the others.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH][net-next] ipv6: fix incorrect bitwise operator used on rt6i_flags
2017-10-10 17:55 [PATCH][net-next] ipv6: fix incorrect bitwise operator used on rt6i_flags Colin King
2017-10-10 18:05 ` NACK: " Colin Ian King
@ 2017-10-10 18:10 ` Martin KaFai Lau
2017-10-10 18:23 ` Wei Wang
1 sibling, 1 reply; 5+ messages in thread
From: Martin KaFai Lau @ 2017-10-10 18:10 UTC (permalink / raw)
To: Colin King
Cc: David S . Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI, netdev,
kernel-janitors, linux-kernel, Wei Wang
On Tue, Oct 10, 2017 at 05:55:27PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The use of the | operator always leads to true on the expression
> (rt->rt6i_flags | RTF_CACHE) which looks rather suspect to me. I
> believe this is fixed by using & instead to just check the
> RTF_CACHE entry bit.
Good catch. LGTM. If rt does not have RTF_CACHE set, it should not be in the
exception table.
Acked-by: Martin KaFai Lau <kafai@fb.com>
>
> Detected by CoverityScan, CID#1457747 ("Wrong operator used")
>
> Fixes: 35732d01fe31 ("ipv6: introduce a hash table to store dst cache")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> net/ipv6/route.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 6db1541eaa7b..0556d1ee189c 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -1425,7 +1425,7 @@ int rt6_remove_exception_rt(struct rt6_info *rt)
> int err;
>
> if (!from ||
> - !(rt->rt6i_flags | RTF_CACHE))
> + !(rt->rt6i_flags & RTF_CACHE))
> return -EINVAL;
>
> if (!rcu_access_pointer(from->rt6i_exception_bucket))
> --
> 2.14.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH][net-next] ipv6: fix incorrect bitwise operator used on rt6i_flags
2017-10-10 18:10 ` Martin KaFai Lau
@ 2017-10-10 18:23 ` Wei Wang
2017-10-10 18:24 ` Colin Ian King
0 siblings, 1 reply; 5+ messages in thread
From: Wei Wang @ 2017-10-10 18:23 UTC (permalink / raw)
To: Martin KaFai Lau, Colin King, Eric Dumazet
Cc: David S . Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI,
Linux Kernel Network Developers, kernel-janitors, lkml
On Tue, Oct 10, 2017 at 11:10 AM, Martin KaFai Lau <kafai@fb.com> wrote:
> On Tue, Oct 10, 2017 at 05:55:27PM +0000, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> The use of the | operator always leads to true on the expression
>> (rt->rt6i_flags | RTF_CACHE) which looks rather suspect to me. I
>> believe this is fixed by using & instead to just check the
>> RTF_CACHE entry bit.
> Good catch. LGTM. If rt does not have RTF_CACHE set, it should not be in the
> exception table.
>
> Acked-by: Martin KaFai Lau <kafai@fb.com>
>
Thanks a lot for catching this. Yes. It should have been '&' instead of '|'.
Acked-by: Wei Wang <weiwan@google.com>
>>
>> Detected by CoverityScan, CID#1457747 ("Wrong operator used")
>>
>> Fixes: 35732d01fe31 ("ipv6: introduce a hash table to store dst cache")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>> net/ipv6/route.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
>> index 6db1541eaa7b..0556d1ee189c 100644
>> --- a/net/ipv6/route.c
>> +++ b/net/ipv6/route.c
>> @@ -1425,7 +1425,7 @@ int rt6_remove_exception_rt(struct rt6_info *rt)
>> int err;
>>
>> if (!from ||
>> - !(rt->rt6i_flags | RTF_CACHE))
>> + !(rt->rt6i_flags & RTF_CACHE))
>> return -EINVAL;
>>
>> if (!rcu_access_pointer(from->rt6i_exception_bucket))
>> --
>> 2.14.1
>>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH][net-next] ipv6: fix incorrect bitwise operator used on rt6i_flags
2017-10-10 18:23 ` Wei Wang
@ 2017-10-10 18:24 ` Colin Ian King
0 siblings, 0 replies; 5+ messages in thread
From: Colin Ian King @ 2017-10-10 18:24 UTC (permalink / raw)
To: Wei Wang, Martin KaFai Lau, Eric Dumazet
Cc: David S . Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI,
Linux Kernel Network Developers, kernel-janitors, lkml
On 10/10/17 19:23, Wei Wang wrote:
> On Tue, Oct 10, 2017 at 11:10 AM, Martin KaFai Lau <kafai@fb.com> wrote:
>> On Tue, Oct 10, 2017 at 05:55:27PM +0000, Colin King wrote:
>>> From: Colin Ian King <colin.king@canonical.com>
>>>
>>> The use of the | operator always leads to true on the expression
>>> (rt->rt6i_flags | RTF_CACHE) which looks rather suspect to me. I
>>> believe this is fixed by using & instead to just check the
>>> RTF_CACHE entry bit.
>> Good catch. LGTM. If rt does not have RTF_CACHE set, it should not be in the
>> exception table.
>>
>> Acked-by: Martin KaFai Lau <kafai@fb.com>
>>
>
> Thanks a lot for catching this. Yes. It should have been '&' instead of '|'.
>
> Acked-by: Wei Wang <weiwan@google.com>
Sorry, can you look at V2 of this patch; there is one more occurrence
that needed fixing.
>
>>>
>>> Detected by CoverityScan, CID#1457747 ("Wrong operator used")
>>>
>>> Fixes: 35732d01fe31 ("ipv6: introduce a hash table to store dst cache")
>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>>> ---
>>> net/ipv6/route.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
>>> index 6db1541eaa7b..0556d1ee189c 100644
>>> --- a/net/ipv6/route.c
>>> +++ b/net/ipv6/route.c
>>> @@ -1425,7 +1425,7 @@ int rt6_remove_exception_rt(struct rt6_info *rt)
>>> int err;
>>>
>>> if (!from ||
>>> - !(rt->rt6i_flags | RTF_CACHE))
>>> + !(rt->rt6i_flags & RTF_CACHE))
>>> return -EINVAL;
>>>
>>> if (!rcu_access_pointer(from->rt6i_exception_bucket))
>>> --
>>> 2.14.1
>>>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-10-10 18:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-10 17:55 [PATCH][net-next] ipv6: fix incorrect bitwise operator used on rt6i_flags Colin King
2017-10-10 18:05 ` NACK: " Colin Ian King
2017-10-10 18:10 ` Martin KaFai Lau
2017-10-10 18:23 ` Wei Wang
2017-10-10 18:24 ` Colin Ian King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox