* [PATCH] ipv6: Properly check reference count flag before taking reference
@ 2019-09-23 14:46 Jason A. Donenfeld
2019-09-23 15:06 ` Petr Vorel
0 siblings, 1 reply; 4+ messages in thread
From: Jason A. Donenfeld @ 2019-09-23 14:46 UTC (permalink / raw)
To: netdev, linux-kernel; +Cc: Jason A. Donenfeld, stable
People are reporting that WireGuard experiences erratic crashes on 5.3,
and bisected it down to 7d30a7f6424e. Casually flipping through that
commit I noticed that a flag is checked using `|` instead of `&`, which in
this current case, means that a reference is never incremented, which
would result in the use-after-free users are seeing. This commit changes
the `|` to the proper `&` test.
Cc: stable@vger.kernel.org
Fixes: 7d30a7f6424e ("Merge branch 'ipv6-avoid-taking-refcnt-on-dst-during-route-lookup'")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
net/ipv6/ip6_fib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 87f47bc55c5e..6e2af411cd9c 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -318,7 +318,7 @@ struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi6 *fl6,
if (rt->dst.error == -EAGAIN) {
ip6_rt_put_flags(rt, flags);
rt = net->ipv6.ip6_null_entry;
- if (!(flags | RT6_LOOKUP_F_DST_NOREF))
+ if (!(flags & RT6_LOOKUP_F_DST_NOREF))
dst_hold(&rt->dst);
}
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ipv6: Properly check reference count flag before taking reference
2019-09-23 14:46 [PATCH] ipv6: Properly check reference count flag before taking reference Jason A. Donenfeld
@ 2019-09-23 15:06 ` Petr Vorel
2019-09-23 15:24 ` Jason A. Donenfeld
2019-09-25 21:37 ` Eric Dumazet
0 siblings, 2 replies; 4+ messages in thread
From: Petr Vorel @ 2019-09-23 15:06 UTC (permalink / raw)
To: Jason A. Donenfeld; +Cc: netdev, linux-kernel, stable
Hi,
> People are reporting that WireGuard experiences erratic crashes on 5.3,
> and bisected it down to 7d30a7f6424e. Casually flipping through that
> commit I noticed that a flag is checked using `|` instead of `&`, which in
> this current case, means that a reference is never incremented, which
> would result in the use-after-free users are seeing. This commit changes
> the `|` to the proper `&` test.
> Cc: stable@vger.kernel.org
> Fixes: 7d30a7f6424e ("Merge branch 'ipv6-avoid-taking-refcnt-on-dst-during-route-lookup'")
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
NOTE: this change was added in d64a1f574a29 ("ipv6: honor RT6_LOOKUP_F_DST_NOREF in rule lookup logic")
Kind regards,
Petr
> ---
> net/ipv6/ip6_fib.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
> index 87f47bc55c5e..6e2af411cd9c 100644
> --- a/net/ipv6/ip6_fib.c
> +++ b/net/ipv6/ip6_fib.c
> @@ -318,7 +318,7 @@ struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi6 *fl6,
> if (rt->dst.error == -EAGAIN) {
> ip6_rt_put_flags(rt, flags);
> rt = net->ipv6.ip6_null_entry;
> - if (!(flags | RT6_LOOKUP_F_DST_NOREF))
> + if (!(flags & RT6_LOOKUP_F_DST_NOREF))
> dst_hold(&rt->dst);
> }
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ipv6: Properly check reference count flag before taking reference
2019-09-23 15:06 ` Petr Vorel
@ 2019-09-23 15:24 ` Jason A. Donenfeld
2019-09-25 21:37 ` Eric Dumazet
1 sibling, 0 replies; 4+ messages in thread
From: Jason A. Donenfeld @ 2019-09-23 15:24 UTC (permalink / raw)
To: Petr Vorel; +Cc: Netdev, LKML, stable
Apparently even with this (certainly correct) patch attached, users
are still experiencing problems. Bug hunting continues, and I'll
report back if I figure something out.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ipv6: Properly check reference count flag before taking reference
2019-09-23 15:06 ` Petr Vorel
2019-09-23 15:24 ` Jason A. Donenfeld
@ 2019-09-25 21:37 ` Eric Dumazet
1 sibling, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2019-09-25 21:37 UTC (permalink / raw)
To: Petr Vorel, Jason A. Donenfeld; +Cc: netdev, linux-kernel, stable
On 9/23/19 8:06 AM, Petr Vorel wrote:
> Hi,
>
>> People are reporting that WireGuard experiences erratic crashes on 5.3,
>> and bisected it down to 7d30a7f6424e. Casually flipping through that
>> commit I noticed that a flag is checked using `|` instead of `&`, which in
>> this current case, means that a reference is never incremented, which
>> would result in the use-after-free users are seeing. This commit changes
>> the `|` to the proper `&` test.
>
>> Cc: stable@vger.kernel.org
>> Fixes: 7d30a7f6424e ("Merge branch 'ipv6-avoid-taking-refcnt-on-dst-during-route-lookup'")
>> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>
> NOTE: this change was added in d64a1f574a29 ("ipv6: honor RT6_LOOKUP_F_DST_NOREF in rule lookup logic")
>
> Kind regards,
> Petr
>
This was fixed earlier I think
https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git/commit/?id=7b09c2d052db4b4ad0b27b97918b46a7746966fa
>> ---
>> net/ipv6/ip6_fib.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>> diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
>> index 87f47bc55c5e..6e2af411cd9c 100644
>> --- a/net/ipv6/ip6_fib.c
>> +++ b/net/ipv6/ip6_fib.c
>> @@ -318,7 +318,7 @@ struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi6 *fl6,
>> if (rt->dst.error == -EAGAIN) {
>> ip6_rt_put_flags(rt, flags);
>> rt = net->ipv6.ip6_null_entry;
>> - if (!(flags | RT6_LOOKUP_F_DST_NOREF))
>> + if (!(flags & RT6_LOOKUP_F_DST_NOREF))
>> dst_hold(&rt->dst);
>> }
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-09-25 21:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-23 14:46 [PATCH] ipv6: Properly check reference count flag before taking reference Jason A. Donenfeld
2019-09-23 15:06 ` Petr Vorel
2019-09-23 15:24 ` Jason A. Donenfeld
2019-09-25 21:37 ` Eric Dumazet
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).