fix(payload): never rename() across devices — fixes USB→internal move kernel panic#142
Merged
Conversation
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 shellmvbuiltin) calledrename(from, to)directly with no cross-filesystem check. On this kernel a cross-device rename (USB exFAT → internal nullfs/UFS) does not returnEXDEV— it panics. The client already falls back to copy-then-delete onfs_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 comparest_dev; if they differ, refuse the rename and returnfs_move_cross_mount. The client then completes the move as copy+delete (byte read/write — cross-volume safe). Applied to both theFS_MOVEhandler and the shellmvcommand.stat()on USB is safe (FS_COPYalready stats the same paths).Hardware verification (real PS5 Phat, FW 5.10, USB drive attached)
/datamove (the panic scenario): now returnsfs_move_cross_mount, console stays alive — no panicrename()s successfully, no regression{ready:true}on the idle consolePayload compiles
-Werrorclean. Client typecheck/lint green.Release 3.3.21.