2019-06-11 14:14:05

by Miroslav Benes

[permalink] [raw]
Subject: [PATCH v4 2/3] Revert "livepatch: Remove reliable stacktrace check in klp_try_switch_task()"

This reverts commit 1d98a69e5cef3aeb68bcefab0e67e342d6bb4dad. Commit
31adf2308f33 ("livepatch: Convert error about unsupported reliable
stacktrace into a warning") weakened the enforcement for architectures
to have reliable stack traces support. The system only warns now about
it.

It only makes sense to reintroduce the compile time checking in
klp_try_switch_task() again and bail out early.

Signed-off-by: Miroslav Benes <[email protected]>
---
kernel/livepatch/transition.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/kernel/livepatch/transition.c b/kernel/livepatch/transition.c
index 8e8c79d4b204..7e7ef04689d1 100644
--- a/kernel/livepatch/transition.c
+++ b/kernel/livepatch/transition.c
@@ -293,6 +293,13 @@ static bool klp_try_switch_task(struct task_struct *task)
if (task->patch_state == klp_target_state)
return true;

+ /*
+ * For arches which don't have reliable stack traces, we have to rely
+ * on other methods (e.g., switching tasks at kernel exit).
+ */
+ if (!klp_have_reliable_stack())
+ return false;
+
/*
* Now try to check the stack for any to-be-patched or to-be-unpatched
* functions. If all goes well, switch the task to the target patch
--
2.21.0


2019-06-12 08:47:19

by Petr Mladek

[permalink] [raw]
Subject: Re: [PATCH v4 2/3] Revert "livepatch: Remove reliable stacktrace check in klp_try_switch_task()"

On Tue 2019-06-11 16:13:19, Miroslav Benes wrote:
> This reverts commit 1d98a69e5cef3aeb68bcefab0e67e342d6bb4dad. Commit
> 31adf2308f33 ("livepatch: Convert error about unsupported reliable
> stacktrace into a warning") weakened the enforcement for architectures
> to have reliable stack traces support. The system only warns now about
> it.
>
> It only makes sense to reintroduce the compile time checking in
> klp_try_switch_task() again and bail out early.
>
> Signed-off-by: Miroslav Benes <[email protected]>

Reviewed-by: Petr Mladek <[email protected]>

Best Regards,
Petr

2019-06-12 17:59:14

by Kamalesh Babulal

[permalink] [raw]
Subject: Re: [PATCH v4 2/3] Revert "livepatch: Remove reliable stacktrace check in klp_try_switch_task()"

On Tue, Jun 11, 2019 at 04:13:19PM +0200, Miroslav Benes wrote:
> This reverts commit 1d98a69e5cef3aeb68bcefab0e67e342d6bb4dad. Commit
> 31adf2308f33 ("livepatch: Convert error about unsupported reliable
> stacktrace into a warning") weakened the enforcement for architectures
> to have reliable stack traces support. The system only warns now about
> it.
>
> It only makes sense to reintroduce the compile time checking in
> klp_try_switch_task() again and bail out early.
>
> Signed-off-by: Miroslav Benes <[email protected]>

Reviewed-by: Kamalesh Babulal <[email protected]>