Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/ring-buffer: Add test for out-of-bound pgoff mapping

Extend the ring-buffer mapping test coverage by checking an out-of-bound
pgoff which has proven to be problematic in the past.

Link: https://lore.kernel.org/r/20241218170318.2814991-1-vdonnefort@google.com
Cc: Shuah Khan <skhan@linuxfoundation.org>
Cc: linux-kselftest@vger.kernel.org
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Vincent Donnefort and committed by
Shuah Khan
b6f9cd83 103c0b5e

+7 -1
+7 -1
tools/testing/selftests/ring-buffer/map_test.c
··· 233 233 ASSERT_NE(data, MAP_FAILED); 234 234 munmap(data, data_len); 235 235 236 - /* Overflow the available subbufs by 1 */ 236 + /* Offset within ring-buffer bounds, mapping size overflow */ 237 237 meta_len += desc->meta->subbuf_size * 2; 238 238 data = mmap(NULL, data_len, PROT_READ, MAP_SHARED, 239 239 desc->cpu_fd, meta_len); 240 + ASSERT_EQ(data, MAP_FAILED); 241 + 242 + /* Offset outside ring-buffer bounds */ 243 + data_len = desc->meta->subbuf_size * desc->meta->nr_subbufs; 244 + data = mmap(NULL, data_len, PROT_READ, MAP_SHARED, 245 + desc->cpu_fd, data_len + (desc->meta->subbuf_size * 2)); 240 246 ASSERT_EQ(data, MAP_FAILED); 241 247 242 248 /* Verify meta-page padding */