]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: dst: annotate data-races around dst->lastuse
authorEric Dumazet <edumazet@google.com>
Mon, 30 Jun 2025 12:19:27 +0000 (12:19 +0000)
committerJakub Kicinski <kuba@kernel.org>
Wed, 2 Jul 2025 21:32:29 +0000 (14:32 -0700)
(dst_entry)->lastuse is read and written locklessly,
add corresponding annotations.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20250630121934.3399505-4-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/dst.h
net/core/rtnetlink.c
net/ipv6/route.c

index 1efe1e5d51a904a0fe907687835b8e07f32afaec..bef2f41c7220437b3cb177ea8c85b81b3f89e8f8 100644 (file)
@@ -240,9 +240,9 @@ static inline void dst_hold(struct dst_entry *dst)
 
 static inline void dst_use_noref(struct dst_entry *dst, unsigned long time)
 {
-       if (unlikely(time != dst->lastuse)) {
+       if (unlikely(time != READ_ONCE(dst->lastuse))) {
                dst->__use++;
-               dst->lastuse = time;
+               WRITE_ONCE(dst->lastuse, time);
        }
 }
 
index c57692eb8da9d47c3b0943bf7b8d8b7f7d347836..a9555bfc372f5709a3b846343986dce1edf935be 100644 (file)
@@ -1026,9 +1026,11 @@ int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst, u32 id,
                .rta_error = error,
                .rta_id =  id,
        };
+       unsigned long delta;
 
        if (dst) {
-               ci.rta_lastuse = jiffies_delta_to_clock_t(jiffies - dst->lastuse);
+               delta = jiffies - READ_ONCE(dst->lastuse);
+               ci.rta_lastuse = jiffies_delta_to_clock_t(delta);
                ci.rta_used = dst->__use;
                ci.rta_clntref = rcuref_read(&dst->__rcuref);
        }
index 1014dcea1200cb4d4fc63f7b335fd2663c4844a3..375112a59492ea3654d180c504946d96ed1592cd 100644 (file)
@@ -2133,7 +2133,8 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
         * expired, independently from their aging, as per RFC 8201 section 4
         */
        if (!(rt->rt6i_flags & RTF_EXPIRES)) {
-               if (time_after_eq(now, rt->dst.lastuse + gc_args->timeout)) {
+               if (time_after_eq(now, READ_ONCE(rt->dst.lastuse) +
+                                      gc_args->timeout)) {
                        pr_debug("aging clone %p\n", rt);
                        rt6_remove_exception(bucket, rt6_ex);
                        return;