fault_test() replaces the exception handler for in-kernel tests with a longjmp() based exception handling. However, it leaves the exception handler in place which may confuse later test code triggering the same exception without installing a handler first. Fix this be restoring the previous exception handler, as running the longjmp() handler out of context will lead to no good. Signed-off-by: Mathias Krause <minipli@xxxxxxxxxxxxxx> --- lib/x86/fault_test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/x86/fault_test.c b/lib/x86/fault_test.c index e15a21864562..614bdcb42535 100644 --- a/lib/x86/fault_test.c +++ b/lib/x86/fault_test.c @@ -19,18 +19,20 @@ static bool fault_test(struct fault_test_arg *arg) test_fault_func func = (test_fault_func) arg->func; /* Init as success in case there isn't callback */ bool callback_success = true; + handler old; if (arg->usermode) { val = run_in_user((usermode_func) func, arg->fault_vector, arg->arg[0], arg->arg[1], arg->arg[2], arg->arg[3], &raised_vector); } else { - handle_exception(arg->fault_vector, fault_test_fault); + old = handle_exception(arg->fault_vector, fault_test_fault); if (setjmp(jmpbuf) == 0) val = func(arg->arg[0], arg->arg[1], arg->arg[2], arg->arg[3]); else raised_vector = true; + handle_exception(arg->fault_vector, old); } if (!raised_vector) { -- 2.39.2