• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From bc2a97ef4b165f7a432cc9cf8d5714b94e120051 Mon Sep 17 00:00:00 2001
2From: Edward Liaw <edliaw@google.com>
3Date: Tue, 10 May 2022 18:06:01 +0000
4Subject: [PATCH 22/24] userfaultfd: infinite loop in faulting_process
5
6The local variables steps and signalled were being reset to 1 and 0
7respectively after every jump back to sigsetjmp by siglongjmp in the
8signal handler. The test was incrementing them and expecting them to
9retain their incremented values. The documentation for siglongjmp says:
10
11All accessible objects have values as of the time sigsetjmp() was
12called, except that the values of objects of automatic storage duration
13which are local to the function containing the invocation of the
14corresponding sigsetjmp() which do not have volatile-qualified type and
15which are changed between the sigsetjmp() invocation and siglongjmp()
16call are indeterminate.
17
18Tagging steps and signalled with volatile enabled the test to pass.
19
20Bug: 232026677
21Signed-off-by: Edward Liaw <edliaw@google.com>
22---
23 tools/testing/selftests/vm/userfaultfd.c | 4 ++--
24 1 file changed, 2 insertions(+), 2 deletions(-)
25
26diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c
27index e7a79f120cbde..b37642be42054 100644
28--- a/tools/testing/selftests/vm/userfaultfd.c
29+++ b/tools/testing/selftests/vm/userfaultfd.c
30@@ -944,7 +944,7 @@ static int faulting_process(int signal_test)
31 	unsigned long split_nr_pages;
32 	unsigned long lastnr;
33 	struct sigaction act;
34-	unsigned long signalled = 0;
35+	volatile unsigned long signalled = 0;
36
37 	if (test_type != TEST_HUGETLB)
38 		split_nr_pages = (nr_pages + 1) / 2;
39@@ -962,7 +962,7 @@ static int faulting_process(int signal_test)
40 	}
41
42 	for (nr = 0; nr < split_nr_pages; nr++) {
43-		int steps = 1;
44+		volatile int steps = 1;
45 		unsigned long offset = nr * page_size;
46
47 		if (signal_test) {
48--
492.36.0.550.gb090851708-goog
50
51