linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] net: ipv6: fix racey clock check in route cache aging logic
@ 2018-10-25 21:13 Brendan Higgins
  2018-10-25 21:40 ` Eric Dumazet
  0 siblings, 1 reply; 5+ messages in thread
From: Brendan Higgins @ 2018-10-25 21:13 UTC (permalink / raw)
  To: davem, kuznet, yoshfuji; +Cc: netdev, linux-kernel, Brendan Higgins

Fix a bug where, with certain settings, the aging logic does not use the
time passed in as the current time, but instead directly checks jiffies.

This bug can be reproduced with (and this fix verified with) the test
at: https://kunit-review.googlesource.com/c/linux/+/1156

Fixes: 31afeb425f7f ("ipv6: change route cache aging logic")
Discovered-by-KUnit: https://kunit-review.googlesource.com/c/linux/+/1156
Signed-off-by: Brendan Higgins <brendanhiggins@google.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 2a7423c394560..54d28b91fd840 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1734,7 +1734,7 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
 			rt6_remove_exception(bucket, rt6_ex);
 			return;
 		}
-	} else if (time_after(jiffies, rt->dst.expires)) {
+	} else if (time_after(now, rt->dst.expires)) {
 		RT6_TRACE("purging expired route %p\n", rt);
 		rt6_remove_exception(bucket, rt6_ex);
 		return;
-- 
2.19.1.568.g152ad8e336-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] net: ipv6: fix racey clock check in route cache aging logic
  2018-10-25 21:13 [PATCH v1] net: ipv6: fix racey clock check in route cache aging logic Brendan Higgins
@ 2018-10-25 21:40 ` Eric Dumazet
  2018-10-25 21:46   ` Brendan Higgins
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2018-10-25 21:40 UTC (permalink / raw)
  To: Brendan Higgins, davem, kuznet, yoshfuji; +Cc: netdev, linux-kernel



On 10/25/2018 02:13 PM, Brendan Higgins wrote:
> Fix a bug where, with certain settings, the aging logic does not use the
> time passed in as the current time, but instead directly checks jiffies.
> 
> This bug can be reproduced with (and this fix verified with) the test
> at: https://kunit-review.googlesource.com/c/linux/+/1156
> 
> Fixes: 31afeb425f7f ("ipv6: change route cache aging logic")
> Discovered-by-KUnit: https://kunit-review.googlesource.com/c/linux/+/1156
> Signed-off-by: Brendan Higgins <brendanhiggins@google.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 2a7423c394560..54d28b91fd840 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -1734,7 +1734,7 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
>  			rt6_remove_exception(bucket, rt6_ex);
>  			return;
>  		}
> -	} else if (time_after(jiffies, rt->dst.expires)) {
> +	} else if (time_after(now, rt->dst.expires)) {
>  		RT6_TRACE("purging expired route %p\n", rt);
>  		rt6_remove_exception(bucket, rt6_ex);
>  		return;
> 


I do not think there is a bug here ?

As a matter of fact, using the latest value of jiffies is probably better,
since in some cases the @now variable could be quite in the past.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] net: ipv6: fix racey clock check in route cache aging logic
  2018-10-25 21:40 ` Eric Dumazet
@ 2018-10-25 21:46   ` Brendan Higgins
  2018-10-25 22:15     ` Eric Dumazet
  0 siblings, 1 reply; 5+ messages in thread
From: Brendan Higgins @ 2018-10-25 21:46 UTC (permalink / raw)
  To: eric.dumazet
  Cc: David S . Miller, kuznet, yoshfuji, netdev, Linux Kernel Mailing List

On Thu, Oct 25, 2018 at 2:40 PM Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On 10/25/2018 02:13 PM, Brendan Higgins wrote:
<snip>
> >
> > diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> > index 2a7423c394560..54d28b91fd840 100644
> > --- a/net/ipv6/route.c
> > +++ b/net/ipv6/route.c
> > @@ -1734,7 +1734,7 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
> >                       rt6_remove_exception(bucket, rt6_ex);
> >                       return;
> >               }
> > -     } else if (time_after(jiffies, rt->dst.expires)) {
> > +     } else if (time_after(now, rt->dst.expires)) {
> >               RT6_TRACE("purging expired route %p\n", rt);
> >               rt6_remove_exception(bucket, rt6_ex);
> >               return;
> >
>
>
> I do not think there is a bug here ?
>
> As a matter of fact, using the latest value of jiffies is probably better,
> since in some cases the @now variable could be quite in the past.

Then why do we pass the `now` parameter in at all and use it at all,
like here: https://elixir.bootlin.com/linux/latest/source/net/ipv6/route.c#L1764
?

I am still skeptical that we should check jiffies in each check, but
we should at least be consistent.

Cheers

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] net: ipv6: fix racey clock check in route cache aging logic
  2018-10-25 21:46   ` Brendan Higgins
@ 2018-10-25 22:15     ` Eric Dumazet
  2018-11-01 16:56       ` Brendan Higgins
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2018-10-25 22:15 UTC (permalink / raw)
  To: Brendan Higgins
  Cc: David S . Miller, kuznet, yoshfuji, netdev, Linux Kernel Mailing List



On 10/25/2018 02:46 PM, Brendan Higgins wrote:
> On Thu, Oct 25, 2018 at 2:40 PM Eric Dumazet <eric.dumazet@gmail.com> wrote:
>> On 10/25/2018 02:13 PM, Brendan Higgins wrote:
> <snip>
>>>
>>> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
>>> index 2a7423c394560..54d28b91fd840 100644
>>> --- a/net/ipv6/route.c
>>> +++ b/net/ipv6/route.c
>>> @@ -1734,7 +1734,7 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
>>>                       rt6_remove_exception(bucket, rt6_ex);
>>>                       return;
>>>               }
>>> -     } else if (time_after(jiffies, rt->dst.expires)) {
>>> +     } else if (time_after(now, rt->dst.expires)) {
>>>               RT6_TRACE("purging expired route %p\n", rt);
>>>               rt6_remove_exception(bucket, rt6_ex);
>>>               return;
>>>
>>
>>
>> I do not think there is a bug here ?
>>
>> As a matter of fact, using the latest value of jiffies is probably better,
>> since in some cases the @now variable could be quite in the past.
> 
> Then why do we pass the `now` parameter in at all and use it at all,
> like here: https://elixir.bootlin.com/linux/latest/source/net/ipv6/route.c#L1764
> ?
> 
> I am still skeptical that we should check jiffies in each check, but
> we should at least be consistent.

Well, this is a case where we do not really care.

When a bug is fixed (you added a Fixes: tag which is good), we want
to understand the real problem that needs to be fixed on stable kernels.

Since this does not seem to be a real issue, I would suggest you send a cleanup
patch when net-next is open (few days after linux-4.20-rc1 is release)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] net: ipv6: fix racey clock check in route cache aging logic
  2018-10-25 22:15     ` Eric Dumazet
@ 2018-11-01 16:56       ` Brendan Higgins
  0 siblings, 0 replies; 5+ messages in thread
From: Brendan Higgins @ 2018-11-01 16:56 UTC (permalink / raw)
  To: eric.dumazet
  Cc: David S . Miller, Alexey Kuznetsov, yoshfuji, netdev,
	Linux Kernel Mailing List

On Thu, Oct 25, 2018 at 3:15 PM Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
>
>
> On 10/25/2018 02:46 PM, Brendan Higgins wrote:
> > On Thu, Oct 25, 2018 at 2:40 PM Eric Dumazet <eric.dumazet@gmail.com> wrote:
> >> On 10/25/2018 02:13 PM, Brendan Higgins wrote:
> > <snip>
> >>>
> >>> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> >>> index 2a7423c394560..54d28b91fd840 100644
> >>> --- a/net/ipv6/route.c
> >>> +++ b/net/ipv6/route.c
> >>> @@ -1734,7 +1734,7 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
> >>>                       rt6_remove_exception(bucket, rt6_ex);
> >>>                       return;
> >>>               }
> >>> -     } else if (time_after(jiffies, rt->dst.expires)) {
> >>> +     } else if (time_after(now, rt->dst.expires)) {
> >>>               RT6_TRACE("purging expired route %p\n", rt);
> >>>               rt6_remove_exception(bucket, rt6_ex);
> >>>               return;
> >>>
> >>
> >>
> >> I do not think there is a bug here ?
> >>
> >> As a matter of fact, using the latest value of jiffies is probably better,
> >> since in some cases the @now variable could be quite in the past.
> >
> > Then why do we pass the `now` parameter in at all and use it at all,
> > like here: https://elixir.bootlin.com/linux/latest/source/net/ipv6/route.c#L1764
> > ?
> >
> > I am still skeptical that we should check jiffies in each check, but
> > we should at least be consistent.
>
> Well, this is a case where we do not really care.
>
> When a bug is fixed (you added a Fixes: tag which is good), we want
> to understand the real problem that needs to be fixed on stable kernels.

So by bug you mean user visible bug?
>
> Since this does not seem to be a real issue, I would suggest you send a cleanup
> patch when net-next is open (few days after linux-4.20-rc1 is release)

Sounds good, I will resend shortly.

Thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-11-01 16:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-25 21:13 [PATCH v1] net: ipv6: fix racey clock check in route cache aging logic Brendan Higgins
2018-10-25 21:40 ` Eric Dumazet
2018-10-25 21:46   ` Brendan Higgins
2018-10-25 22:15     ` Eric Dumazet
2018-11-01 16:56       ` Brendan Higgins

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).