Skip to content

Commit 1756b67

Browse files
committed
IB/sa: Fix sa_local_svc_timeout_ms read race
JIRA: https://issues.redhat.com/browse/RHEL-109942 commit 1428cd7 Author: Vlad Dumitrescu <vdumitrescu@nvidia.com> Date: Tue Sep 16 19:31:12 2025 +0300 IB/sa: Fix sa_local_svc_timeout_ms read race When computing the delta, the sa_local_svc_timeout_ms is read without ib_nl_request_lock held. Though unlikely in practice, this can cause a race condition if multiple local service threads are managing the timeout. Fixes: 2ca546b ("IB/sa: Route SA pathrecord query through netlink") Signed-off-by: Vlad Dumitrescu <vdumitrescu@nvidia.com> Reviewed-by: Mark Zhang <markzhang@nvidia.com> Signed-off-by: Edward Srouji <edwards@nvidia.com> Link: https://patch.msgid.link/20250916163112.98414-1-edwards@nvidia.com Signed-off-by: Leon Romanovsky <leon@kernel.org> Signed-off-by: Kamal Heib <kheib@redhat.com>
1 parent 7058f24 commit 1756b67

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/infiniband/core/sa_query.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,14 +1013,15 @@ int ib_nl_handle_set_timeout(struct sk_buff *skb,
10131013
if (timeout > IB_SA_LOCAL_SVC_TIMEOUT_MAX)
10141014
timeout = IB_SA_LOCAL_SVC_TIMEOUT_MAX;
10151015

1016+
spin_lock_irqsave(&ib_nl_request_lock, flags);
1017+
10161018
delta = timeout - sa_local_svc_timeout_ms;
10171019
if (delta < 0)
10181020
abs_delta = -delta;
10191021
else
10201022
abs_delta = delta;
10211023

10221024
if (delta != 0) {
1023-
spin_lock_irqsave(&ib_nl_request_lock, flags);
10241025
sa_local_svc_timeout_ms = timeout;
10251026
list_for_each_entry(query, &ib_nl_request_list, list) {
10261027
if (delta < 0 && abs_delta > query->timeout)
@@ -1038,9 +1039,10 @@ int ib_nl_handle_set_timeout(struct sk_buff *skb,
10381039
if (delay)
10391040
mod_delayed_work(ib_nl_wq, &ib_nl_timed_work,
10401041
(unsigned long)delay);
1041-
spin_unlock_irqrestore(&ib_nl_request_lock, flags);
10421042
}
10431043

1044+
spin_unlock_irqrestore(&ib_nl_request_lock, flags);
1045+
10441046
settimeout_out:
10451047
return 0;
10461048
}

0 commit comments

Comments
 (0)