From 248b738f255374c1e9a99f1e3f69d3c0f615f727 Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Tue, 3 May 2022 08:42:15 +0300 Subject: [PATCH] arm_addrenv: Add stubs for modifying permissions Adds stubs for up_addrenv_text_enable/disable_write. These don't have to do anything as the ARM MMU allows setting access per mode. Currently the settings for user .text area grants the kernel write access, but revokes user write access. --- arch/arm/src/armv7-a/Make.defs | 2 +- arch/arm/src/armv7-a/arm_addrenv_perms.c | 75 ++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 arch/arm/src/armv7-a/arm_addrenv_perms.c diff --git a/arch/arm/src/armv7-a/Make.defs b/arch/arm/src/armv7-a/Make.defs index dc1adbfa44..19a60b3954 100644 --- a/arch/arm/src/armv7-a/Make.defs +++ b/arch/arm/src/armv7-a/Make.defs @@ -63,7 +63,7 @@ else endif ifeq ($(CONFIG_ARCH_ADDRENV),y) - CMN_CSRCS += arm_addrenv.c arm_addrenv_utils.c arm_pgalloc.c + CMN_CSRCS += arm_addrenv.c arm_addrenv_utils.c arm_addrenv_perms.c arm_pgalloc.c ifeq ($(CONFIG_ARCH_STACK_DYNAMIC),y) CMN_CSRCS += arm_addrenv_ustack.c endif diff --git a/arch/arm/src/armv7-a/arm_addrenv_perms.c b/arch/arm/src/armv7-a/arm_addrenv_perms.c new file mode 100644 index 0000000000..c396f9f1e2 --- /dev/null +++ b/arch/arm/src/armv7-a/arm_addrenv_perms.c @@ -0,0 +1,75 @@ +/**************************************************************************** + * arch/arm/src/armv7-a/arm_addrenv_perms.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_addrenv_text_enable_write + * + * Description: + * Temporarily enable write access to the .text section. This must be + * called prior to loading the process code into memory. + * + * Input Parameters: + * addrenv - The address environment to be modified. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_text_enable_write(group_addrenv_t *addrenv) +{ + /* Nothing needs to be done */ + + return OK; +} + +/**************************************************************************** + * Name: up_addrenv_text_disable_write + * + * Description: + * Disable write access to the .text section. This must be called after the + * process code is loaded into memory. + * + * Input Parameters: + * addrenv - The address environment to be modified. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_text_disable_write(group_addrenv_t *addrenv) +{ + /* Nothing needs to be done */ + + return OK; +}