提交 50b0f797 编写于 作者: E Edward Liaw 提交者: akpm

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.comSigned-off-by: NEdward Liaw <edliaw@google.com>
Reviewed-by: NAxel Rasmussen <axelrasmussen@google.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Peter Xu <peterx@redhat.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
上级 6acfcd0d
...@@ -931,7 +931,7 @@ static int faulting_process(int signal_test) ...@@ -931,7 +931,7 @@ static int faulting_process(int signal_test)
unsigned long split_nr_pages; unsigned long split_nr_pages;
unsigned long lastnr; unsigned long lastnr;
struct sigaction act; struct sigaction act;
unsigned long signalled = 0; volatile unsigned long signalled = 0;
split_nr_pages = (nr_pages + 1) / 2; split_nr_pages = (nr_pages + 1) / 2;
...@@ -946,7 +946,7 @@ static int faulting_process(int signal_test) ...@@ -946,7 +946,7 @@ static int faulting_process(int signal_test)
} }
for (nr = 0; nr < split_nr_pages; nr++) { for (nr = 0; nr < split_nr_pages; nr++) {
int steps = 1; volatile int steps = 1;
unsigned long offset = nr * page_size; unsigned long offset = nr * page_size;
if (signal_test) { if (signal_test) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册