From 262d6af519c1f5bffcbe6c0e0952ce6367667ea4 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 1 Apr 2019 17:24:15 -0700 Subject: [PATCH] bis_protect: guard against autorcm on rcm-patched units --- exosphere/src/fuse.c | 5 +++++ .../ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp | 11 ++++++++++- stratosphere/libstratosphere | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/exosphere/src/fuse.c b/exosphere/src/fuse.c index 36ac6991f..e591cd249 100644 --- a/exosphere/src/fuse.c +++ b/exosphere/src/fuse.c @@ -40,6 +40,11 @@ void fuse_init(void) fuse_make_regs_visible(); fuse_secondary_private_key_disable(); fuse_disable_programming(); + + /* TODO: Should we allow this to be done later? */ + if (!g_has_checked_for_rcm_bug_patch) { + (void)(fuse_has_rcm_bug_patch()); + } /* TODO: Overrides (iROM patches) and various reads happen here */ } diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp index f0ad46dfc..d1853fd92 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp @@ -24,7 +24,16 @@ static HosMutex g_boot0_mutex; static u8 g_boot0_bct_buffer[Boot0Storage::BctEndOffset]; bool Boot0Storage::CanModifyBctPubks() { - return this->title_id != TitleId_Ns; + if (IsRcmBugPatched()) { + /* RCM bug patched. */ + /* Only allow NS to update the BCT pubks. */ + /* AutoRCM on a patched unit will cause a brick, so homebrew should NOT be allowed to write. */ + return this->title_id == TitleId_Ns; + } else { + /* RCM bug unpatched. */ + /* Allow homebrew but not NS to update the BCT pubks. */ + return this->title_id != TitleId_Ns; + } } Result Boot0Storage::Read(void *_buffer, size_t size, u64 offset) { diff --git a/stratosphere/libstratosphere b/stratosphere/libstratosphere index 37b74c7d7..b6ca2d89a 160000 --- a/stratosphere/libstratosphere +++ b/stratosphere/libstratosphere @@ -1 +1 @@ -Subproject commit 37b74c7d754c6e6e73278864264940cba4f651db +Subproject commit b6ca2d89ae5106ea21454f332f07076159ad2e92