Re: [PATCH v3 36/37] x86/cet/shstk: Add ARCH_CET_UNLOCK

From: Peter Zijlstra
Date: Tue Nov 15 2022 - 14:34:20 EST


On Fri, Nov 04, 2022 at 03:36:03PM -0700, Rick Edgecombe wrote:

> diff --git a/arch/x86/kernel/shstk.c b/arch/x86/kernel/shstk.c
> index 71620b77a654..bed7032d35f2 100644
> --- a/arch/x86/kernel/shstk.c
> +++ b/arch/x86/kernel/shstk.c
> @@ -450,9 +450,14 @@ long cet_prctl(struct task_struct *task, int option, unsigned long features)
> return 0;
> }
>
> - /* Don't allow via ptrace */
> - if (task != current)
> + /* Only allow via ptrace */

Both the old and new comment are equally useless for they tell us
nothing the code doesn't already.

Why isn't ptrace allowed to call these, and doesn't that rather leave
CRIU in a bind, it can unlock but not re-lock the features, leaving
restored processes more vulnerable than they were.

> + if (task != current) {
> + if (option == ARCH_CET_UNLOCK && IS_ENABLED(CONFIG_CHECKPOINT_RESTORE)) {

Why make this conditional on CRIU at all?

> + task->thread.features_locked &= ~features;
> + return 0;
> + }
> return -EINVAL;
> + }
>
> /* Do not allow to change locked features */
> if (features & task->thread.features_locked)
> --
> 2.17.1
>