$ uname -a A_BLOG_ABOUT_UNIX_TOOLS_AND_THE_BEAUTY_OF_SIMPLE_SYSTEMS
SYS.YEAR  2026
← Back to articles
2026-09-07ARTICLE

Blog Linux Redbaron

Running RedBaron 3.10 on a Modern Linux Kernel

A journey through 1997 browser archaeology, libc5 allocator quirks, and the magic of setarch


The Starting Point

RedBaron 3.10 is Red Hat's branded build of the Mosaic-derived browser, shipped with Red Hat Linux 4.2 in late 1997. It's a 32-bit i386 ELF binary, dynamically linked against libc.so.5 (the pre-glibc Linux C library), libX11.so.6, libXt.so.6, libm.so.5, and libdl.so.1.

The goal: run this binary natively on a 2026 kernel (7.0.11) — no CPU emulation, no Docker, no VM. Just the host kernel, a Bubblewrap namespace, and the extracted Red Hat 4.2 filesystem.

$ file rh42/usr/lib/redbaron/redbaron_3.10
rh42/usr/lib/redbaron/redbaron_3.10: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
dynamically linked, interpreter /lib/ld-linux.so.1, for GNU/Linux 2.0.0, not stripped

Phase 1: The Extraction and First Launch Attempt

The rh42/ directory is a full Red Hat 4.2 root filesystem. The original launch script (rh42/usr/bin/redbaron) is a shell wrapper setting REDBARON=/usr/lib/redbaron and exec'ing the binary. But the extracted shell itself crashes — an allocation failure in libc5's malloc.

So step one: a host-shell launcher using Bubblewrap to construct a clean namespace:

#!/bin/bash
# run-redbaron - minimal host launcher
bwrap \
  --unshare-pid --unshare-ipc --unshare-uts --unshare-cgroup --die-with-parent \
  --tmpfs / \
  --ro-bind rh42/bin /bin \
  --ro-bind rh42/lib /lib \
  --ro-bind rh42/usr /usr \
  --ro-bind rh42/etc /etc \
  --bind .redbaron-home /root \
  --tmpfs /tmp \
  --proc /proc --dev /dev \
  --bind /tmp/.X11-unix/X1 /tmp/.X11-unix/X1 \
  --ro-bind ~/.Xauthority /root/.Xauthority \
  --clearenv \
  --setenv HOME /root --setenv PATH /usr/bin:/bin:/usr/X11R6/bin \
  --setenv LANG C --setenv DISPLAY :1 \
  --setenv XAUTHORITY /root/.Xauthority \
  --setenv REDBARON /usr/lib/redbaron \
  --setenv LD_LIBRARY_PATH /lib:/usr/lib:/usr/X11R6/lib \
  /usr/lib/redbaron/redbaron_3.10

First run: crash in mmap. The loader (ld-linux.so.1) starts, maps libc5, then the browser's own malloc calls mmap — and gets ENOSYS.


Phase 2: The mmap vs mmap2 Trap

Modern x86_64 kernels provide mmap2 (syscall 192) which takes page-offset units. The old i386 mmap (syscall 90) takes byte offsets and expects a 6-word struct on the stack:

struct mmap_args {
    unsigned long addr;
    unsigned long len;
    unsigned long prot;
    unsigned long flags;
    unsigned long fd;
    unsigned long offset;  // byte offset, not pages
};

libc5's malloc calls the old mmap syscall directly via int 0x80 (or sysenter on later kernels). But the syscall ABI changed: modern kernels do still support syscall 90, but only if the personality has the legacy layout bits set.

Without the right personality, the kernel returns ENOSYS for the old mmap — hence the crash.


Phase 3: setarch i386 -L -R — The Personality Fix

setarch changes the process personality flags. Two flags matter:

  • ADDR_LIMIT_32BIT (-L) — Forces the legacy 32-bit virtual address layout: low brk start (near 0x08048000), mmap returns low addresses. libc5's allocator assumes this layout.
  • ADDR_NO_RANDOMIZE (-R) — Disables ASLR. Predictable addresses help the allocator's assumptions.
exec setarch i386 -L -R -- bwrap ... /usr/lib/redbaron/redbaron_3.10

Result: the browser launches! The version banner prints:

RedHat Redbaron: Linux i486 (Linux 2.0) Version 3.10

A visible X11 window appears. But it's fragile — any memory pressure (loading images, multiple pages) triggers allocator corruption. The legacy layout helps, but libc5's malloc/free still misbehaves on modern kernels because brk/mmap interactions have subtly changed over 25 years.


Phase 4: The Freestanding Allocator Shim

Since we can't patch libc5 (read-only extraction) and the personality fix isn't enough, we replace the allocator entirely via LD_PRELOAD.

Requirements

  • ELF32 i386 shared object (.so)
  • No host libc dependency — -nostdlib, no CRT startup
  • Raw i386 Linux syscalls for mmap/munmap
  • Implements malloc, free, calloc, realloc
  • 16-byte alignment, overflow checks, zeroed calloc, correct realloc semantics

The Shim (compat/malloc_shim.c)

#define _GNU_SOURCE
#include <stddef.h>
#include <stdint.h>

/* Raw syscall wrappers — no libc */
static inline long sys_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) {
    struct { void *addr; size_t len; int prot; int flags; int fd; off_t offset; } args = {
        addr, len, prot, flags, fd, offset
    };
    long ret;
    __asm__ volatile (
        "int $0x80"
        : "=a"(ret)
        : "a"(90), "b"(&args)  // syscall 90 = old mmap, struct pointer in EBX
        : "memory", "ecx", "edx", "esi", "edi"
    );
    return ret;
}

static inline long sys_munmap(void *addr, size_t len) {
    long ret;
    __asm__ volatile (
        "int $0x80"
        : "=a"(ret)
        : "a"(91), "b"(addr), "c"(len)  // syscall 91 = munmap
        : "memory"
    );
    return ret;
}

/* Metadata header before each allocation */
typedef struct { size_t size; } header_t;

void *malloc(size_t size) {
    if (size == 0) size = 1;
    size = (size + 15) & ~15;  // 16-byte align
    size_t total = size + sizeof(header_t);
    void *map = (void*)sys_mmap(NULL, total, PROT_READ|PROT_WRITE,
                                MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
    if ((long)map < 0) return NULL;
    ((header_t*)map)->size = size;
    return (char*)map + sizeof(header_t);
}

void free(void *ptr) {
    if (!ptr) return;
    header_t *h = (header_t*)((char*)ptr - sizeof(header_t));
    sys_munmap(h, h->size + sizeof(header_t));
}

void *calloc(size_t nmemb, size_t size) {
    if (nmemb && size > SIZE_MAX / nmemb) return NULL;
    size_t total = nmemb * size;
    void *p = malloc(total);
    if (p) __builtin_memset(p, 0, total);
    return p;
}

void *realloc(void *ptr, size_t size) {
    if (!ptr) return malloc(size);
    if (size == 0) { free(ptr); return NULL; }
    header_t *h = (header_t*)((char*)ptr - sizeof(header_t));
    if (size <= h->size) { h->size = size; return ptr; }
    void *n = malloc(size);
    if (!n) return NULL;
    __builtin_memcpy(n, ptr, h->size);
    free(ptr);
    return n;
}

Build command (host x86_64, 32-bit codegen only):

gcc -m32 -fno-stack-protector -O2 -nostdlib -fPIC -shared \
    -Wl,-z,notext -o libredbaron_compat.so malloc_shim.c

Verification — no host dependencies:

$ readelf -d compat/libredbaron_compat.so | grep NEEDED
# (empty — no DT_NEEDED entries)

Phase 5: The Launcher Evolves

The final run-redbaron injects the shim via LD_PRELOAD inside the guest:

# ... inside bwrap command array ...
cmd+=(--setenv "LD_PRELOAD" "/usr/lib/redbaron/libredbaron_compat.so")
cmd+=(/usr/lib/redbaron/redbaron_3.10)
exec setarch i386 -L -R -- "${cmd[@]}"

The shim lives at rh42/usr/lib/redbaron/libredbaron_compat.so (copied there during setup) — outside the read-only extraction but inside the guest namespace.


Phase 6: Validation — Does It Actually Browse?

With the shim + personality, the browser is stable. Full interaction test matrix:

Feature Status Notes
Local HTML (file:/fixtures/index.html) ✅ Headings, image, form, scrollable content
HTTP (http://127.0.0.1:8192/index.html) ✅ Server logs show GET /index.html HTTP/1.0
Link navigation ✅ Click → second page renders
Back button ✅ Cached, no new request
Reload ✅ Fresh HTTP/1.0 GET
Resize + reflow ✅ 620×460 → content resizes
Scrollbar click ✅ Reaches bottom marker text
Preferences persist ✅ Show_Tool_Bar=FALSE survives restart
Hotlist persist ✅ "Add to Hotlist" writes file
Clean exit (File→Quit) ✅ No orphan processes
Form <input> ⚠️ Painted in-page, no X window — focus trapped by URL field without WM

The form limitation is fundamental: RedBaron draws form widgets into its content canvas. Without a window manager to route keyboard focus to a specific widget, the X server delivers all keystrokes to the URL field (which is a native X window). Under a real WM (fvwm, twm, etc.) this would work.


The Font Path Gotcha

RedBaron uses XLFD font names (-adobe-courier-medium-r-normal--14-...) that only exist in the extraction's 75dpi/100dpi/misc directories. The host X server doesn't know about them. Session-only fix:

xset fp+ /home/guest/redbaron/rh42/usr/X11R6/lib/X11/fonts/75dpi
xset fp+ /home/guest/redbaron/rh42/usr/X11R6/lib/X11/fonts/misc
xset fp+ /home/guest/redbaron/rh42/usr/X11R6/lib/X11/fonts/100dpi
xset fp rehash

Extraction Integrity

The rh42/ filesystem is treated as immutable. Baseline verification:

find rh42 -type f -print0 2>/dev/null | sort -z | xargs -0 -n1 sha256sum
  • 10,425 regular files hashed
  • 289 symlinks recorded
  • 1 unreadable (rh42/usr/sbin/traceroute — setuid root)
  • Zero unexpected changes after all testing

What Made This Possible

Piece Why It Mattered
Bubblewrap Clean namespace, read-only extraction, private /tmp + home, X socket forwarding
setarch i386 -L -R Legacy VA layout + no ASLR — satisfies libc5 allocator assumptions
Allocator shim Bypasses libc5's broken malloc/free entirely; raw mmap/munmap works on any kernel
Host-shell launcher No extracted shell involved; safe argument handling, proper env isolation
X11 socket + auth bind Browser talks to host X server directly; no VNC/Xvfb needed

What Didn't Work (And Why)

  1. Form input — In-page widget, no native X window. Needs a WM for focus routing.
  2. Default homepage — Browser tries http://www.redhat.com on startup; no DNS in namespace → "Error" page. Workaround: type URL manually.
  3. Mouse wheel / PageDown — Only scrollbar clicks scroll.
  4. HTTPS — Browser only speaks HTTP/1.0.

Reproducing It

# 1. Fonts (once per X session)
xset fp+ /path/to/rh42/usr/X11R6/lib/X11/fonts/75dpi
xset fp+ /path/to/rh42/usr/X11R6/lib/X11/fonts/misc
xset fp+ /path/to/rh42/usr/X11R6/lib/X11/fonts/100dpi
xset fp rehash

# 2. Fixture server
python3 serve_fixtures.py --port 8192 &

# 3. Launch
env DISPLAY=:1 ./run-redbaron

# 4. In browser: click URL field → type http://127.0.0.1:8192/index.html → Return
# 5. Exit via File → Quit

Final Thoughts

Running a 1997 browser on a 2026 kernel is less about "compatibility layers" and more about understanding what the binary actually expects — the memory layout, the syscall ABI, the X11 protocol — and providing exactly that, no more, no less.

The allocator shim is ~200 lines of C + inline asm. The launcher is ~80 lines of bash. The heavy lifting is the kernel's backward compatibility (syscall 90 still exists!) and X11's network transparency.

RedBaron 3.10 renders HTML 3.2, follows links, submits forms, persists preferences, and exits cleanly. For a browser older than most developers, that's not bad.


Full source: run-redbaron, compat/malloc_shim.c, serve_fixtures.py, diagnostics/ — see the repository.