Skip to content

Commit 24076ab

Browse files
stephensmalleyAnas Nashif
authored andcommitted
tests/kernel/mem_protect/userspace: test that _k_neg_eagain is in rodata
Explicitly test that _k_neg_eagain is in rodata. Signed-off-by: Stephen Smalley <[email protected]>
1 parent 106b1c2 commit 24076ab

File tree

1 file changed

+7
-0
lines changed
  • tests/kernel/mem_protect/userspace/src

1 file changed

+7
-0
lines changed

tests/kernel/mem_protect/userspace/src/main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,16 @@ static void write_kernram(void)
103103

104104
extern int _k_neg_eagain;
105105

106+
#include <linker/linker-defs.h>
107+
106108
static void write_kernro(void)
107109
{
108110
/* Try to write to kernel RO. */
111+
const char *const ptr = (const char *const)&_k_neg_eagain;
112+
113+
zassert_true(ptr < _image_rodata_end &&
114+
ptr >= _image_rodata_start,
115+
"_k_neg_eagain is not in rodata\n");
109116
_k_neg_eagain = -EINVAL;
110117
zassert_unreachable("Write to kernel RO did not fault\n");
111118
}

0 commit comments

Comments
 (0)