mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-10-05 05:07:49 +00:00
A test that a user process which makes a forbidden access is stopped, and that nothing else is. It spawns this program again as a separate process to make the access, because a kernel build does not give user code task_create(), and checks that the offender died, that the caller still runs and that a canary thread kept counting. The canary is what tells "the offender was contained" from "the whole system stopped". Every target has the outcome it expects: self the process's own data must succeed kernel kernel memory must fault periph a peripheral register must fault unmapped an address with no mapping must fault "self" is the control. Without it a build that refuses every access passes every other check. An MMU keeps processes apart but does not stop one reaching a peripheral, and an unmapped access is refused by another mechanism again, so neither is covered by the kernel target. The offender allocates memory and opens a file before the access. The test reads /proc/meminfo and /proc/<pid>/group/fd while it lives and after it is reaped, and fails if the counts never rose, since "the same before and after" says nothing if the resources were never seen. The addresses come from Kconfig, because a user process cannot see kernel symbols. A protected build derives the kernel target from CONFIG_NUTTX_USERSPACE when none is set. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
32 lines
1.3 KiB
Makefile
32 lines
1.3 KiB
Makefile
############################################################################
|
|
# apps/examples/sandbox/Makefile
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
# 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.
|
|
#
|
|
############################################################################
|
|
|
|
include $(APPDIR)/Make.defs
|
|
|
|
PROGNAME = $(CONFIG_EXAMPLES_SANDBOX_PROGNAME)
|
|
PRIORITY = $(CONFIG_EXAMPLES_SANDBOX_PRIORITY)
|
|
STACKSIZE = $(CONFIG_EXAMPLES_SANDBOX_STACKSIZE)
|
|
MODULE = $(CONFIG_EXAMPLES_SANDBOX)
|
|
|
|
MAINSRC = sandbox_main.c
|
|
|
|
include $(APPDIR)/Application.mk
|