* [PATCH] ipv6: prevent a possible race condition with lifetimes
@ 2022-02-20 17:54 Niels Dossche
2022-02-22 3:02 ` David Ahern
2022-02-23 0:43 ` Jakub Kicinski
0 siblings, 2 replies; 4+ messages in thread
From: Niels Dossche @ 2022-02-20 17:54 UTC (permalink / raw)
To: David S. Miller, Hideaki YOSHIFUJI, David Ahern; +Cc: netdev, linux-kernel
valid_lft, prefered_lft and tstamp are always accessed under the lock
"lock" in other places. Reading these without taking the lock may result
in inconsistencies regarding the calculation of the valid and preferred
variables since decisions are taken on these fields for those variables.
Signed-off-by: Niels Dossche <niels.dossche@ugent.be>
---
net/ipv6/addrconf.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 3f23da8c0b10..6c8ab3e6e6fe 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -4998,6 +4998,7 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,
nla_put_s32(skb, IFA_TARGET_NETNSID, args->netnsid))
goto error;
+ spin_lock_bh(&ifa->lock);
if (!((ifa->flags&IFA_F_PERMANENT) &&
(ifa->prefered_lft == INFINITY_LIFE_TIME))) {
preferred = ifa->prefered_lft;
@@ -5019,6 +5020,7 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,
preferred = INFINITY_LIFE_TIME;
valid = INFINITY_LIFE_TIME;
}
+ spin_unlock_bh(&ifa->lock);
if (!ipv6_addr_any(&ifa->peer_addr)) {
if (nla_put_in6_addr(skb, IFA_LOCAL, &ifa->addr) < 0 ||
--
2.35.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ipv6: prevent a possible race condition with lifetimes
2022-02-20 17:54 [PATCH] ipv6: prevent a possible race condition with lifetimes Niels Dossche
@ 2022-02-22 3:02 ` David Ahern
2022-02-23 0:43 ` Jakub Kicinski
1 sibling, 0 replies; 4+ messages in thread
From: David Ahern @ 2022-02-22 3:02 UTC (permalink / raw)
To: Niels Dossche, David S. Miller, Hideaki YOSHIFUJI; +Cc: netdev, linux-kernel
On 2/20/22 10:54 AM, Niels Dossche wrote:
> valid_lft, prefered_lft and tstamp are always accessed under the lock
> "lock" in other places. Reading these without taking the lock may result
> in inconsistencies regarding the calculation of the valid and preferred
> variables since decisions are taken on these fields for those variables.
>
> Signed-off-by: Niels Dossche <niels.dossche@ugent.be>
> ---
> net/ipv6/addrconf.c | 2 ++
> 1 file changed, 2 insertions(+)
>
Reviewed-by: David Ahern <dsahern@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ipv6: prevent a possible race condition with lifetimes
2022-02-20 17:54 [PATCH] ipv6: prevent a possible race condition with lifetimes Niels Dossche
2022-02-22 3:02 ` David Ahern
@ 2022-02-23 0:43 ` Jakub Kicinski
2022-02-23 13:33 ` Niels Dossche
1 sibling, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2022-02-23 0:43 UTC (permalink / raw)
To: Niels Dossche; +Cc: David S. Miller, Hideaki YOSHIFUJI, David Ahern, netdev
On Sun, 20 Feb 2022 18:54:40 +0100 Niels Dossche wrote:
> valid_lft, prefered_lft and tstamp are always accessed under the lock
> "lock" in other places. Reading these without taking the lock may result
> in inconsistencies regarding the calculation of the valid and preferred
> variables since decisions are taken on these fields for those variables.
>
> Signed-off-by: Niels Dossche <niels.dossche@ugent.be>
Looks like your email client has replaced tabs with spaces,
so the patch won't apply. Could you try resending with git send-email?
Please add Dave's review tag in the next version, and the subject
tag should be [PATCH net v2]. Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ipv6: prevent a possible race condition with lifetimes
2022-02-23 0:43 ` Jakub Kicinski
@ 2022-02-23 13:33 ` Niels Dossche
0 siblings, 0 replies; 4+ messages in thread
From: Niels Dossche @ 2022-02-23 13:33 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: David S. Miller, Hideaki YOSHIFUJI, David Ahern, netdev
It appears that the mail server of the university is changing tabs to spaces.
I will resend it from my personal gmail address, since that does not seem to
change tabs to spaces. Sorry for the inconvenience. Thanks!
On 23/02/2022 01:43, Jakub Kicinski wrote:
> On Sun, 20 Feb 2022 18:54:40 +0100 Niels Dossche wrote:
>> valid_lft, prefered_lft and tstamp are always accessed under the lock
>> "lock" in other places. Reading these without taking the lock may result
>> in inconsistencies regarding the calculation of the valid and preferred
>> variables since decisions are taken on these fields for those variables.
>>
>> Signed-off-by: Niels Dossche <niels.dossche@ugent.be>
>
> Looks like your email client has replaced tabs with spaces,
> so the patch won't apply. Could you try resending with git send-email?
> Please add Dave's review tag in the next version, and the subject
> tag should be [PATCH net v2]. Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-02-23 13:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-20 17:54 [PATCH] ipv6: prevent a possible race condition with lifetimes Niels Dossche
2022-02-22 3:02 ` David Ahern
2022-02-23 0:43 ` Jakub Kicinski
2022-02-23 13:33 ` Niels Dossche
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).