Merge branch 'bugfix/memprot_bad_esp_restart_check' into 'master'

System/Security: wrong check of the Memprot feature in esp_restart()/panic_restart()

See merge request espressif/esp-idf!15414
This commit is contained in:
Mahavir Jain 2021-10-29 12:17:32 +00:00
commit a89d56082f
3 changed files with 14 additions and 30 deletions

View File

@ -1,16 +1,8 @@
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "esp_system.h"
#include "esp_private/system_internal.h"
@ -93,7 +85,7 @@ void IRAM_ATTR esp_restart(void)
vTaskSuspendAll();
bool digital_reset_needed = false;
#if CONFIG_ESP_SYSTEM_CONFIG_MEMPROT_FEATURE
#if CONFIG_ESP_SYSTEM_MEMPROT_FEATURE
if (esp_memprot_is_intr_ena_any() || esp_memprot_is_locked_any()) {
digital_reset_needed = true;
}

View File

@ -1,16 +1,9 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <stdlib.h>
#include "esp_spi_flash.h"
@ -199,7 +192,8 @@ static void panic_handler(void *frame, bool pseudo_excause)
* This function must always be in IRAM as it is required to
* re-enable the flash cache.
*/
static void IRAM_ATTR panic_enable_cache(void) {
static void IRAM_ATTR panic_enable_cache(void)
{
int core_id = cpu_hal_get_core_id();
if (!spi_flash_cache_enabled()) {
@ -234,7 +228,7 @@ void __attribute__((noreturn)) panic_restart(void)
digital_reset_needed = true;
}
#endif
#if CONFIG_ESP_SYSTEM_CONFIG_MEMPROT_FEATURE
#if CONFIG_ESP_SYSTEM_MEMPROT_FEATURE
if (esp_memprot_is_intr_ena_any() || esp_memprot_is_locked_any()) {
digital_reset_needed = true;
}

View File

@ -933,7 +933,6 @@ components/esp_system/crosscore_int.c
components/esp_system/dbg_stubs.c
components/esp_system/eh_frame_parser.c
components/esp_system/esp_err.c
components/esp_system/esp_system.c
components/esp_system/fpga_overrides.c
components/esp_system/freertos_hooks.c
components/esp_system/include/eh_frame_parser.h
@ -958,7 +957,6 @@ components/esp_system/port/brownout.c
components/esp_system/port/include/esp_clk_internal.h
components/esp_system/port/include/port/panic_funcs.h
components/esp_system/port/include/riscv/eh_frame_parser_impl.h
components/esp_system/port/panic_handler.c
components/esp_system/port/public_compat/brownout.h
components/esp_system/port/public_compat/cache_err_int.h
components/esp_system/port/public_compat/trax.h