# Exit / mqueue panic — 2026-09-13 and 2026-09-20

**Submission status:** prepared locally; not submitted. Use the draft below;
the original analysis follows under **Investigation notes**.

## How to submit

1. Search [FreeBSD Bugzilla](https://bugs.freebsd.org/bugzilla/query.cgi) for
   `mq_proc_exit`, `mqueuefs`, and descriptor-table corruption. Check apparent
   duplicates; no complete duplicate search is claimed here.
2. Create/sign in to an account and open
   [New Base System bug](https://bugs.freebsd.org/bugzilla/enter_bug.cgi?product=Base%20System).
3. Fill the fields below, paste the draft, and attach the focused text evidence.
   Use `text/plain`; leave the attachment's patch checkbox unset.
4. Review public content, submit, record the assigned PR URL here, and answer
   follow-up questions in that PR.

Sources: FreeBSD's [bug reporting page](https://www.freebsd.org/support/bugreports/)
and [report-writing guide](https://docs.freebsd.org/en/articles/problem-reports/),
checked 2026-12-02. The live form blocked automated access: confirm its current
choices and mandatory markers after signing in. These are proposed values, not
a verified list of mandatory UI fields.

| Field | Proposed value |
|---|---|
| Product | Base System |
| Component/category | kern |
| Summary | mq_proc_exit panic at exit with capability-like values in fde_file (15.1-RELEASE-p3 amd64) |
| Version | 15.1-RELEASE if offered; put `-p3` and revision in Description |
| Hardware/platform | amd64 or equivalent x86-64 choice |
| OS | FreeBSD, if shown |
| Severity | Affects Only Me: one host confirmed, two reboots |
| Priority, assignee, CC, flags | Leave defaults; no specific maintainer established |
| Description / Environment / Steps | Draft below; split only if separate fields exist |
| Reporter | Monitored email; FreeBSD warns that it becomes public |

### Information to confirm or explicitly mark unknown

- Historical install/update method, local patches, kernel configuration/debug
  options, and third-party modules. The September 21 baseline says GENERIC;
  exact panic-time binary identity is unverified.
- RAM size and actual hardware/memory test results. Hardware corruption has not
  been excluded.
- Codex launch command, native/compatibility environment, workload duration,
  and descriptor limits if recoverable. Loaded Linux modules alone do not
  establish the process's execution environment.
- Recurrence or tests on newer kernels. Today's local GENERIC-DEBUG build does
  not establish a fix. Do not substitute today's configuration for September's.
- Dates are preserved syslog labels; source timezone and differences from the
  embedded kernel epoch values have not been reconciled.

Unknowns need not prevent filing, but should remain explicit.

## Copyable Bugzilla description

### Problem and environment

Two kernel panics on one four-core Intel N95 mini PC occurred while a process
named `codex` was exiting, on September 13 and September 20, 2026. Both caused
an immediate reboot. Expected: process exit completes without a kernel panic.
Actual: page fault on September 13 and general protection fault on September 20.

September 21 baseline `uname -a`:

```text
FreeBSD miniPC 15.1-RELEASE-p3 FreeBSD 15.1-RELEASE-p3 releng/15.1-n283611-88e7371d9dc2 GENERIC amd64
```

The September 21 module snapshot places `mqueuefs.ko` at
`0xffffffff83a38000`; the full list is attached. It also includes ZFS, vmm,
Linux compatibility modules, and if_rtw89. Package logs record `codex-0.151.0`
installed September 6, with no later package change before these two crashes.
Exact process executable hashes are unavailable.

No vmcore was saved: `/var/crash` contained only `minfree` when checked.
Disassembly, module addresses, layouts, and hashes are from installed artifacts
collected September 21, not saved panic-time binaries. Symbolization is
conditional on those artifacts matching the crashed installations.

### Crash evidence

| Syslog date/time (2026) | PID | Uptime | Trap | r14 (inferred fde_file) | r15 (index) | rcx (capacity) |
|---|---:|---|---|---|---:|---:|
| Sep 13 16:17:34 | 6229 | 1d0h0m9s | Page fault | 0x000000780000ffff | 15360 | 29952 |
| Sep 20 22:02:22 | 12537 | 7d5h44m21s | General protection | 0x04000000007fffff | 8875 | 42560 |

Both recorded RIP `0xffffffff83a3ca06`. Complete original trap records,
registers, and distinct backtraces are attached. Both traces include
`exit1+0x33c`, `sys__exit+0xd`, and `amd64_syscall+0x126`.

Installed-module symbolization:

```text
0xffffffff83a3ca06 - 0xffffffff83a38000 = 0x4a06
mq_proc_exit begins at 0x4980: fault is +0x86
49fd: movq (%rax,%rbx), %r14
4a01: testq %r14, %r14
4a04: je 0x49e0
4a06: cmpq $mqueueops, 0x10(%r14)
```

This reads `fde_file->f_ops`. Both indices are in bounds; `rbx` is respectively
`0xb4008` and `0x68018`, matching `8 + 48 * index`. For September 13,
`r14 + 0x10 = 0x780001000f`, exactly the logged fault address.
September 20's value matches `CAP_ALL1`; September 13's matches the combined
full-rights `fc_nioctls`/`fc_fcntls` word in the inspected layout. This suggests
descriptor/capability corruption, but does not identify its writer or prove a
use-after-free. `mq_proc_exit` may merely expose earlier corruption.

### Workload and reproduction

No deterministic reproducer exists. The observed workload was a long-running
Codex session on a large package staging tree. A separate September 21 snapshot
of another Codex process showed 29,904 numeric descriptors, mostly read-only
vnodes. This is supporting workload evidence, not either crashing process's
open-file count. The crash registers indicate table capacity only.

A candidate investigation workload is to grow a descriptor table into the tens
of thousands and exercise fork/exec/exit with mqueuefs loaded in a disposable
VM. This has not reproduced the panics. Local stress programs are unvalidated
candidates, not confirmed reproduction steps.

### Limits and request

No confirmed workaround or corrective patch. A lower descriptor limit is an
untested containment experiment. The two crashes share a reader fault; a common
corrupting writer is unproven. A separate September 12 exec-path panic is excluded
because its relationship is unknown. Persistence on newer releases is unknown.

Please advise which descriptor/capability paths to instrument and which focused
debugger output would help on recurrence. No whole memory dump is available for
these events; preserved text evidence is attached.

## Evidence attachments without a whole core dump

Upload these small files individually; relative links will not work in Bugzilla.
Review each for private information first.

| File | Purpose |
|---|---|
| [exit-mqueue-panic-evidence.txt](exit-mqueue-panic-evidence.txt) | Complete Sep 13/20 trap records, registers, and backtraces, extracted verbatim; excludes Sep 12 |
| [uname.txt](diagnosis/uname.txt), [kldstat.txt](diagnosis/kldstat.txt) | Sep 21 identity and module addresses, explicitly post-crash |
| [mq_proc_exit.asm](diagnosis/mq_proc_exit.asm), [exit1.asm](diagnosis/exit1.asm) | Fault instruction and event-handler call context |
| [kernel-layout.txt](diagnosis/kernel-layout.txt), [module-layout.txt](diagnosis/module-layout.txt) | Inspected offsets and stride |
| [SHA256.txt](diagnosis/SHA256.txt) | Baseline artifact hashes, not saved panic-time binary hashes |

Keep the investigation below for follow-up. Initially omit full rotated logs,
full `procstat -f` path listings, unrelated patches, and untested stressors.
Review hostnames, usernames, paths, and network details; label redactions and
retain originals. Preserve diagnostic registers and instruction addresses.

### If a future crash yields a vmcore

Retain it privately with the exact kernel, modules, debug symbols, build
configuration, and hashes. Ask the investigating developer for targeted
extraction commands with matching symbols. Useful text would include:

- Full panic/trap output and all-thread backtraces.
- The exiting process's `filedesc`, table pointer/capacity, and faulting slot.
- A small range of neighboring `filedescent` entries and their capability words.
- Relevant table-lifetime and allocator metadata, if recoverable in that build.

Review `core.txt`/crashinfo output too: text diagnostics can contain private
information. Compression or a kernel minidump does not make a dump safe to
publish. If a developer needs the dump, arrange private access separately.
Text extracts can help, but may be insufficient to identify the corrupting writer.

---

## Investigation notes

**Class:** exit-path fault in `mq_proc_exit`
**Events:** 2026-09-13 16:17:34 and 2026-09-20 22:02:22
**Host:** miniPC
**Kernel:** FreeBSD 15.1-RELEASE-p3 (GENERIC), 4-core Intel N95
**Processes:** `codex` PID 6229 (Sep 13), `codex` PID 12537 (Sep 20)
**Outcome:** kernel panic, immediate reboot both times
**Uptimes:** 1d 0h 0m 9s (Sep 13), 7d 5h 44m 21s (Sep 20)

These two panics share the same faulting instruction, the same backtrace shape,
and the same corrupted-field class. See
[`execve-gpf-panic.md`](execve-gpf-panic.md) for the separate Sep 12 event and
[`README.md`](README.md) for the overall assessment.

---

## Raw records

### Sep 13 — page fault

```
Fatal trap 12: page fault while in kernel mode
cpuid = 0; apic id = 00
fault virtual address = 0x780001000f
fault code            = supervisor read data, page not present
instruction pointer   = 0x20:0xffffffff83a3ca06
current process       = 6229 (codex)
rdi: fffffe01062b1510 rsi: 0000000000000000 rdx: fffffe01062b14f0
rcx: 0000000000007500 r8: ffffffff818bb9c0  r9: 0000000000000000
rax: fffffe017deeb000 rbx: 00000000000b4008 rbp: fffffe00d356cd90
r10: 00002012fe461810 r11: fffff800123cdcd0 r12: fffff800010f5c80
r13: 0000000000000000 r14: 000000780000ffff r15: 0000000000003c00
panic: page fault
```

Backtrace:

```
#0 kdb_backtrace+0x5d
#1 vpanic+0x136
#2 panic+0x43
#3 trap_pfault+0x37d
#4 calltrap+0x8
#5 exit1+0x33c
#6 sys__exit+0xd
#7 amd64_syscall+0x126
#8 fast_syscall_common+0xf8
```

### Sep 20 — general protection fault

```
Fatal trap 9: general protection fault while in kernel mode
cpuid = 0; apic id = 00
instruction pointer = 0x20:0xffffffff83a3ca06
current process     = 12537 (codex)
rdi: fffffe00f7494cb0 rsi: 0000000000000000 rdx: fffffe00f7494c90
rcx: 000000000000a640 r8: ffffffff818bb9c0  r9: 0000000000000000
rax: fffffe014954c000 rbx: 0000000000068018 rbp: fffffe00d37e7d90
r10: 00002bada3461010 r11: fffff80008740550 r12: fffff800010f5c80
r13: 0000000000000000 r14: 04000000007fffff r15: 00000000000022ab
panic: general protection fault
```

Backtrace: same as Sep 13, including `exit1+0x33c` and `sys__exit`.

Full text:
[`panic-excerpts.txt`](panic-evidence-20260921.adypzQ/panic-excerpts.txt).

---

## Symbolization

With the installed `mqueuefs.ko` loaded at `0xffffffff83a38000`:

```
0xffffffff83a3ca06 - 0xffffffff83a38000 = 0x4a06
mq_proc_exit starts at module offset 0x4980
0x4a06 - 0x4980 = 0x86
```

Faulting instruction: **`mq_proc_exit+0x86`**.

The module disassembly at that point:

```
49f6: 89 c9                    movl   %ecx, %ecx
49f8: 49 39 cf                 cmpq   %rcx, %r15
49fb: 73 e3                    jae    0x49e0
49fd: 4c 8b 34 18              movq   (%rax,%rbx), %r14
4a01: 4d 85 f6                 testq  %r14, %r14
4a04: 74 da                    je     0x49e0
4a06: 49 81 7e 10 00 00 00 00  cmpq   $mqueueops, 0x10(%r14)
```

The compare at `4a06` reads `fde_file->f_ops` at `+0x10`. `r14` is the
`fde_file` value loaded from the descriptor table at `rax + rbx`.

Register roles in this compiled loop:

- `rax` = descriptor table base (`fdp->fd_files`)
- `rcx` = `fdt_nfiles` / table capacity
- `r15` = descriptor index
- `rbx` = `8 + 0x30 * index` (8-byte table header, 48-byte entries)
- `r14` = `fde_file` at that slot

`mq_proc_exit` scans **all** descriptors up to `fd_nfiles`, not just
message-queue descriptors. It holds the filedesc shared lock and uses
`fget_noref`. If a slot is valid, it compares `f_ops` against `&mqueueops` and,
on a match, removes the process notifier.

`exit1+0x33c` is the return address immediately after an indirect
`process_exit` event-handler call. The handler is `mq_proc_exit`. The earlier
attribution to `vmspace_exitfree()` / `vm_map_delete` was wrong.

---

## Register evidence

| Event | Index `r15` | Capacity `rcx` | Entry offset `rbx` | `fde_file` `r14` |
|---|---:|---:|---:|---:|
| Sep 13 | 15,360 (`0x3c00`) | 29,952 (`0x7500`) | `0xb4008` | `0x780000ffff` |
| Sep 20 | 8,875 (`0x22ab`) | 42,560 (`0xa640`) | `0x68018` | `0x04000000007fffff` |

- Both indices are in bounds.
- Both entry offsets match `8 + 48 * index`.
- Sep 13: `0x780000ffff + 0x10 = 0x780001000f`, exactly the logged page-fault
  address. The value is a non-kernel address, so the supervisor read faults.
- Sep 20: `0x04000000007fffff` is exactly `CAP_ALL1`.
- Both are non-kernel values in a field that must hold a `struct file *`, and
  both are exact words from a full-rights capability structure (next section).

`rcx` is the table **capacity**, not the number of open files. The crashing
processes had grown their tables to 29,952 and 42,560 entries. That is a
high-water mark, but it is direct evidence of large descriptor tables at exit.

---

## Both corrupt values are capability-metadata words

Neither value is a plausible `struct file *`. Both are exact words from a
full-rights `struct filecaps` (the `fde_caps` embedded in a `filedescent`):

| Word | `filecaps` offset | `filedescent` offset | Full-rights value |
|---|---:|---:|---|
| `fc_rights[0]` | `+0` | `+8` | `0x02000FFFFFFFFFFF` (`CAP_ALL0`) |
| `fc_rights[1]` | `+8` | `+16` | `0x04000000007FFFFF` (`CAP_ALL1`) |
| `fc_ioctls` | `+16` | `+24` | `NULL` for full rights |
| `fc_nioctls` / `fc_fcntls` | `+24` | `+32` | `0x000000780000FFFF` |
| `fde_flags` | — | `+40` | small `UF_*` bits |
| `fde_seqc` | — | `+44` | small counter |

- Sep 20's `0x04000000007FFFFF` is exactly `CAP_ALL1`, the `fc_rights[1]` word.
- Sep 13's `0x000000780000FFFF` is exactly `fc_nioctls = -1` (all ioctls
  allowed) together with `fc_fcntls = CAP_FCNTL_ALL` (`0x78`, the
  `F_GETFL`/`F_SETFL`/`F_GETOWN`/`F_SETOWN` bits), the
  `fc_nioctls`/`fc_fcntls` word.

So the two panics did not read random garbage or an ordinary dangling kernel
pointer. They read **capability metadata** in the field where a file pointer
belongs. That ties the corruption to `filecaps`/`filedescent` data, not to a
plain VFS use-after-free.

The two values are different words of the same structure, at different
indices. A single writer with one fixed wrong destination offset would tend to
leave the same word in `fde_file` on both events. The difference is evidence
for either two different mis-offsets/paths, or for reading reused memory whose
alignment differed between the events. It does not by itself prove either.

### Alignment arithmetic

A numeric pattern is worth recording, with a caveat.

If a region were an array of 32-byte `struct filecaps`, the reader's
`8 + 48*i` sample offsets (modulo 32) alternate between `+8` and `+24`. With
the region base 16 bytes off the table base, even indices sample `+24` (the
`0x780000ffff` word) and odd indices sample `+8` (`CAP_ALL1`). That matches
Sep 13 (index 15,360, even → `0x780000ffff`) and Sep 20 (index 8,875, odd →
`CAP_ALL1`) exactly.

Caveat: the matching source does **not** allocate a standalone array of
`struct filecaps`. `struct filecaps` is embedded in each 48-byte
`filedescent`. The one `M_FILECAPS` array is `fdev` in
`sys/kern/uipc_usrreq.c` (`unp_internalize`), and it is an array of 48-byte
`filedescent`, not 32-byte `filecaps`. In a 48-byte array those two values sit
at entry `+16` (`CAP_ALL1`) and entry `+32` (`0x780000ffff`), so the reader's
base would have to be 8 or 24 bytes into the array. The 32-byte parity match is
therefore a coincidence of the observed numbers until a vmcore shows the actual
surrounding memory. It is suggestive of reused descriptor/capability memory,
not proof.

`CAP_ALL1` is at `filedescent +16`, not `+8`. A simple `+8` read skew would
have produced `cr_rights[0]` (`CAP_ALL0`), which was not observed. A global
`+16` skew is also unlikely: it would fault on descriptor 0, while the recorded
faults are at indices 15,360 and 8,875. The evidence still points to a
**slot-specific** fault rather than a uniform struct-layout error.

---

## Why the reader is not the root cause

`mq_proc_exit` is doing a normal scan under the filedesc shared lock. The
faulting value was already bad in the table. The corrupting writer is the root
cause and is not identified.

Checked or ruled out in the preserved evidence and matching source:

- **Exit/exec race:** `exit1()` stops other threads with
  `thread_single(p, SINGLE_EXIT)` before teardown. The proposed race needs
  separate evidence.
- **Handler ordering:** `process_exit` handlers run before `fdescfree(td)` in
  `exit1()`. This is not a post-free read caused by ordering.
- **Struct-size mismatch:** kernel and module both describe 48-byte
  `filedescent` entries and an 8-byte table header. Installed `fdgrowtable()`
  copies 48 bytes per entry; `mq_proc_exit` strides by `0x30`.
- **Uninitialized growth slots:** installed `fdgrowtable()` allocates with
  `M_WAITOK | M_ZERO` and copies the old entries. New slots are zeroed.
- **Old-table lifetime:** tables are published with a release store; old tables
  are retained on a per-process free list when the table is shared, then freed
  at process release. No demonstrated use-after-free was found here.
- **PR 2029:** the installed code already has the `NDENTRIES` capacity rounding
  that the revised patch says prevents the alleged map-lifetime bug.
- **PR 293382:** the installed `kern_event.c` already contains the locked fd
  recheck added by that commit.
- **Simple wrong-offset writer:** a static review of `fde_copy`,
  `filecaps_copy`, `filecaps_move`, `filecaps_fill`, `_finstall`, `fdfree`,
  `fdcopy`, `fdgrowtable`, `kern_dup`, `close_range`, and
  `cap_rights_limit` found the correct field offsets in the matching source.

The matching source hash for `kern_descrip.c` is the one preserved in
`diagnosis/SHA256.txt`. That makes a plain source-level offset bug unlikely,
but it does not prove the panic-time binary was identical.

---

## Working hypotheses

Ranked, not proven:

1. **Reused descriptor/capability memory.** The region the scan read as a
   descriptor table had been freed and reused for `filedescent`/`filecaps`
   data, so one or more slots held capability words instead of file pointers.
   This now leads because both corrupt values are exact capability words and
   they differ in the way different offsets would. No specific lifetime bug was
   demonstrated in the matching source, so it is a hypothesis.
2. **Capability copy or move at a wrong offset.** A `filecaps`/`filedescent`
   copy landed on `fde_file`, leaving `fc_rights[1]` or the
   `fc_nioctls`/`fc_fcntls` word in the pointer slot. The differing words
   suggest more than one offset or path.
3. **External overwrite.** A separate kernel memory-corruption source, or
   hardware memory fault, wrote into the fd table. No evidence either way.
4. **Two different writers** producing the same exit signature on Sep 13 and
   Sep 20. Possible; the logs cannot distinguish.

The descriptor-retention workload is an amplifier: Codex held tens of
thousands of descriptors, forks copied the table, and every process exit
scanned it. That makes a latent defect much more likely to be hit. It is not
proven to be the writer.

---

## Confidence

| Claim | Confidence |
|---|---|
| Sep 13/20 fault at `mq_proc_exit+0x86` | high |
| The faulting field is `fde_file` | high |
| Sep 13 fault address is `r14 + 0x10` | high |
| Sep 20 value is `CAP_ALL1` | high |
| Sep 13 value is the `fc_nioctls`/`fc_fcntls` word | high |
| Both corrupt values are capability metadata, not random garbage | high |
| Slot-specific fault, not global skew | moderate |
| Reused descriptor/capability memory is the leading mechanism | moderate / unproven |
| Sep 13/20 share one writer bug | moderate |
| Root cause identified | no |
| Same root cause as Sep 12 | low / unproven |

---

## What would resolve it

- A vmcore showing the fd table, the surrounding entries, capability state, and
  allocator metadata at panic time. In particular, check whether adjacent slots
  also hold capability words (a reused run) or only the faulting slot does (a
  one-off write). That distinguishes the two leading hypotheses.
- Panic-time kernel/module binaries and hashes matching the disassembly.
- An instrumented kernel that asserts on every `fde_file` write and table
  transition, and records the first invalid value.
- A reproducible trigger in a disposable VM, with the exact Codex workload and
  descriptor-retention pattern.

None of those exist in this directory.
