Skip to content

Commit 360be17

Browse files
committed
zephyr: vregion: stop logging spurious "read access denied" on free paths
vregion_verify() asserts that the vregion metadata object is NOT accessible to the userspace context. It did this with K_OOPS(!K_SYSCALL_MEMORY_READ(vr, sizeof(*vr))); but K_SYSCALL_MEMORY_READ() emits an "os.vregion_verify: ... Memory region <addr> (size 88) read access denied" error via LOG_ERR precisely when the region is inaccessible - i.e. in the expected, correct case for a kernel-only vregion. Probe the mapping directly with arch_buffer_validate(), which performs the same check without logging, and oops only if the userspace context can actually read the metadata. No functional change to the security check; only the false-positive error logging is removed. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 182294e commit 360be17

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

zephyr/lib/vregion.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,15 @@ bool vregion_verify(struct vregion *vr)
554554
if (!vr)
555555
return false;
556556

557-
/* vregion instances must not be accessible to the userspace. */
558-
K_OOPS(!K_SYSCALL_MEMORY_READ(vr, sizeof(*vr)));
557+
/*
558+
* vregion instances must not be accessible to the userspace.
559+
*
560+
* Don't use K_SYSCALL_MEMORY_READ() here: it logs an "access denied"
561+
* error whenever the region is inaccessible, which is exactly the
562+
* expected (good) case for a kernel-only vregion. Omit false
563+
* error messages by using arch_buffer_validate() directly.
564+
*/
565+
K_OOPS(arch_buffer_validate((void *)vr, sizeof(*vr), 0) == 0);
559566

560567
size_t vr_size = 0;
561568
uintptr_t vr_start;

0 commit comments

Comments
 (0)