Race Condition Affecting kernel-macros package, versions <5.14.21-150400.24.158.1


Severity

Recommended
0.0
medium
0
10

Based on SUSE Linux Enterprise Server security rating.

Threat Intelligence

EPSS
0.02% (3rd percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-SLES154-KERNELMACROS-9534826
  • published27 Mar 2025
  • disclosed26 Mar 2025

Introduced: 26 Mar 2025

CVE-2022-49607  (opens in a new tab)
CWE-362  (opens in a new tab)

How to fix?

Upgrade SLES:15.4 kernel-macros to version 5.14.21-150400.24.158.1 or higher.

NVD Description

Note: Versions mentioned in the description apply only to the upstream kernel-macros package and not the kernel-macros package as distributed by SLES. See How to fix? for SLES:15.4 relevant fixed versions and status.

In the Linux kernel, the following vulnerability has been resolved:

perf/core: Fix data race between perf_event_set_output() and perf_mmap_close()

Yang Jihing reported a race between perf_event_set_output() and perf_mmap_close():

CPU1					CPU2

perf_mmap_close(e2) if (atomic_dec_and_test(&amp;e2-&gt;rb-&gt;mmap_count)) // 1 - &gt; 0 detach_rest = true

                ioctl(e1, IOC_SET_OUTPUT, e2)
                  perf_event_set_output(e1, e2)

... list_for_each_entry_rcu(e, &amp;e2-&gt;rb-&gt;event_list, rb_entry) ring_buffer_attach(e, NULL); // e1 isn&#39;t yet added and // therefore not detached

                    ring_buffer_attach(e1, e2-&amp;gt;rb)
                      list_add_rcu(&amp;amp;e1-&amp;gt;rb_entry,
                           &amp;amp;e2-&amp;gt;rb-&amp;gt;event_list)

After this; e1 is attached to an unmapped rb and a subsequent perf_mmap() will loop forever more:

again:
    mutex_lock(&amp;e-&gt;mmap_mutex);
    if (event-&gt;rb) {
        ...
        if (!atomic_inc_not_zero(&amp;e-&gt;rb-&gt;mmap_count)) {
            ...
            mutex_unlock(&amp;e-&gt;mmap_mutex);
            goto again;
        }
    }

The loop in perf_mmap_close() holds e2->mmap_mutex, while the attach in perf_event_set_output() holds e1->mmap_mutex. As such there is no serialization to avoid this race.

Change perf_event_set_output() to take both e1->mmap_mutex and e2->mmap_mutex to alleviate that problem. Additionally, have the loop in perf_mmap() detach the rb directly, this avoids having to wait for the concurrent perf_mmap_close() to get around to doing it to make progress.

CVSS Base Scores

version 3.1