<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="https://blog.bl4nk.kr/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://blog.bl4nk.kr</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></tabi:default_theme>
        <tabi:post_listing_date>date</tabi:post_listing_date>
        <tabi:current_section>mitigation</tabi:current_section>
    </tabi:metadata><link rel="extra-stylesheet" href="https://blog.bl4nk.kr/skins/lavender.css?h=31ee0a710ed660d122f6" /><title>~/bl4nk - mitigation</title>
        <subtitle>fill in the bl4nk</subtitle>
    <link href="https://blog.bl4nk.kr/tags/mitigation/atom.xml" rel="self" type="application/atom+xml"/>
    <link href="https://blog.bl4nk.kr/tags/mitigation/" rel="alternate" type="text/html"/>
    <generator uri="https://www.getzola.org/">Zola</generator><updated>2024-06-15T00:00:00+00:00</updated><id>https://blog.bl4nk.kr/tags/mitigation/atom.xml</id><entry xml:lang="en">
        <title>[SECCOMP] SECCOMP using prctl function</title>
        <published>2024-06-15T00:00:00+00:00</published>
        <updated>2024-06-15T00:00:00+00:00</updated>
        <author>
            <name>bl4nk</name>
        </author>
        <link rel="alternate" href="https://blog.bl4nk.kr/blog/seccomp-using-prctl-function/" type="text/html"/>
        <id>https://blog.bl4nk.kr/blog/seccomp-using-prctl-function/</id>
        
            <content type="html">&lt;h2 id=&quot;0x00-introduction&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#0x00-introduction&quot; aria-label=&quot;Anchor link for: 0x00-introduction&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
0x00. Introduction&lt;/h2&gt;
&lt;p&gt;The SECCOMP (SECure COMPuting mode) is a feature of Linux kernel that provides sandboxing of process.
In detail, it restricts the syscalls that are executed in the process, and terminates the process (SIGKILL) if a syscall is not allowed one.
Unlike other mitigations, it is not applied at compile time, but rather at run time.&lt;/p&gt;
&lt;p&gt;It seems that it was activated through the value of the &lt;code&gt;/proc/&amp;lt;pid&amp;gt;/seccomp&lt;/code&gt; in the past, but it had been changed to be set through &lt;code&gt;prctl&lt;/code&gt; or &lt;code&gt;sys_seccomp&lt;/code&gt;.(I don’t know since when…)&lt;/p&gt;
&lt;p&gt;In this post, I will describe the SECCOMP using the &lt;code&gt;prctl&lt;/code&gt; function.&lt;/p&gt;
&lt;h2 id=&quot;0x01-prctl-function&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#0x01-prctl-function&quot; aria-label=&quot;Anchor link for: 0x01-prctl-function&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
0x01. prctl function&lt;/h2&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; prctl&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-12&quot;&gt; option&lt;/span&gt;&lt;span&gt;,&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-l-5 z-d-3&quot;&gt;            /*&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; unsigned long arg2, unsigned long arg3,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;            unsigned long arg4, unsigned long arg5 &lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;*/&lt;/span&gt;&lt;span&gt; )&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;prctl&lt;/code&gt; function is a function for managing the properties of processes or threads (PRocess ConTroL).
In addition to applying SECCOMP, which will be explained in detail, it can be used to obtain the process name or the endian information.
Basically it receives a variable number of arguments and operates according to the desired action.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;/*&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Values to pass as first argument to prctl() &lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; PR_SET_PDEATHSIG&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;  1&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;  /*&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Second arg is a signal &lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; PR_GET_PDEATHSIG&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;  2&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;  /*&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Second arg is a ptr to return the signal &lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;/*&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Get/set current-&amp;gt;mm-&amp;gt;dumpable &lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; PR_GET_DUMPABLE&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;   3&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; PR_SET_DUMPABLE&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;   4&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;/*&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Get/set unaligned access control bits (if meaningful) &lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; PR_GET_UNALIGN&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;    5&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; PR_SET_UNALIGN&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;    6&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;/*&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Set/Get process name &lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; PR_SET_NAME&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;    15&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; PR_GET_NAME&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;    16&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;/*&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Get/set process endian &lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; PR_GET_ENDIAN&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;   19&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; PR_SET_ENDIAN&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;   20&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;/*&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Get/set process seccomp mode &lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; -----------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; PR_GET_SECCOMP&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;  21&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;                //&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; PR_SET_SECCOMP&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;  22&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;                //&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; PR_SET_NO_NEW_PRIVS&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;     38&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;        //&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; PR_GET_NO_NEW_PRIVS&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;     39&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;        //&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; -----------------------------------------&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the &lt;code&gt;prctl.h&lt;/code&gt;, you can check the values of the macros that go into the first argument, &lt;code&gt;option&lt;/code&gt;.
Among them, let’s take a closer look at &lt;code&gt;PR_SET_NO_NEW_PRIVS&lt;/code&gt; and &lt;code&gt;PR_SET_SECCOMP&lt;/code&gt;, which are related to the SECCOMP.&lt;/p&gt;
&lt;h3 id=&quot;pr-set-no-new-privs&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#pr-set-no-new-privs&quot; aria-label=&quot;Anchor link for: pr-set-no-new-privs&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
PR_SET_NO_NEW_PRIVS&lt;/h3&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; prctl&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;PR_SET_NO_NEW_PRIVS&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; int&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-12&quot;&gt; value&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The example above sets the &lt;code&gt;no_new_privs&lt;/code&gt; property of the current process as &lt;code&gt;value&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This property can be checked in the &lt;code&gt;NoNewPrivs&lt;/code&gt; field of &lt;code&gt;/proc/&amp;lt;pid&amp;gt;/status&lt;/code&gt; since the Linux kernel 4.10.
If the value of this property is set to 1, the current process and it’s child processes cannot execute codes that grant new privileges.
However, they can still execute codes that revoke privileges.&lt;/p&gt;
&lt;p&gt;The importance of this property will be described in the &lt;a href=&quot;https://blog.bl4nk.kr/blog/seccomp-using-prctl-function/#seccomp-mode-filter&quot;&gt;SECCOMP_MODE_FILTER&lt;/a&gt; part.&lt;/p&gt;
&lt;h3 id=&quot;pr-set-seccomp&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#pr-set-seccomp&quot; aria-label=&quot;Anchor link for: pr-set-seccomp&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
PR_SET_SECCOMP&lt;/h3&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; prctl&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;PR_SET_SECCOMP&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; int&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-12&quot;&gt; mode&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, we come to the actual control of SECCOMP, which has two modes.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; /*&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Valid values for seccomp.mode and prctl(PR_SET_SECCOMP, &amp;lt;mode&amp;gt;) &lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; #&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; SECCOMP_MODE_DISABLED&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;   0&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; /*&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; seccomp is not in use. &lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; #&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; SECCOMP_MODE_STRICT&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; /*&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; uses hard-coded filter. &lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; #&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; SECCOMP_MODE_FILTER&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 2&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; /*&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; uses user-supplied filter. &lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the &lt;code&gt;seccomp.h&lt;/code&gt;, each mode is defined as a macro.&lt;/p&gt;
&lt;h4 id=&quot;seccomp-mode-strict&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#seccomp-mode-strict&quot; aria-label=&quot;Anchor link for: seccomp-mode-strict&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
SECCOMP_MODE_STRICT&lt;/h4&gt;
&lt;p&gt;In this mode, only four syscalls are allowed: &lt;code&gt;read&lt;/code&gt;, &lt;code&gt;write&lt;/code&gt;, &lt;code&gt;exit&lt;/code&gt;, and &lt;code&gt;sigreturn&lt;/code&gt;. The third argument is not necessary because the available syscalls are already defined.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;include&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;stdio.h&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;include&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;sys/prctl.h&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;include&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;linux/seccomp.h&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;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-l-8 z-d-10&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; main&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&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-l-8 z-d-10&quot;&gt;        int&lt;/span&gt;&lt;span&gt; fd&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-l-8 z-d-10&quot;&gt;        char&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-12&quot;&gt; buf&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;16&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;0&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&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-l-8 z-d-10&quot;&gt;        if&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;prctl&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;PR_SET_SECCOMP&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; SECCOMP_MODE_STRICT&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; !=&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;)&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-l-6 z-d-7&quot;&gt;                perror&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;SET_SECCOMP error&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&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;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;        read&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; buf&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 16&lt;/span&gt;&lt;span&gt;)&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-l-6 z-d-7&quot;&gt;        write&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;1&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; buf&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&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&gt;        fd &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; open&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;a.txt&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&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-l-6 z-d-7&quot;&gt;        write&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;fd&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; buf&lt;/span&gt;&lt;span&gt;)&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-l-6 z-d-7&quot;&gt;        close&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;fd&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&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-l-8 z-d-10&quot;&gt;        return&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&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;/code&gt;&lt;/pre&gt;
&lt;p&gt;As a result of compiling and executing the code above, &lt;code&gt;SIGKILL&lt;/code&gt; occurred in &lt;code&gt;open&lt;/code&gt; like the following.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ./strict&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;hihi&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;hihi&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;    517393 killed     ./strict&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h4 id=&quot;seccomp-mode-filter&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#seccomp-mode-filter&quot; aria-label=&quot;Anchor link for: seccomp-mode-filter&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
SECCOMP_MODE_FILTER&lt;/h4&gt;
&lt;p&gt;This is a mode that the user builds a rule set to block certain syscalls.
The filter mode can be executed only when &lt;code&gt;no_new_privs&lt;/code&gt; property is set via the &lt;code&gt;PR_SET_NO_NEW_PRIVS&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The rule set is an assembly-like syntax called Berkeley Packet Filter (BPF), which will be covered in detail in the &lt;a href=&quot;https://blog.bl4nk.kr/blog/seccomp-using-prctl-function/#0x02-seccomp-tools&quot;&gt;seccomp-tools&lt;/a&gt; section.
The following is an example code of filtering out &lt;code&gt;write&lt;/code&gt; syscalls.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;include&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;stdio.h&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;include&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;sys/prctl.h&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;include&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;linux/seccomp.h&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;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-l-8 z-d-10&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; unsigned&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; char&lt;/span&gt;&lt;span&gt; filter&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;[]&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&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-l-1 z-d-4&quot;&gt;    32&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;    //&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; A = sys_number&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;    21&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 1&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 1&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;    //&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; if (A == write) goto 0003&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;    6&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 255&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 127&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;    //&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; return ALLOW&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;    6&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;        //&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; return KILL&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;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;struct&lt;/span&gt;&lt;span&gt; sock_fprog &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-l-8 z-d-10&quot;&gt;    unsigned&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; short&lt;/span&gt;&lt;span&gt; len&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-l-8 z-d-10&quot;&gt;    unsigned&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; char&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; *&lt;/span&gt;&lt;span&gt;filter&lt;/span&gt;&lt;span&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&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-l-8 z-d-10&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; main&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&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-l-8 z-d-10&quot;&gt;    int&lt;/span&gt;&lt;span&gt; fd&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-l-8 z-d-10&quot;&gt;    char&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-12&quot;&gt; buf&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;16&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;0&lt;/span&gt;&lt;span&gt;}&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-l-8 z-d-10&quot;&gt;    struct&lt;/span&gt;&lt;span&gt; sock_fprog prog&lt;/span&gt;&lt;span&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-l-8 z-d-10&quot;&gt;    if&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;prctl&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;PR_SET_NO_NEW_PRIVS&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 1&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; !=&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;)&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-l-6 z-d-7&quot;&gt;        perror&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;SET_NO_NEW_PRIVS error&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&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;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    prog&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;len&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; sizeof&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;filter&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; /&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 8&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    prog&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;filter&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; filter&lt;/span&gt;&lt;span&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-l-8 z-d-10&quot;&gt;    if&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;prctl&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;PR_SET_SECCOMP&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; SECCOMP_MODE_FILTER&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; &amp;amp;&lt;/span&gt;&lt;span&gt;prog&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; !=&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;)&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-l-6 z-d-7&quot;&gt;        perror&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;SET_SECCOMP error&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&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;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;    read&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; buf&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 16&lt;/span&gt;&lt;span&gt;)&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-l-6 z-d-7&quot;&gt;    write&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;1&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; buf&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;          //&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; &amp;lt;----- This will be blocked&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;    fd &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; open&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;a.txt&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&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-l-6 z-d-7&quot;&gt;    write&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;fd&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; buf&lt;/span&gt;&lt;span&gt;)&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-l-6 z-d-7&quot;&gt;    close&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;fd&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&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-l-8 z-d-10&quot;&gt;    return&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&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;/code&gt;&lt;/pre&gt;
&lt;p&gt;As a result of compiling and executing the code above, &lt;code&gt;SIGSYS&lt;/code&gt; occurred in &lt;code&gt;open&lt;/code&gt; like the following.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ./filter&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;hihi&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;    669145 invalid system call (&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; dumped&lt;/span&gt;&lt;span&gt;)  ./filter&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I tried to debug the process because it printed a different message from the &lt;code&gt;SIGKILL&lt;/code&gt; message of the strict mode, and I found that the process was terminated by &lt;code&gt;SIGSYS&lt;/code&gt; in filter mode.&lt;/p&gt;
&lt;h2 id=&quot;0x02-seccomp-tools&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#0x02-seccomp-tools&quot; aria-label=&quot;Anchor link for: 0x02-seccomp-tools&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
0x02. seccomp-tools&lt;/h2&gt;
&lt;p&gt;Looking at the example code of &lt;code&gt;SECCOMP_MODE_FILTER&lt;/code&gt;, you need to change the filtering rule into bytecodes and put them in the &lt;code&gt;filter&lt;/code&gt; array.
However, even if you are an expert, it is difficult to freely convert the desired BPF rule into bytecodes.
In this case, seccomp-tools is a good tool to use.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; sudo&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; apt&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; install&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; gcc&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ruby-dev&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;y&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; gem&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; install&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; seccomp-tools&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can install seccomp-tools like the above.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; seccomp-tools&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;Usage:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; seccomp-tools&lt;/span&gt;&lt;span&gt; [--version&lt;/span&gt;&lt;span&gt;] &lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;--help&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span&gt;command&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;options&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&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-l-6 z-d-7&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; of&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; commands:&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-l-6 z-d-7&quot;&gt;        asm&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;     Seccomp&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; bpf&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; assembler.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;        disasm&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  Disassemble&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; seccomp&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; bpf.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;        dump&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;    Automatically&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; dump&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; seccomp&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; bpf&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; from&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; execution&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; file&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;s&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;        emu&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;     Emulate&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; seccomp&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; rules.&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-l-6 z-d-7&quot;&gt;See&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;seccomp-tools &amp;lt;command&amp;gt; --help&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; to&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; read&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; about&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; a&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; specific&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; subcommand.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see in the usage, there are commands like &lt;code&gt;asm&lt;/code&gt;, &lt;code&gt;disasm&lt;/code&gt;, &lt;code&gt;dump&lt;/code&gt;, and &lt;code&gt;emu&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;asm&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#asm&quot; aria-label=&quot;Anchor link for: asm&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
asm&lt;/h3&gt;
&lt;p&gt;This command converts BPF rules written like the following to bytecodes.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;A = arch&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;if (A != ARCH_X86_64) goto dead&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;A = sys_number&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;if (A &amp;gt;= 0x40000000) goto dead&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;if (A == write) goto ok&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;if (A == close) goto ok&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;if (A == dup) goto ok&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;if (A == exit) goto ok&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;return ERRNO(5)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ok:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;return ALLOW&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;dead:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;return KILL&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The variable &lt;code&gt;A&lt;/code&gt; appeared out of nowhere, so I wondered what it was at first, but it’s easier to think of it as just a variable.&lt;/p&gt;
&lt;p&gt;Now, you can save this content as a file and pass it to the argument of seccomp-tools.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; seccomp-tools&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; asm&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; rule.txt&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; \x00\x00\x00\x04\x00\x00\x00\x15\x00\x00\b&amp;gt;\x00\x00\xC0 \x00\x00\x00\x00\x00\x00\x005\x00\x06\x00\x00\x00\x00@\x15\x00\x04\x00\x01\x00\x00\x00\x15\x00\x03\x00\x03\x00\x00\x00\x15\x00\x02\x00 \x00\x00\x00\x15\x00\x01\x00&amp;lt;\x00\x00\x00\x06\x00\x00\x00\x05\x00\x05\x00\x06\x00\x00\x00\x00\x00\xFF\x7F\x06\x00\x00\x00\x00\x00\x00\x00&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;&amp;quot;&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-l-6 z-d-7&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; seccomp-tools&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; asm&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; rule.txt&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; c_array&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;unsigned&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; char&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; bpf[]&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; {32,0,0,0,4,0,0,0,21,0,0,8,62,0,0,192,32,0,0,0,0,0,0,0,53,0,6,0,0,0,0,64,21,0,4,0,1,0,0,0,21,0,3,0,3,0,0,0,21,0,2,0,32,0,0,0,21,0,1,0,60,0,0,0,6,0,0,0,5,0,5,0,6,0,0,0,0,0,255,127,6,0,0,0,0,0,0,0}&lt;/span&gt;&lt;span&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-l-6 z-d-7&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; seccomp-tools&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; asm&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; rule.txt&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; c_source&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;include &amp;lt;linux/seccomp.h&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;include &amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;include &amp;lt;sys/prctl.h&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; void&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; install_seccomp&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;  static&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; unsigned&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; char&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; filter[]&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; {32,0,0,0,4,0,0,0,21,0,0,8,62,0,0,192,32,0,0,0,0,0,0,0,53,0,6,0,0,0,0,64,21,0,4,0,1,0,0,0,21,0,3,0,3,0,0,0,21,0,2,0,32,0,0,0,21,0,1,0,60,0,0,0,6,0,0,0,5,0,5,0,6,0,0,0,0,0,255,127,6,0,0,0,0,0,0,0}&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-l-6 z-d-7&quot;&gt;  struct&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; prog&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;    unsigned&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; short&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; len&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-l-6 z-d-7&quot;&gt;    unsigned&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; char&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; *&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;filter&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  } rule = &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-l-6 z-d-7&quot;&gt;    .len&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; sizeof&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;filter&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; &amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; 3,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;    .filter&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; filter&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&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;  if(prctl(PR_SET_NO_NEW_PRIVS,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; 1,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; 0,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; 0,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;span&gt;) &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span&gt; 0) &lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; perror(&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;prctl(PR_SET_NO_NEW_PRIVS)&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; exit&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  if(&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;prctl(PR_SET_SECCOMP,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; SECCOMP_MODE_FILTER,&lt;/span&gt;&lt;span&gt; &amp;amp;&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;rule&lt;/span&gt;&lt;span&gt;) &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span&gt; 0) &lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; perror(&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;prctl(PR_SET_SECCOMP)&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; exit&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&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;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see from the example above, you can output the results in various formats. The &lt;code&gt;-f&lt;/code&gt; option provides ready-to-use formats such as &lt;code&gt;raw&lt;/code&gt;, &lt;code&gt;c_array&lt;/code&gt;, &lt;code&gt;c_source&lt;/code&gt;, and &lt;code&gt;assembly&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;disasm&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#disasm&quot; aria-label=&quot;Anchor link for: disasm&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
disasm&lt;/h3&gt;
&lt;p&gt;The opposite command of &lt;code&gt;asm&lt;/code&gt;. It converts BPF in bytecode format to filtering rules.
You can give the file where the bytecodes are saved as an input file as an argument.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; xxd&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; rule.raw&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;00000000:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 2000&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0000&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0400&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0000&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 1500&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0008&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; 3e00&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; 00c0&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;   ..........&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;00000010:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 2000&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0000&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0000&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0000&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 3500&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0600&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0000&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0040&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;   .......5......@&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;00000020:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 1500&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0400&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0100&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0000&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 1500&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0300&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0300&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ................&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;00000030:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 1500&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0200&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 2000&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0000&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 1500&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0100&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; 3c00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ....&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; .......&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;00000040:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0600&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0000&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0500&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0500&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0600&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0000&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ff7f&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ................&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;00000050:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0600&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0000&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0000&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&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-l-6 z-d-7&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; seccomp-tools&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; disasm&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; rule.raw&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; line&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  CODE&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  JT&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;   JF&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;      K&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0000:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x20&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000004&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; arch&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0001:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x15&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x08&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0xc000003e&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; !=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ARCH_X86_64&lt;/span&gt;&lt;span&gt;) goto 0010&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0002:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x20&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; sys_number&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0003:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x35&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x06&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x40000000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (A&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x40000000&lt;/span&gt;&lt;span&gt;) goto 0010&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0004:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x15&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x04&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000001&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ==&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; write&lt;/span&gt;&lt;span&gt;) goto 0009&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0005:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x15&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x03&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000003&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ==&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; close&lt;/span&gt;&lt;span&gt;) goto 0009&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0006:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x15&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x02&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000020&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ==&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; dup&lt;/span&gt;&lt;span&gt;) goto 0009&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0007:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x15&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x01&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x0000003c&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ==&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; exit&lt;/span&gt;&lt;span&gt;) goto 0009&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0008:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x06&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00050005&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  return&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ERRNO&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;5&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-l-6 z-d-7&quot;&gt; 0009:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x06&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x7fff0000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  return&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ALLOW&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0010:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x06&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  return&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; KILL&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-l-6 z-d-7&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; seccomp-tools&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; asm&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; rule.txt&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; raw&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; |&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; seccomp-tools&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; disasm&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; -&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; line&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  CODE&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  JT&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;   JF&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;      K&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0000:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x20&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000004&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; arch&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0001:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x15&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x08&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0xc000003e&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; !=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ARCH_X86_64&lt;/span&gt;&lt;span&gt;) goto 0010&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0002:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x20&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; sys_number&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0003:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x35&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x06&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x40000000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (A&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x40000000&lt;/span&gt;&lt;span&gt;) goto 0010&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0004:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x15&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x04&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000001&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ==&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; write&lt;/span&gt;&lt;span&gt;) goto 0009&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0005:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x15&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x03&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000003&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ==&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; close&lt;/span&gt;&lt;span&gt;) goto 0009&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0006:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x15&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x02&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000020&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ==&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; dup&lt;/span&gt;&lt;span&gt;) goto 0009&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0007:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x15&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x01&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x0000003c&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ==&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; exit&lt;/span&gt;&lt;span&gt;) goto 0009&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0008:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x06&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00050005&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  return&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ERRNO&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;5&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-l-6 z-d-7&quot;&gt; 0009:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x06&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x7fff0000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  return&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ALLOW&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0010:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x06&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  return&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; KILL&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By pipelining the &lt;code&gt;asm&lt;/code&gt; command, you can check whether the BPF rule is written correctly.&lt;/p&gt;
&lt;h3 id=&quot;dump&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#dump&quot; aria-label=&quot;Anchor link for: dump&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
dump&lt;/h3&gt;
&lt;p&gt;This is a command that outputs the BPF rules applied within the binary.
I looked up how it works out of curiosity, and it seems to analyze the binary dynamically using &lt;code&gt;ptrace&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;However, since it prints the rules based on the first &lt;code&gt;prctl(PR_SET_SECCOMP)&lt;/code&gt;, it may be different from the actual result if the &lt;code&gt;prctl&lt;/code&gt; function was called multiple times.&lt;/p&gt;
&lt;p&gt;In that case, you can increase the number of &lt;code&gt;prctl&lt;/code&gt; functions to be checked by giving the &lt;code&gt;-l&lt;/code&gt; or &lt;code&gt;--limit&lt;/code&gt; option.&lt;/p&gt;
&lt;p&gt;You can also give the &lt;code&gt;-p&lt;/code&gt; or &lt;code&gt;--pid&lt;/code&gt; option to check the rules applied to the running process.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; seccomp-tools&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; dump&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ./filter&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; line&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  CODE&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  JT&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;   JF&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;      K&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0000:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x20&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000004&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; arch&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0001:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x15&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x03&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0xc000003e&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; !=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ARCH_X86_64&lt;/span&gt;&lt;span&gt;) goto 0005&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0002:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x20&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; sys_number&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0003:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x15&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x01&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000001&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ==&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; write&lt;/span&gt;&lt;span&gt;) goto 0005&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0004:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x06&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x7fff0000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  return&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ALLOW&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0005:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x06&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  return&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; KILL&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-l-6 z-d-7&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; sudo&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; seccomp-tools&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; dump&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; `&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;pgrep&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; filter&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; line&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  CODE&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  JT&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;   JF&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;      K&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0000:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x20&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000004&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; arch&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0001:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x15&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x03&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0xc000003e&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; !=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ARCH_X86_64&lt;/span&gt;&lt;span&gt;) goto 0005&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0002:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x20&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; sys_number&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0003:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x15&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x01&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000001&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ==&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; write&lt;/span&gt;&lt;span&gt;) goto 0005&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0004:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x06&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x7fff0000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  return&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ALLOW&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0005:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x06&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  return&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; KILL&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can use the &lt;code&gt;dump&lt;/code&gt; command like this.&lt;/p&gt;
&lt;h3 id=&quot;emu&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#emu&quot; aria-label=&quot;Anchor link for: emu&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
emu&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;emu&lt;/code&gt; is a good command to check whether syscalls are properly called or blocked by emulating rule sets.
When ran in &lt;code&gt;bash&lt;/code&gt;, the output is colored and easy to check.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.bl4nk.kr/blog/seccomp-using-prctl-function/./image.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.bl4nk.kr/blog/seccomp-using-prctl-function/./image-1.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;0x03-expected-vulnerability&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#0x03-expected-vulnerability&quot; aria-label=&quot;Anchor link for: 0x03-expected-vulnerability&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
0x03. Expected Vulnerability&lt;/h2&gt;
&lt;p&gt;Of course, it depends on how it was coded, but I thought about vulnerabilities that could occur easily.&lt;/p&gt;
&lt;h3 id=&quot;x32-syscall&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#x32-syscall&quot; aria-label=&quot;Anchor link for: x32-syscall&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
x32 Syscall&lt;/h3&gt;
&lt;p&gt;In the previous example of &lt;code&gt;disasm&lt;/code&gt; command in seccomp-tools, there were rules like these.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0000: 0x20 0x00 0x00 0x00000004  A = arch&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0001: 0x15 0x00 0x08 0xc000003e  if (A != ARCH_X86_64) goto 0010&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0002: 0x20 0x00 0x00 0x00000000  A = sys_number&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0003: 0x35 0x06 0x00 0x40000000  if (A &amp;gt;= 0x40000000) goto 0010&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;0001&lt;/code&gt; line is the logic to check if the architecture is &lt;code&gt;X86_64&lt;/code&gt;, then why does it check if the &lt;code&gt;sys_number&lt;/code&gt; of the &lt;code&gt;0003&lt;/code&gt; line is greater than &lt;code&gt;0x40000000&lt;/code&gt;?&lt;/p&gt;
&lt;p&gt;The reason is the compatibility of the &lt;code&gt;X86_64&lt;/code&gt; architecture.
It was developed for the instructions used in the previous 32-bit to be also used in the 64-bit architecture, and this whole concept is called the x32 ABI.
Therefore, 32-bit syscalls can be called in the 64-bit architecture, and the method for doing so is to add &lt;code&gt;0x40000000&lt;/code&gt; to the 64-bit syscall number in Linux.&lt;/p&gt;
&lt;p&gt;Let’s look at the code of the &lt;code&gt;do_syscall_x32&lt;/code&gt; function that is called when a 32-bit syscall is actually called in the Linux kernel.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;static&lt;/span&gt;&lt;span&gt; __always_inline &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; do_syscall_x32&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;struct&lt;/span&gt;&lt;span&gt; pt_regs &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-12&quot;&gt;regs&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; int&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-12&quot;&gt; nr&lt;/span&gt;&lt;span&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 class=&quot;z-l-5 z-d-3&quot;&gt;    /*&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;     * Adjust the starting offset of the table, and convert numbers&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;     * &amp;lt; __X32_SYSCALL_BIT to very high and thus out of range&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;     * numbers for comparisons.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;     */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;    unsigned&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; int&lt;/span&gt;&lt;span&gt; xnr &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;=&lt;/span&gt;&lt;span&gt; nr &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;-&lt;/span&gt;&lt;span&gt; __X32_SYSCALL_BIT&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-l-8 z-d-10&quot;&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;IS_ENABLED&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;CONFIG_X86_X32_ABI&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; &amp;amp;&amp;amp;&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; likely&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;xnr &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span&gt; X32_NR_syscalls&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        xnr &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; array_index_nospec&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;xnr&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; X32_NR_syscalls&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        regs&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;ax&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-12&quot;&gt; x32_sys_call_table&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;xnr&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;regs&lt;/span&gt;&lt;span&gt;)&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-l-8 z-d-10&quot;&gt;        return&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; true&lt;/span&gt;&lt;span&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 class=&quot;z-l-8 z-d-10&quot;&gt;    return&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; false&lt;/span&gt;&lt;span&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;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the first line of the function, &lt;code&gt;xnr = nr - __X32_SYSCALL_BIT&lt;/code&gt; is executed, and the &lt;code&gt;__X32_SYSCALL_BIT&lt;/code&gt; value is predefined value &lt;code&gt;0x40000000&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Therefore, if there is no logic to verify that the syscall number is less than &lt;code&gt;0x40000000&lt;/code&gt; in the BPF rule of a 64-bit binary, even if a specific syscall is blocked, you can still call the syscall of the 32-bit architecture by adding &lt;code&gt;0x40000000&lt;/code&gt; to the syscall number using the x32 ABI.&lt;/p&gt;
&lt;h3 id=&quot;filter-overwrite&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#filter-overwrite&quot; aria-label=&quot;Anchor link for: filter-overwrite&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Filter Overwrite&lt;/h3&gt;
&lt;p&gt;The simplest idea that comes to mind is that it is a vulnerability that can occur when the BPF filter rule part in memory can be overwritten with a desired value before SECCOMP is set. There are ways to do this, such as changing the rule to allow calling the desired syscall, or overwriting the rule with &lt;code&gt;return ALLOW&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;There is a related challenge on &lt;a class=&quot;external&quot; rel=&quot;external&quot; href=&quot;https://dreamhack.io&quot;&gt;dreamhack.io&lt;/a&gt;, which I recommend trying.&lt;/p&gt;
&lt;h3 id=&quot;seccomp-bypass&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#seccomp-bypass&quot; aria-label=&quot;Anchor link for: seccomp-bypass&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
SECCOMP Bypass&lt;/h3&gt;
&lt;p&gt;I found out while using &lt;code&gt;PR_SET_SECCOMP&lt;/code&gt; that if the BPF rule is slightly wrong, the prctl function only returns an error and does not terminate the process.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; cat&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; wrong.txt&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; sys_number&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ==&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; write&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; goto&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 3&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ALLOW&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; KILL&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-l-6 z-d-7&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; seccomp-tools&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; asm&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; wrong.txt&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; raw&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; |&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; seccomp-tools&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; disasm&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; -&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; line&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  CODE&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  JT&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;   JF&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;      K&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;=&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0000:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x20&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; sys_number&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0001:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x15&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x03&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000001&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (A&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ==&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; write&lt;/span&gt;&lt;span&gt;) goto 0005&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0002:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x06&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x7fff0000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  return&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ALLOW&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; 0003:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x06&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0x00000000&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  return&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; KILL&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here is an example of a wrong BPF rule. If you look closely, you will see that it says goto 0005 on line 0001.
When composing &lt;code&gt;wrong.txt&lt;/code&gt;, I thoughtlessly set line of &lt;code&gt;goto&lt;/code&gt; as 3 where &lt;code&gt;return KILL&lt;/code&gt; is located, but I found out that I had to calculate the line as a relative address.&lt;/p&gt;
&lt;p&gt;For example, if &lt;code&gt;goto 0&lt;/code&gt; is on the current line 0001, it is interpreted as going to the next line, 0002; and if it’s &lt;code&gt;goto 1&lt;/code&gt;, it is interpreted as going to the next next line, 0003. So &lt;code&gt;goto 3&lt;/code&gt; becomes a command to go to line 0005.
Since line 0005 does not exist in &lt;code&gt;wrong.txt&lt;/code&gt;, an error occurs when passing it as an option to &lt;code&gt;prctl&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ./filter&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;SET_SECCOMP&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; error:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; Invalid&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; argument&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;hihi&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;hihi&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When the wrong rule is applied, a SECCOMP error occurs like this.
As a result, the rule that was supposed to block the &lt;code&gt;write&lt;/code&gt; syscall was not applied, so the input string was output to &lt;code&gt;STDOUT&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Therefore, even if the entire filter cannot be overwritten like &lt;a href=&quot;https://blog.bl4nk.kr/blog/seccomp-using-prctl-function/#filter-overwrite&quot;&gt;Filter Overwrite&lt;/a&gt;, if the rule itself can be made nonsensical with a few bytes, an error will occur, but the process will be maintained, so SECCOMP bypass is possible.&lt;/p&gt;
&lt;h2 id=&quot;0x04-references&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#0x04-references&quot; aria-label=&quot;Anchor link for: 0x04-references&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
0x04. References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class=&quot;external&quot; rel=&quot;external&quot; href=&quot;https://man7.org/linux/man-pages/man2/prctl.2.html&quot;&gt;https://man7.org/linux/man-pages/man2/prctl.2.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&quot;external&quot; rel=&quot;external&quot; href=&quot;https://jeongzero.oopy.io/06eebad5-8306-493f-9c6d-e7a04d5aacff&quot;&gt;https://jeongzero.oopy.io/06eebad5-8306-493f-9c6d-e7a04d5aacff&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&quot;external&quot; rel=&quot;external&quot; href=&quot;https://velog.io/@woounnan/LINUX-Seccomp&quot;&gt;https://velog.io/@woounnan/LINUX-Seccomp&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&quot;external&quot; rel=&quot;external&quot; href=&quot;https://velog.io/@dandb3/SECCOMP2&quot;&gt;https://velog.io/@dandb3/SECCOMP2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&quot;external&quot; rel=&quot;external&quot; href=&quot;https://learn.dreamhack.io/280&quot;&gt;https://learn.dreamhack.io/280&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&quot;external&quot; rel=&quot;external&quot; href=&quot;https://github.com/david942j/seccomp-tools&quot;&gt;https://github.com/david942j/seccomp-tools&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
        <summary type="html">From usage of prctl function to related tool and expected vulnerailities</summary>
        </entry>
</feed>
