userfaultfd: selftests: infinite loop in faulting_process
authorEdward Liaw <edliaw@google.com>
Mon, 13 Jun 2022 23:33:21 +0000 (23:33 +0000)
committerakpm <akpm@linux-foundation.org>
Mon, 4 Jul 2022 01:08:43 +0000 (18:08 -0700)
commit50b0f797cab6cb7dff418777e1acf82dfd3568f8
tree0e6e4a22f4fc5ae61538b2a9b44bb9f13ada99af
parent6acfcd0d75244178a4a101fe0da888fa3bff29fb
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>
tools/testing/selftests/vm/userfaultfd.c