Commit Graph
6423 Commits
Author SHA1 Message Date
Henrik Rydgård 77ebdf2e80 Clamp segment count in PSPModule::GetLongInfo
nm.nsegment is attacker-controlled but segmentaddr/segmentsize are fixed
4-entry arrays; the debug info loop read past them. Clamp to 4 like the
other consumers.
2026-08-01 13:16:21 +02:00
Henrik Rydgård 942a76cfaa Fix heap overflow via unsigned underflow in legacy Atrac::EnqueueForSas
The space-left clamp was computed in unsigned 32-bit arithmetic, so a
crafted fileoffset/FirstOffsetExtra could underflow to a huge value and
leave addbytes unclamped, driving a Memory::Memcpy past dataBuf_.

Compute the clamp in signed 64-bit, clamp negatives to 0, and skip the
copy when there's nothing to write.
2026-08-01 13:16:21 +02:00
Henrik Rydgård 4cd611b71f Fix out-of-bounds reads in ATRAC track parsing
AnalyzeAtracTrack used max(fileSize, size) as the chunk-parse bound with
fileSize taken from the file's RIFF header, so a crafted inflated RIFF
size could push reads past the end of the buffer. Keep the real-library
behavior of tolerating a too-low size, but clamp the parse bound to the
actual mapped guest memory at the buffer.

Also guard ParseWaveAT3's RIFF scan against a blockSize < 4 underflow
that could make the offset negative and bypass the loop bounds check, and
clamp readSize to the mapped region in Atrac2::SetData before parsing.
2026-08-01 11:57:27 +02:00
Henrik Rydgård 32abdd63bf Fix EP-map parsing OOB read in PSMF video stream params
EP_MAP_STRIDE * EPMapEntriesNum was computed in 32-bit and could wrap,
passing the range check while the loop read the unwrapped count; and the
check was skipped entirely when headerOffset == 0 (the player tempbuf
path).

- Use 64-bit math for the EP map size.
- Keep the guest-RAM range check when headerOffset != 0.
- Cap the entry count for the headerOffset == 0 path so the reads stay
  within the player's 64KB tempbuf.
2026-08-01 11:57:27 +02:00
Henrik Rydgård 788150c28e Fix out-of-bounds reads in PGF font parsing
PGF::ReadPtr walked four length-prefixed tables and computed table sizes
before any bounds check, and used signed 32-bit size math that could
overflow, allowing a crafted font to read past the input buffer.

- Validate the total size of all tables up front using 64-bit math.
- Check the rev3 extra header fits before reading it.
- Cap charPointerLength/charMapLength/shadowMapLength to avoid absurd
  allocations.
- Bounds-check glyph data offsets before reading each glyph.

Also throw in a warning fix
2026-08-01 11:57:27 +02:00
Henrik Rydgård 983068b07a Fix OOB read on unterminated module names in PRX import debug reporter
The import debug reporter used IsValidAddress (start-address only) before
formatting module names with %s, so a crafted unterminated name could be
read past guest RAM. Use IsValidNullTerminatedString instead.
2026-08-01 11:57:27 +02:00
Henrik Rydgård 2100e4ec47 Reject ATRAC files with oversized packets at parse time; honor Verify errors
- InitContextFromTrackInfo now rejects files where sampleSize (from
  blockAlign) exceeds the buffer size, instead of only clamping later in
  DecodeForSas. Keep the DecodeForSas check as defense-in-depth since a
  large buffer could still allow a crafted packet to overflow the fixed
  assembly buffer.
- CChunkFileReader::Verify now returns ERROR_BROKEN_STATE if bounds
  checking fails, so modified savestates are rejected here too.
2026-08-01 11:57:27 +02:00
Henrik Rydgård 398a678b88 Fix null pointer deref in AtracSasAddStreamData
The null check for getAtrac() only logged a warning and fell through to
a virtual call on the null pointer. Return 0 on invalid atrac ID.
2026-08-01 11:57:27 +02:00
Henrik Rydgård 3ad08377c5 Clamp partial packet copy to main buffer size in Atrac2::DecodeInternal
The loop-with-trailer streaming path copied 'secondBufferByte % sampleSize'
bytes into the main buffer with no clamp. sampleSize is file-derived, so a
crafted value could overflow the destination. Clamp the copy length to
info.bufferByte.
2026-08-01 11:41:24 +02:00
Henrik Rydgård 6d231f3f45 Guard SAS assembly buffer against oversized ATRAC packets
A crafted blockAlign could overflow the fixed 1000-byte assembly stack
buffer in Atrac2::DecodeForSas. Bail out if the packet can't fit.
2026-07-31 20:54:17 +02:00
Henrik Rydgård ecce9baffa Fix some pause screen issues 2026-07-30 18:44:44 +02:00
Henrik Rydgård e3975c7aae Merge pull request #21988 from Arkadyzja/savestate-forget-stale-helper-threads
Savestate: don't let stale HLE helper threads mutate restored kernel state
2026-07-30 17:21:54 +02:00
Henrik Rydgård 820d420f47 Merge pull request #21989 from Arkadyzja/savestate-compact-audio-queues
Savestate: store only live audio queue data (AudioChannel section v3)
2026-07-30 17:20:30 +02:00
Henrik Rydgård c7653e6b7f Improve sceReg and its tests 2026-07-30 00:26:10 +02:00
Henrik Rydgård e9a0e54e92 sceRtc: Deepseek's implementation of parsing various date formats 2026-07-29 23:41:29 +02:00
Henrik Rydgård c8093171a5 Use the new AI workflow to have DeepSeek figure out an ancient problem with mailbox tests 2026-07-29 23:04:44 +02:00
Henrik Rydgård 2b509e4b1e Minor cleanups, revert change in sceKernelMbx 2026-07-29 20:30:17 +02:00
Henrik Rydgård c99a303646 Fix behavior so we can turn off "IgnoreBadMemAccess" in headless 2026-07-29 18:38:25 +02:00
Henrik Rydgård cc57945280 Made the threads/mbx/refer/refer test not crash 2026-07-29 16:27:51 +02:00
Henrik Rydgård 39c8cbbde1 Use the new kernel module description thing to annotate GPRs in the register viewer 2026-07-28 00:15:41 +02:00
Henrik Rydgård c0826cbb5d Add another dummy function in sceReg, AGENTS.md update 2026-07-27 23:51:17 +02:00
Henrik RydgårdandClaude Opus 5 9b577b5f46 Show module.section+offset next to addresses in exception/stack-trace logs
Added KernelModuleAddressDescription() (Core/HLE/sceKernelModule.cpp),
which looks up which currently loaded module (and text/data/bss/segment
section within it) an address falls in, e.g. "EBOOT.BIN.text+1234".
Wired it into:

- Core_MemoryException/Core_ExecException/Core_BreakException
  (Core/Core.cpp), appended next to every address/pc/ra shown in their
  log lines.
- FormatStackTrace (Core/MemFault.cpp), appended per-frame next to the
  existing symbol description.

This makes crash/exception logs actionable even when there's no symbol
at the faulting address - you at least get which module and section
it's in, useful for reverse engineering unfamiliar code.

Verified live via headless: injected a MIPS break instruction at the
current PC (through Tools/wsdbg) and confirmed the log line changed from
"break instruction hit at 088040ac" to "break instruction hit at 088040ac
[sceDisplayWaitVblank Test.text+ac]".

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XDNwPPuidmNxQGRJxBuRL6
2026-07-27 23:44:14 +02:00
Henrik Rydgård 02aedb598d Detect the main VSH module and log 2026-07-27 23:44:14 +02:00
Henrik Rydgård 606c233ee1 Claude's new sceReg functions 2026-07-27 23:44:06 +02:00
Henrik Rydgård c14959b0b6 Buildfix/testfix 2026-07-27 21:33:14 +02:00
Henrik Rydgård e30b90e709 Quiet and improve some logs 2026-07-27 18:37:28 +02:00
Ren 3abb56e7f5 Savestate: store only live audio queue data (AudioChannel section v3)
FixedSizeQueue::DoState serializes the entire fixed backing store. For
the sceAudio channel queues that is 512KB per channel (32768*8 s16
samples), or ~4.6MB of mostly dead bytes in every savestate across the
nine channels - the live sample count at any moment is normally a few
KB. This addresses the existing TODO in DoState.

Add DoStateCompact(), which stores only the live [head, head+count)
region and restores it linearized at the front of storage. A wrapped
live region is written as its two pieces in pop order; since the POD
DoArray path writes raw bytes with no per-element or per-call header,
the single linear read on load consumes them identically. The count is
validated on load and a bad value fails the load cleanly via
p.SetError.

AudioChannel bumps its section to v3 to use the compact form; old
states still load through the unchanged full-storage path. This shrinks
every savestate by several MB uncompressed and cuts the copy/compress
cost of each save, including the rewind feature's periodic states.
2026-07-27 16:20:49 +02:00
Ren 9296bf0a04 Savestate: don't let stale HLE helper threads mutate restored kernel state
On savestate load, two sites delete a pre-load host object that owns an
HLEHelperThread without calling Forget() first, so ~HLEHelperThread runs
__KernelDeleteThread and kernelMemory.Free() with thread ids and block
addresses from before the load, against the freshly restored kernel
state:

- sceUtility: Do(p, accessThread) deletes the stale accessThread inside
  DoClass before recreating it from the stream.
- scePsmf: Do(p, psmfPlayerMap) deletes every existing PsmfPlayer, and
  ~PsmfPlayer -> AbortFinish() deletes its finishThread raw.

When the stale id or block happens to be absent from the restored state
this only logs errors ("... does not exist" / "BlockAllocator: invalid
free"). When it has been recycled, a live thread is terminated or a
live allocation is freed, silently corrupting the loaded state. Easiest
to hit by loading a state while a savedata operation or PSMF player is
active, into a session where those ids were reused.

__IoDoState and __PsmfShutdown already Forget() before deleting; do the
same at these two sites. Worst case behavior change is a leaked
kernel-side thread record where one was previously (incorrectly)
freed.
2026-07-27 16:20:01 +02:00
Henrik Rydgård 4bf36fc7f8 Add command line option --vsh to try to boot the VSH. Logspam reduction, improve printf logs. 2026-07-27 14:58:59 +02:00
Henrik Rydgård 5c1d113279 Warning fix in sceUsbCam 2026-07-27 14:58:59 +02:00
Henrik Rydgård 28bbb7c5b0 Update the sceReg registry to include the CONFIG category 2026-07-27 14:58:39 +02:00
Henrik Rydgård 26ff5fdb00 Robustness fix 2026-07-25 14:53:40 +02:00
Henrik Rydgård 8cb1732564 Clean up the memory partition ID enum 2026-07-25 14:53:02 +02:00
Henrik RydgårdandClaude Sonnet 5 ca34a14fd8 Resolve unresolved-import calls to a module/NID in the "Unknown syscall" log
A call through a still-pending import gets written as a generic "invalid
syscall" opcode (WriteFuncMissingStub) that no longer carries the
original module name or NID by the time it's actually invoked - but the
address of the syscall instruction itself is exactly the stubAddr every
pending FuncSymbolImport already records. Added
KernelFindImportByStubAddr() to search loaded modules' importedFuncs for
a match, and use it in GetSyscallFuncPointer's unknown-syscall path.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-25 14:52:19 +02:00
Henrik Rydgård afe4d5beaf Buildfixes, dependency shuffling to make things more logical 2026-07-24 14:43:34 +02:00
Henrik Rydgård 78c9952731 Move Qt camera code out of Core 2026-07-24 12:06:15 +02:00
Henrik Rydgård 240a974e95 Remove direct dependency from Core to MacCameraHelper.mm 2026-07-24 12:06:15 +02:00
Henrik Rydgård 040996f185 Use new/delete properly for SceNetAdhocMatchingContext. It contains non-POD C++ objects. 2026-07-23 11:17:44 +02:00
Henrik Rydgård 16c7ec390f Headless: Start taking logic out of the "HeadlessHost"
Also update some agent files
2026-07-21 11:01:48 +02:00
Katharine Chui 01849c251e use new aemu_postoffice apis during polling 2026-07-19 11:30:27 +02:00
Katharine Chui ff83e8c896 bump aemu_postoffice
- Make GetPdpStat behave more like in P2P mode
  - Now fetches accumulated ready to be received amount of data
    instead of only the immediate to be received Pdp block
- Make GetPtpStat behave more like in P2P mode
  - Now fetches accumulated ready to be received amount of data
    instead of the size of the next server send block
- Make PtpRecv behave more like in P2P mode
  - Fix block like behavior where whole server send block has
    to be consumed before getting data from the next send block
  - Fix block like bahavior where sender sends in small PtpSend
    calls while receiver receive with less frequent but bigger
    buffer PtpRecv causes bloat(and eventually server kick)
    on relay
2026-07-19 11:30:27 +02:00
Henrik Rydgård 702e18bd2d Fix typo (thanks Nemo)
See #d0dd10c
2026-07-18 23:55:25 +02:00
Henrik Rydgård 3fd9b42f95 Fix playback of framedumps for headless 2026-07-18 19:09:46 +02:00
Henrik Rydgård ee1314f803 Add new TexCache logging channel 2026-07-18 11:57:56 +02:00
Henrik Rydgård 31b21d6bef Improve and clean up GPU stats 2026-07-16 15:03:20 +02:00
Henrik Rydgård a6516c8d66 __KernelModuleDoState: Only apply function replacement on state load. Improves performance of rewind states 2026-07-14 20:31:39 +02:00
Henrik Rydgård 3d7817a5e3 Fix savestate issue 2026-07-10 12:28:44 +02:00
Dave Leaver 41c3eba296 Call the callback once from put, and have the action call it again if needed 2026-07-10 12:12:39 +02:00
Dave Leaver d31881f0bb cludge fix write position updating 2026-07-10 12:12:39 +02:00
Henrik Rydgård a7dc184613 Reapply "Implement exit callbacks. Attempt to solve #21828"
It was a mistake to revert c4d3cc8 , need to take savestates into
account

This reverts commit d5cec86933.
2026-07-08 19:45:42 +02:00