net: ipv6: fix racey clock check in route cache aging logic
Subsystems (3)
PATCH 1/1 net: ipv6: fix racey clock check in route cache aging logic
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
Discovered-by-KUnit: https://kunit-review.googlesource.com/c/linux/+/1156
--- net/ipv6/route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/route.c +1 -1
@@ -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 ;
Signature · 1 line
2.19.1.568.g152ad8e336-goog
Quoted 19 lines · 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/+/1156Fixes 31afeb425f7f ("ipv6: change route cache aging logic")Discovered-by-KUnit: https://kunit-review.googlesource.com/c/linux/+/1156
Signed-off-by Brendan Higgins <[email protected]>--- net/ipv6/route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/ipv6/route.c +0
-0
net/ipv6/route.c static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket, · line 1740
Quoted 8 lines
net/ipv6/route.c +1
-1@@ -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.
Quoted 1 line · Eric Dumazet
On 10/25/2018 02:13 PM, Brendan Higgins wrote:
<snip>
Quoted 19 lines
Quoted 7 lines
net/ipv6/route.c +0
-0net/ipv6/route.c static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket, · line 1740
Quoted 8 lines
net/ipv6/route.c +1
-1@@ -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 ?
Quoted 2 lines
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
Quoted 25 lines · Brendan Higgins
Quoted 1 line · Eric Dumazet
On 10/25/2018 02:13 PM, Brendan Higgins wrote:
<snip>
Quoted 19 lines
Quoted 7 lines
net/ipv6/route.c +0
-0net/ipv6/route.c static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket, · line 1740
Quoted 8 lines
net/ipv6/route.c +1
-1@@ -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 ?
Quoted 2 lines
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.
Quoted 6 lines
Then why do we pass the
nowparameter 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)
Quoted 33 lines · Eric Dumazet
Quoted 29 lines · Brendan Higgins
Quoted 1 line · Eric Dumazet
On 10/25/2018 02:13 PM, Brendan Higgins wrote:
<snip>
Quoted 19 lines
Quoted 7 lines
net/ipv6/route.c +0
-0net/ipv6/route.c static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket, · line 1740
Quoted 8 lines
net/ipv6/route.c +1
-1@@ -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 ?
Quoted 2 lines
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
nowparameter in at all and use it at all, like here: https://elixir.bootlin.com/linux/latest/source/net/ipv6/route.c#L1764
?
Quoted 7 lines
Quoted 2 lines
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?
Quoted 3 lines
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!