โšก Embedded Security

Linux 2.6.36-to-6.12 sk_buff ABI Interposition vs. Native OpenWrt 25.12 Packaging (Part 5)

When security researchers confront a 15-year gap between a vendor's Linux 2.6.36.4 binary driver and mainline OpenWrt 25.12 (Linux 6.12 LTS), two distinct engineering schools emerge in the wild: Track A (Binary Kernel ABI Interposition), which cages the unmodified ARMv7 relocatable object inside symbol-redefined C translation shims, and Track B (Clean-Room Upstream mac80211), which replaces the proprietary driver completely inside OpenWrt's kmod-b43 build system. Mastering both teaches you more about how the Linux kernel actually links and executes code than reading ten textbooks.

Side-by-side blueprint comparing GNU objcopy symbol redefinition and sk_buff shadow struct translation against native OpenWrt 25.12 mac80211 packaging and CFE TFTP recovery
Figure 5.1 โ€” Track A (left): Binary ABI interposition across a 2.6.36-to-6.12 sk_buff layout shift. Track B (right): Native OpenWrt 25.12 mac80211 build and immutable CFE recovery.

1. Track A: How a 2.6.36 ARMv7 Blob Runs on Linux 6.12

At first glance, loading a 2010 wl_apsta.o binary compiled for Linux 2.6.36 into an unmodified Linux 6.12 kernel sounds impossible โ€” timer APIs changed (init_timer -> timer_setup), net_device_ops evolved, procfs changed (create_proc_entry -> proc_create), and struct sk_buff rearranged dozens of fields. Yet because ARMv7's Procedure Call Standard (AAPCS: arguments in r0..r3, return value in r0, 8-byte stack alignment) has remained identical since 2005, binary ABI interposition works in two surgical steps:

Step 1: Redirecting Undefined Imports with objcopy --redefine-sym

Recall from Part 2 that wl_apsta.o is an unlinked ET_REL object whose 26โ€“35 external kernel calls appear as SHN_UNDEF entries in .symtab. Running GNU objcopy with a symbol map file rewrites those import names in-place without touching a single byte of ARM machine code:

# shim_syms.map
dev_alloc_skb       wl_shim_dev_alloc_skb
skb_pull            wl_shim_skb_pull
netif_rx            wl_shim_netif_rx
init_timer          wl_shim_init_timer
pci_read_config_dword wl_shim_pci_read_cfg32

$ arm-openwrt-linux-muslgnueabi-objcopy --redefine-syms=shim_syms.map wl_apsta.o wl_apsta_shimmed.o

Now Kbuild links wl_apsta_shimmed.o alongside a freshly compiled Linux 6.12 C translation file (wl_abi_shim.c) that implements every wl_shim_* function using modern 6.12 kernel APIs!

Step 2: Solving the Inlined struct sk_buff Offset Trap

Why isn't function redirection enough by itself? Because in Linux's <linux/skbuff.h>, performance-critical helpers like __skb_pull() or direct reads of skb->data, skb->len, and skb->priority were static inline macros/functions expanded directly inside wl_apsta.o's .text at compile time in 2010!

If wl_shim_dev_alloc_skb() returns a genuine Linux 6.12 struct sk_buff * to the 2.6.36 binary, the binary executes hardcoded ARM stores like str r3, [r0, #0x68] assuming offset 0x68 is skb->len โ€” when on Linux 6.12 offset 0x68 sits right in the middle of sk_buff's red-black tree pointers or checksum metadata! Instant kernel panic.

The solution is Shadow Struct Wrapping:

struct skb_shadow_wrap {
	struct sk_buff_v2636 legacy; /* MUST be offset 0 so &wrap->legacy == (void *)wrap */
	struct sk_buff      *real612;
};

When the blob allocates or receives a packet, the shim allocates a compact skb_shadow_wrap, copies data, head, len, dev, and priority into wrap->legacy at exact 2.6.36 byte offsets, and hands &wrap->legacy to the blob. The blob mutates legacy.data and legacy.len inline harmlessly; then, the moment the blob hands &wrap->legacy back across an exported boundary (such as wl_shim_netif_rx() or DMA TX submission), the shim casts the pointer back to struct skb_shadow_wrap *, synchronizes the delta onto wrap->real612, frees the shadow wrapper, and hands a 100% valid struct sk_buff * to Linux 6.12!

2. Track A vs. Track B: Engineering Trade-Off Matrix

Criterion Track A: Binary 2.6.36 ABI Shim Track B: Clean-Room Mainline mac80211
Kernel Licensing & Taint Proprietary taint (TAINT_PROPRIETARY_MODULE); cannot use EXPORT_SYMBOL_GPL Pure GPL-2.0; full access to mac80211, cfg80211, bcma, and debugfs
Modern Wi-Fi Security Stuck on legacy Broadcom nas / WEXT ioctls; fragile WPA3 / 802.11w support Native OpenWrt hostapd / wpad: WPA3-SAE, 802.11w MFP, 802.11r/k/v fast roaming
Bufferbloat & Queueing Opaque internal vendor FIFO queues prone to latency spikes under load Mainline mac80211 FQ-CoDel + Airtime Queue Limits (AQL)
Long-Term Maintainability Locked forever to 32-bit ARMv7 little-endian; breaks if unshimmed struct drifts Portable C across ARM, ARM64, MIPS, x86_64, and future Linux 6.x / 7.x LTS trees

3. Track B: Native OpenWrt 25.12 Build & Packaging Workflow

In OpenWrt 25.12 (bcm53xx/generic target for netgear_r7000), wireless drivers are built not from the base kernel tree directly, but from OpenWrt's package/kernel/mac80211 backports package so routers get modern wireless stacks even on LTS kernels. Packaging your clean-room AC-PHY patches cleanly follows OpenWrt's quilt workflow:

# 1. Clone OpenWrt 25.12 and initialize feeds on a Linux build host
$ git clone --branch v25.12.6 https://git.openwrt.org/openwrt/openwrt.git
$ cd openwrt && ./scripts/feeds update -a && ./scripts/feeds install -a

# 2. Select Broadcom BCM47xx/53xx (ARM) -> NETGEAR R7000 + kmod-b43
$ make menuconfig
#   Target System: Broadcom BCM47xx/53xx (ARM)
#   Target Profile: Netgear R7000
#   Kernel modules -> Wireless Drivers -> kmod-b43 (enable B43_BCMA & B43_PHY_AC)

# 3. Compile ONLY the mac80211/b43 kernel package during rapid driver iteration
$ make package/kernel/mac80211/compile V=s

Instead of reflashing the entire flash chip on every edit, copy the resulting kmod-b43 module + your /lib/firmware/b43/ files over SSH to /tmp/ on the test router (isolated on a lab bench subnet such as 192.0.2.1/24), unload the previous test module (rmmod b43), and reload with live dmesg -w telemetry over a 3.3V UART serial adapter!

4. Hardware Safety Net: Unbrickable Broadcom CFE TFTP Recovery

Every kernel researcher eventually triggers a boot-time oops or hangs the PCIe bus. Before flashing custom images onto a physical Nighthawk R7000, memorize the two golden hardware safety rules:

  1. Never touch mtd0 (boot / CFE) or mtdboard_data: On the R7000's dual-flash layout (SPI NOR holding CFE + NVRAM + factory board data; 128 MiB NAND holding the linux TRX/UBI image), CFE and your factory RF SROM calibration remain completely untouched by normal sysupgrade or .chk flashes.
  2. Keep a verified stock/OpenWrt .chk image staged for CFE TFTP recovery: Configure a wired workstation Ethernet port with a static IP in the router's boot subnet (default 192.168.1.10/24 targeting 192.168.1.1 during CFE's 3-second power-on TFTP window), switch your TFTP client to binary mode, and put the verified .chk image whenever a test build fails to boot.

5. Your Turn โ€” Hands-On Lab 05 Checkpoints (Zero Spoilers)

Open labs/05-abi-interposition-and-openwrt-build.md and complete the final hands-on C challenge in labs/starter/lab05_abi_shadow_skeleton.c:

  1. Implement wl_shim_alloc_skb(size): Allocate a modern struct skb_v612 * from the harness, wrap it inside a struct skb_shadow_wrap whose first member is struct skb_v26 legacy, mirror initial data, len, and priority, and return &wrap->legacy to the precompiled binary object.
  2. Implement wl_shim_tx_submit(legacy_skb): Recover your skb_shadow_wrap * after the objcopy-redefined binary object has mutated legacy_skb->data, len, and priority inline, copy the updated fields onto wrap->real without corrupting ktime_ns or hash, free the wrapper, and submit to kernel612_tx_submit().
  3. Run the Full 5-Lab Suite: Execute python3 labs/verify_labs.py --all โ€” Lab 05 compiles an opaque legacy object, runs real GNU objcopy --redefine-sym on it, links your shim, and verifies end-to-end packet delivery!

Where to Go Next

Congratulations on working through all five parts of the router firmware & Linux Wi-Fi driver reverse engineering curriculum! Once all five local labs report [PASS], apply your tools directly to your router workbench โ€” or reach out via our IoT Router & Embedded Gateway Reverse Engineering Consultancy if your engineering team needs dedicated white-hat firmware auditing, custom OpenWrt BSP bring-up, or mainline Linux driver development.

Robert Baindourov

Written & Architected by Robert Baindourov

Senior IoT Firmware & Edge-Cloud Solutions Architect with 17+ years total experience (15+ years professional architecture). Specializing in bare-metal C/C++, FreeRTOS, Zephyr OS, Embedded Rust, hardware secure elements (ATECC608, TPM 2.0), and high-throughput cloud telemetry pipelines (AWS IoT Core, EMQX, Node.js). Based in Los Angeles, CA.