You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2022/05/03 12:25:33 UTC

[incubator-nuttx] 02/02: arm_addrenv: Add stubs for modifying permissions

This is an automated email from the ASF dual-hosted git repository.

masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 248b738f255374c1e9a99f1e3f69d3c0f615f727
Author: Ville Juven <vi...@unikie.com>
AuthorDate: Tue May 3 08:42:15 2022 +0300

    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(-)

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 <nuttx/config.h>
+
+#include <nuttx/arch.h>
+
+/****************************************************************************
+ * 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;
+}