On 09/01/2024 13:04, Chaitanya S Prakash wrote:
From: Chaitanya S Prakash chaitanyas.prakash@arm.com
Overwriting part of a mapping within an existing reservation is allowed with the use of the MAP_FIXED flag. Whereas any attempt to write beyond the bounds of the existing reservation would cause the syscall to fail.
AFAICT these tests are purely abound capability bounds check, not reservation bounds.
[...]
- /* negative madvise() range test */
- ptr = mmap(NULL, MMAP_SIZE, prot, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
Can't we use the same (private) mapping to test madvise()?
- ASSERT_FALSE(IS_ERR_VALUE(ptr));
- reduced_bound_ptr = cheri_bounds_set(ptr, MMAP_SIZE_REDUCED);
- retval = madvise(reduced_bound_ptr, MMAP_SIZE, MADV_NORMAL);
- EXPECT_EQ(retval, -EINVAL);
+}
[...]