Skip to content

Commit 9d51c16

Browse files
committed
selftests/mm: fix guard-pages build
JIRA: https://issues.redhat.com/browse/RHEL-78135 Upstream Status: RHEL only The tools/testing/selftests/mm/guard-pages.c build was br0ken in v6.13: """ guard-pages.c: In function ‘guard_pages_process_madvise’: guard-pages.c:422:17: warning: implicit declaration of function ‘process_madvise’; did you mean ‘SYS_process_madvise’? [-Wimplicit-function-declaration] 422 | count = process_madvise(pidfd, vec, 6, MADV_GUARD_INSTALL, 0); | ^~~~~~~~~~~~~~~ | SYS_process_madvise /usr/bin/ld: /tmp/ccLfVeGh.o: in function `guard_pages_process_madvise': guard-pages.c:(.text+0x5c54): undefined reference to `process_madvise' /usr/bin/ld: guard-pages.c:(.text+0x629c): undefined reference to `process_madvise' collect2: error: ld returned 1 exit status make: *** [../lib.mk:222: /home/luizcap/src/linux/tools/testing/selftests/mm/guard-pages] Error 1 """ This is fixed in upstream commit 19b65ff ("selftests/mm: add fork CoW guard page test"). Now, the problem is that that commit was merged in v6.14-rc1 and it adds a new test too so I can't tell if the new test is supported in v6.13. To be safe, do a partial backport of the build fix only. Signed-off-by: Luiz Capitulino <luizcap@redhat.com>
1 parent 7fd921d commit 9d51c16

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tools/testing/selftests/mm/guard-pages.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ static int pidfd_open(pid_t pid, unsigned int flags)
5555
return syscall(SYS_pidfd_open, pid, flags);
5656
}
5757

58+
static ssize_t sys_process_madvise(int pidfd, const struct iovec *iovec,
59+
size_t n, int advice, unsigned int flags)
60+
{
61+
return syscall(__NR_process_madvise, pidfd, iovec, n, advice, flags);
62+
}
63+
5864
/*
5965
* Enable our signal catcher and try to read/write the specified buffer. The
6066
* return value indicates whether the read/write succeeds without a fatal
@@ -419,7 +425,7 @@ TEST_F(guard_pages, process_madvise)
419425
ASSERT_EQ(munmap(&ptr_region[99 * page_size], page_size), 0);
420426

421427
/* Now guard in one step. */
422-
count = process_madvise(pidfd, vec, 6, MADV_GUARD_INSTALL, 0);
428+
count = sys_process_madvise(pidfd, vec, 6, MADV_GUARD_INSTALL, 0);
423429

424430
/* OK we don't have permission to do this, skip. */
425431
if (count == -1 && errno == EPERM)
@@ -440,7 +446,7 @@ TEST_F(guard_pages, process_madvise)
440446
ASSERT_FALSE(try_read_write_buf(&ptr3[19 * page_size]));
441447

442448
/* Now do the same with unguard... */
443-
count = process_madvise(pidfd, vec, 6, MADV_GUARD_REMOVE, 0);
449+
count = sys_process_madvise(pidfd, vec, 6, MADV_GUARD_REMOVE, 0);
444450

445451
/* ...and everything should now succeed. */
446452

0 commit comments

Comments
 (0)