<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet href="/static/style.xsl" type="text/xsl"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0">
  <channel>
    <title>Most recent entries from all</title>
    <link>https://vulnerability.circl.lu</link>
    <description>Contains only the most 10 recent entries.</description>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <generator>python-feedgen</generator>
    <language>en</language>
    <lastBuildDate>Sun, 04 Oct 2026 20:35:44 +0000</lastBuildDate>
    <item>
      <title>CVE-2022-49607 — perf/core: Fix data race between perf_event_set_output() and perf_mmap_close()</title>
      <link>https://vulnerability.circl.lu/vuln/cve-2022-49607</link>
      <description>&lt;p&gt;&lt;strong&gt;Affected:&lt;/strong&gt; Linux&lt;/p&gt;
&lt;p&gt;In the Linux kernel, the following vulnerability has been resolved:&lt;/p&gt;
&lt;p&gt;perf/core: Fix data race between perf_event_set_output() and perf_mmap_close()&lt;/p&gt;
&lt;p&gt;Yang Jihing reported a race between perf_event_set_output() and
perf_mmap_close():&lt;/p&gt;
&lt;p&gt;CPU1					CPU2&lt;/p&gt;
&lt;p&gt;perf_mmap_close(e2)
	  if (atomic_dec_and_test(&amp;amp;e2-&amp;gt;rb-&amp;gt;mmap_count)) // 1 - &amp;gt; 0
	    detach_rest = true&lt;/p&gt;
&lt;p&gt;ioctl(e1, IOC_SET_OUTPUT, e2)
						  perf_event_set_output(e1, e2)&lt;/p&gt;
&lt;p&gt;...
	  list_for_each_entry_rcu(e, &amp;amp;e2-&amp;gt;rb-&amp;gt;event_list, rb_entry)
	    ring_buffer_attach(e, NULL);
	    // e1 isn&amp;#39;t yet added and
	    // therefore not detached&lt;/p&gt;
&lt;p&gt;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)&lt;/p&gt;
&lt;p&gt;After this; e1 is attached to an unmapped rb and a subsequent
perf_mmap() will loop forever more:&lt;/p&gt;
&lt;p&gt;again:
		mutex_lock(&amp;amp;e-&amp;gt;mmap_mutex);
		if (event-&amp;gt;rb) {
			...
			if (!atomic_inc_not_zero(&amp;amp;e-&amp;gt;rb-&amp;gt;mmap_count)) {
				...
				mutex_unlock(&amp;amp;e-&amp;gt;mmap_mutex);
				goto again;
			}
		}&lt;/p&gt;
&lt;p&gt;The loop in perf_mmap_close() holds e2-&amp;gt;mmap_mutex, while the attach
in perf_event_set_output() holds e1-&amp;gt;mmap_mutex. As such there is no
serialization to avoid this race.&lt;/p&gt;
&lt;p&gt;Change perf_event_set_output() to take both e1-&amp;gt;mmap_mutex and
e2-&amp;gt;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.&lt;/p&gt;</description>
      <content:encoded>&lt;p&gt;&lt;strong&gt;Affected:&lt;/strong&gt; Linux&lt;/p&gt;
&lt;p&gt;In the Linux kernel, the following vulnerability has been resolved:&lt;/p&gt;
&lt;p&gt;perf/core: Fix data race between perf_event_set_output() and perf_mmap_close()&lt;/p&gt;
&lt;p&gt;Yang Jihing reported a race between perf_event_set_output() and
perf_mmap_close():&lt;/p&gt;
&lt;p&gt;CPU1					CPU2&lt;/p&gt;
&lt;p&gt;perf_mmap_close(e2)
	  if (atomic_dec_and_test(&amp;amp;e2-&amp;gt;rb-&amp;gt;mmap_count)) // 1 - &amp;gt; 0
	    detach_rest = true&lt;/p&gt;
&lt;p&gt;ioctl(e1, IOC_SET_OUTPUT, e2)
						  perf_event_set_output(e1, e2)&lt;/p&gt;
&lt;p&gt;...
	  list_for_each_entry_rcu(e, &amp;amp;e2-&amp;gt;rb-&amp;gt;event_list, rb_entry)
	    ring_buffer_attach(e, NULL);
	    // e1 isn&amp;#39;t yet added and
	    // therefore not detached&lt;/p&gt;
&lt;p&gt;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)&lt;/p&gt;
&lt;p&gt;After this; e1 is attached to an unmapped rb and a subsequent
perf_mmap() will loop forever more:&lt;/p&gt;
&lt;p&gt;again:
		mutex_lock(&amp;amp;e-&amp;gt;mmap_mutex);
		if (event-&amp;gt;rb) {
			...
			if (!atomic_inc_not_zero(&amp;amp;e-&amp;gt;rb-&amp;gt;mmap_count)) {
				...
				mutex_unlock(&amp;amp;e-&amp;gt;mmap_mutex);
				goto again;
			}
		}&lt;/p&gt;
&lt;p&gt;The loop in perf_mmap_close() holds e2-&amp;gt;mmap_mutex, while the attach
in perf_event_set_output() holds e1-&amp;gt;mmap_mutex. As such there is no
serialization to avoid this race.&lt;/p&gt;
&lt;p&gt;Change perf_event_set_output() to take both e1-&amp;gt;mmap_mutex and
e2-&amp;gt;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.&lt;/p&gt;</content:encoded>
      <guid isPermaLink="false">https://vulnerability.circl.lu/vuln/cve-2022-49607</guid>
    </item>
  </channel>
</rss>
