Re: [PATCH 2/2] powerpc/rtas: block error injection when locked down

From: Michael Ellerman
Date: Fri Sep 23 2022 - 03:12:53 EST


Paul Moore <paul@xxxxxxxxxxxxxx> writes:
> On Thu, Sep 22, 2022 at 3:38 PM Nathan Lynch <nathanl@xxxxxxxxxxxxx> wrote:
>>
>> The error injection facility on pseries VMs allows corruption of
>> arbitrary guest memory, potentially enabling a sufficiently privileged
>> user to disable lockdown or perform other modifications of the running
>> kernel via the rtas syscall.
>>
>> Block the PAPR error injection facility from being opened or called
>> when locked down.
>>
>> Signed-off-by: Nathan Lynch <nathanl@xxxxxxxxxxxxx>
>> ---
>> arch/powerpc/kernel/rtas.c | 25 ++++++++++++++++++++++++-
>> include/linux/security.h | 1 +
>> security/security.c | 1 +
>> 3 files changed, 26 insertions(+), 1 deletion(-)
>
> ...
>
>> diff --git a/include/linux/security.h b/include/linux/security.h
>> index 1ca8dbacd3cc..b5d5138ae66a 100644
>> --- a/include/linux/security.h
>> +++ b/include/linux/security.h
>> @@ -123,6 +123,7 @@ enum lockdown_reason {
>> LOCKDOWN_BPF_WRITE_USER,
>> LOCKDOWN_DBG_WRITE_KERNEL,
>> LOCKDOWN_DEVICE_TREE,
>> + LOCKDOWN_RTAS_ERROR_INJECTION,
>
> With the understanding that I've never heard of RTAS until now, are
> there any other RTAS events that would require a lockdown reason? As
> a follow up, is it important to distinguish between different RTAS
> lockdown reasons?
>
> I'm trying to determine if we can just call it LOCKDOWN_RTAS.

Yes I think we should.

Currently it only locks down the error injection calls, not all of RTAS.

But firmware can/will add new RTAS calls in future, so it's always
possible something will need to be added to the list of things that need
to be blocked during lockdown.

So I think calling it LOCKDOWN_RTAS would be more general and future
proof, and can be read to mean "lockdown the parts of RTAS that need
to be locked down".

Similarly we have LOCKDOWN_ACPI_TABLES which locks down modification to
ACPI data, but doesn't disable ACPI use entirely AIUI.

cheers