Skip to content

Commit 50b0f79

Browse files
edliawakpm00
authored andcommitted
userfaultfd: selftests: infinite loop in faulting_process
On Android this test is getting stuck in an infinite loop due to indeterminate behavior: The local variables steps and signalled were being reset to 1 and 0 respectively after every jump back to sigsetjmp by siglongjmp in the signal handler. The test was incrementing them and expecting them to retain their incremented values. The documentation for siglongjmp says: All accessible objects have values as of the time sigsetjmp() was called, except that the values of objects of automatic storage duration which are local to the function containing the invocation of the corresponding sigsetjmp() which do not have volatile-qualified type and which are changed between the sigsetjmp() invocation and siglongjmp() call are indeterminate. Tagging steps and signalled with volatile enabled the test to pass. Link: https://lkml.kernel.org/r/20220613233321.431282-1-edliaw@google.com Signed-off-by: Edward Liaw <edliaw@google.com> Reviewed-by: Axel Rasmussen <axelrasmussen@google.com> Cc: Shuah Khan <shuah@kernel.org> Cc: Peter Xu <peterx@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 6acfcd0 commit 50b0f79

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/testing/selftests/vm/userfaultfd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ static int faulting_process(int signal_test)
931931
unsigned long split_nr_pages;
932932
unsigned long lastnr;
933933
struct sigaction act;
934-
unsigned long signalled = 0;
934+
volatile unsigned long signalled = 0;
935935

936936
split_nr_pages = (nr_pages + 1) / 2;
937937

@@ -946,7 +946,7 @@ static int faulting_process(int signal_test)
946946
}
947947

948948
for (nr = 0; nr < split_nr_pages; nr++) {
949-
int steps = 1;
949+
volatile int steps = 1;
950950
unsigned long offset = nr * page_size;
951951

952952
if (signal_test) {

0 commit comments

Comments
 (0)