{"id":"DEBIAN-CVE-2022-49607","details":"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():  \tCPU1\t\t\t\t\tCPU2  \tperf_mmap_close(e2) \t  if (atomic_dec_and_test(&e2-\u003erb-\u003emmap_count)) // 1 - \u003e 0 \t    detach_rest = true  \t\t\t\t\t\tioctl(e1, IOC_SET_OUTPUT, e2) \t\t\t\t\t\t  perf_event_set_output(e1, e2)  \t  ... \t  list_for_each_entry_rcu(e, &e2-\u003erb-\u003eevent_list, rb_entry) \t    ring_buffer_attach(e, NULL); \t    // e1 isn't yet added and \t    // therefore not detached  \t\t\t\t\t\t    ring_buffer_attach(e1, e2-\u003erb) \t\t\t\t\t\t      list_add_rcu(&e1-\u003erb_entry, \t\t\t\t\t\t\t\t   &e2-\u003erb-\u003eevent_list)  After this; e1 is attached to an unmapped rb and a subsequent perf_mmap() will loop forever more:  \tagain: \t\tmutex_lock(&e-\u003emmap_mutex); \t\tif (event-\u003erb) { \t\t\t... \t\t\tif (!atomic_inc_not_zero(&e-\u003erb-\u003emmap_count)) { \t\t\t\t... \t\t\t\tmutex_unlock(&e-\u003emmap_mutex); \t\t\t\tgoto again; \t\t\t} \t\t}  The loop in perf_mmap_close() holds e2-\u003emmap_mutex, while the attach in perf_event_set_output() holds e1-\u003emmap_mutex. As such there is no serialization to avoid this race.  Change perf_event_set_output() to take both e1-\u003emmap_mutex and e2-\u003emmap_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.","modified":"2026-09-01T16:05:32.956555315Z","published":"2025-02-26T07:01:36.180Z","upstream":["CVE-2022-49607"],"references":[{"type":"ADVISORY","url":"https://security-tracker.debian.org/tracker/CVE-2022-49607"}],"affected":[{"package":{"name":"linux","ecosystem":"Debian:12","purl":"pkg:deb/debian/linux?arch=source&distro=bookworm"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"5.18.16-1"}]}],"ecosystem_specific":{"urgency":"not yet assigned"},"database_specific":{"source":"https://storage.googleapis.com/osv-test-debian-osv/debian-cve-osv/DEBIAN-CVE-2022-49607.json"}},{"package":{"name":"linux","ecosystem":"Debian:13","purl":"pkg:deb/debian/linux?arch=source&distro=trixie"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"5.18.16-1"}]}],"ecosystem_specific":{"urgency":"not yet assigned"},"database_specific":{"source":"https://storage.googleapis.com/osv-test-debian-osv/debian-cve-osv/DEBIAN-CVE-2022-49607.json"}},{"package":{"name":"linux","ecosystem":"Debian:14","purl":"pkg:deb/debian/linux?arch=source&distro=forky"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"5.18.16-1"}]}],"ecosystem_specific":{"urgency":"not yet assigned"},"database_specific":{"source":"https://storage.googleapis.com/osv-test-debian-osv/debian-cve-osv/DEBIAN-CVE-2022-49607.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H"}]}