Skip to content

fix(payload): never rename() across devices — fixes USB→internal move kernel panic#142

Merged
phantomptr merged 1 commit into
mainfrom
fix/move-kernel-panic
Jun 17, 2026
Merged

fix(payload): never rename() across devices — fixes USB→internal move kernel panic#142
phantomptr merged 1 commit into
mainfrom
fix/move-kernel-panic

Conversation

@phantomptr

Copy link
Copy Markdown
Owner

Critical bug — console kernel panic

Moving (cut & paste) a file from a USB drive to the internal SSD reliably kernel-panicked the PS5 (hard crash + reboot), reproduced every time. Copy worked fine — that difference was the smoking gun.

Root cause

The payload's handle_fs_move (and the shell mv builtin) called rename(from, to) directly with no cross-filesystem check. On this kernel a cross-device rename (USB exFAT → internal nullfs/UFS) does not return EXDEV — it panics. The client already falls back to copy-then-delete on fs_move_cross_mount, but the payload panicked before it could ever return that error.

Fix

Before rename(), stat() the source and the destination's parent dir and compare st_dev; if they differ, refuse the rename and return fs_move_cross_mount. The client then completes the move as copy+delete (byte read/write — cross-volume safe). Applied to both the FS_MOVE handler and the shell mv command. stat() on USB is safe (FS_COPY already stats the same paths).

Hardware verification (real PS5 Phat, FW 5.10, USB drive attached)

  • ✅ USB→/data move (the panic scenario): now returns fs_move_cross_mount, console stays alive — no panic
  • ✅ Intra-volume move (USB→USB): still rename()s successfully, no regression
  • ✅ Readiness probe (3.3.20): {ready:true} on the idle console
  • Throwaway test files only (a copy of an 11-byte file); all cleaned up, user data untouched

Payload compiles -Werror clean. Client typecheck/lint green.

Release 3.3.21.

… kernel panic

Moving (cut & paste) a file from a USB drive to the internal SSD reliably
KERNEL-PANICKED the console — a hard crash + reboot, reported and
reproduced every time. Copy worked fine.

Root cause: handle_fs_move (and the shell 'mv' builtin) called rename()
directly. On this kernel a cross-DEVICE rename (USB exFAT → internal
nullfs/UFS) does not return EXDEV — it PANICS. The client already falls
back to copy-then-delete on 'fs_move_cross_mount', but the payload panicked
before it could ever return that error.

Fix: before rename(), stat the source and the destination's parent dir and
compare st_dev; if they differ, refuse the rename and return
fs_move_cross_mount (the client then completes the move as copy+delete,
which reads/writes bytes and is cross-volume safe). Applied to both the
FS_MOVE handler and the shell 'mv' command. stat() on USB is safe (FS_COPY
already does it).

HARDWARE-VERIFIED on a real PS5 (Phat, FW 5.10) with a USB drive attached:
the USB→/data move that used to panic now returns fs_move_cross_mount and
the console stays up; an intra-volume move still renames fine; readiness
probe (3.3.20) returns ready. Throwaway test files only; user data untouched.

Release 3.3.21.
@phantomptr phantomptr merged commit e20a5f5 into main Jun 17, 2026
23 checks passed
@phantomptr phantomptr deleted the fix/move-kernel-panic branch June 17, 2026 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant