Skip to content

Commit b6f9cd8

Browse files
vdonnefortshuahkh
authored andcommitted
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>
1 parent 103c0b5 commit b6f9cd8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tools/testing/selftests/ring-buffer/map_test.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,18 @@ TEST_F(map, data_mmap)
233233
ASSERT_NE(data, MAP_FAILED);
234234
munmap(data, data_len);
235235

236-
/* Overflow the available subbufs by 1 */
236+
/* Offset within ring-buffer bounds, mapping size overflow */
237237
meta_len += desc->meta->subbuf_size * 2;
238238
data = mmap(NULL, data_len, PROT_READ, MAP_SHARED,
239239
desc->cpu_fd, meta_len);
240240
ASSERT_EQ(data, MAP_FAILED);
241241

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));
246+
ASSERT_EQ(data, MAP_FAILED);
247+
242248
/* Verify meta-page padding */
243249
if (desc->meta->meta_page_size > getpagesize()) {
244250
data_len = desc->meta->meta_page_size;

0 commit comments

Comments
 (0)