From 25b0baae59facbe227a28fe2fa3ab9b856c56e17 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 17 Feb 2020 02:57:01 -0800 Subject: [PATCH] kern: change decompression asserts -> audits --- .../libmesosphere/source/arch/arm64/kern_k_page_table.cpp | 2 +- libraries/libmesosphere/source/kern_initial_process.cpp | 1 - .../libmesosphere/source/kern_k_initial_process_reader.cpp | 7 ++++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/libmesosphere/source/arch/arm64/kern_k_page_table.cpp b/libraries/libmesosphere/source/arch/arm64/kern_k_page_table.cpp index ffd1f8037..7696356a5 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_k_page_table.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_k_page_table.cpp @@ -190,7 +190,7 @@ namespace ams::kern::arch::arm64 { /* Map the pages, using a guard to ensure we don't leak. */ { - auto map_guard = SCOPE_GUARD { MESOSPHERE_R_ABORT_UNLESS(this->Unmap(orig_virt_addr, num_pages, nullptr, page_list, true, true)); }; + auto map_guard = SCOPE_GUARD { MESOSPHERE_R_ABORT_UNLESS(this->Unmap(orig_virt_addr, num_pages, page_list, true, true)); }; if (num_pages < ContiguousPageSize / PageSize) { R_TRY(this->Map(virt_addr, phys_addr, num_pages, entry_template, L3BlockSize, page_list, reuse_ll)); diff --git a/libraries/libmesosphere/source/kern_initial_process.cpp b/libraries/libmesosphere/source/kern_initial_process.cpp index 64e7c56ed..780fadb9d 100644 --- a/libraries/libmesosphere/source/kern_initial_process.cpp +++ b/libraries/libmesosphere/source/kern_initial_process.cpp @@ -52,7 +52,6 @@ namespace ams::kern { /* Parse process parameters and reserve memory. */ ams::svc::CreateProcessParameter params; MESOSPHERE_R_ABORT_UNLESS(reader.MakeCreateProcessParameter(std::addressof(params), true)); - MESOSPHERE_LOG("Reserving %zx for process %zu\n", params.code_num_pages * PageSize, i); MESOSPHERE_ABORT_UNLESS(Kernel::GetSystemResourceLimit().Reserve(ams::svc::LimitableResource_PhysicalMemoryMax, params.code_num_pages * PageSize)); /* Create the process. */ diff --git a/libraries/libmesosphere/source/kern_k_initial_process_reader.cpp b/libraries/libmesosphere/source/kern_k_initial_process_reader.cpp index bf3a66a91..b5eae38cb 100644 --- a/libraries/libmesosphere/source/kern_k_initial_process_reader.cpp +++ b/libraries/libmesosphere/source/kern_k_initial_process_reader.cpp @@ -49,13 +49,14 @@ namespace ams::kern { if (control & 0x80) { /* NOTE: Nintendo does not check if it's possible to decompress. */ /* As such, we will leave the following as a debug assertion, and not a release assertion. */ - MESOSPHERE_ASSERT(cmp_ofs >= sizeof(u16)); + MESOSPHERE_AUDIT(cmp_ofs >= sizeof(u16)); cmp_ofs -= sizeof(u16); /* Extract segment bounds. */ const util::BitPack16 seg_flags{static_cast((cmp_start[cmp_ofs] << 0) | (cmp_start[cmp_ofs + 1] << 8))}; const u32 seg_ofs = seg_flags.Get() + 3; - const u32 seg_size = std::min(seg_flags.Get(), out_ofs) + 3; + const u32 seg_size = std::min(seg_flags.Get() + 3, out_ofs); + MESOSPHERE_AUDIT(out_ofs + seg_ofs <= total_size + additional_size); /* Copy the data. */ out_ofs -= seg_size; @@ -65,7 +66,7 @@ namespace ams::kern { } else { /* NOTE: Nintendo does not check if it's possible to copy. */ /* As such, we will leave the following as a debug assertion, and not a release assertion. */ - MESOSPHERE_ASSERT(cmp_ofs >= sizeof(u8)); + MESOSPHERE_AUDIT(cmp_ofs >= sizeof(u8)); cmp_start[--out_ofs] = cmp_start[--cmp_ofs]; } }