Re: [PATCH V32 01/27] Add the ability to lock down access to the running kernel image

2019-04-29 Thread Andrew Donnellan

On 29/4/19 2:54 pm, Daniel Axtens wrote:

Hi,


I'm thinking about whether we should lock down the powerpc xmon debug
monitor - intuitively, I think the answer is yes if for no other reason
than Least Astonishment, when lockdown is enabled you probably don't
expect xmon to keep letting you access kernel memory.


The original patchset contained a sysrq hotkey to allow physically
present users to disable lockdown, so I'm not super concerned about
this case - I could definitely be convinced otherwise, though.


So Mimi contacted me offlist and very helpfully provided me with a much
better and less confused justification for disabling xmon in lockdown:

On x86, physical presence (== console access) is a trigger to
disable/enable lockdown mode.

In lockdown mode, you're not supposed to be able to modify memory. xmon
allows you to modify memory, and therefore shouldn't be allowed in
lockdown.

So, if you can disable lockdown on the console that's probably OK, but
it should be specifically disabling lockdown, not randomly editing
memory with xmon.


That makes sense.

--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited



Re: [PATCH V32 01/27] Add the ability to lock down access to the running kernel image

2019-04-28 Thread Daniel Axtens
Hi, 

>>> I'm thinking about whether we should lock down the powerpc xmon debug
>>> monitor - intuitively, I think the answer is yes if for no other reason
>>> than Least Astonishment, when lockdown is enabled you probably don't
>>> expect xmon to keep letting you access kernel memory.
>>
>> The original patchset contained a sysrq hotkey to allow physically
>> present users to disable lockdown, so I'm not super concerned about
>> this case - I could definitely be convinced otherwise, though.

So Mimi contacted me offlist and very helpfully provided me with a much
better and less confused justification for disabling xmon in lockdown:

On x86, physical presence (== console access) is a trigger to
disable/enable lockdown mode.

In lockdown mode, you're not supposed to be able to modify memory. xmon
allows you to modify memory, and therefore shouldn't be allowed in
lockdown.

So, if you can disable lockdown on the console that's probably OK, but
it should be specifically disabling lockdown, not randomly editing
memory with xmon.

Regards,
Daniel


Re: [PATCH V32 01/27] Add the ability to lock down access to the running kernel image

2019-04-28 Thread Daniel Axtens
Matthew Garrett  writes:

> On Tue, Apr 16, 2019 at 1:40 AM Andrew Donnellan
>  wrote:
>> I'm thinking about whether we should lock down the powerpc xmon debug
>> monitor - intuitively, I think the answer is yes if for no other reason
>> than Least Astonishment, when lockdown is enabled you probably don't
>> expect xmon to keep letting you access kernel memory.
>
> The original patchset contained a sysrq hotkey to allow physically
> present users to disable lockdown, so I'm not super concerned about
> this case - I could definitely be convinced otherwise, though.

So currently (and I'm pretty new to this as I've only recently rejoined
IBM) we aren't considering access to the console to be sufficient to
assert physical presence on bare-metal server-class Power machines. The
short argument for this is that with IPMI and BMCs, a server's console
isn't what it used to be. Our console is also a bit different to x86:
we don't generally have bios configuration screens on the console.

In your example, a sysrq key would allow you to disable lockdown after
the system has booted. On Power though, we use Linux as a bootloader
(Petitboot: https://github.com/open-power/petitboot) so being able to
disable lockdown there allows an IPMI-connected user to prevent a signed
kernel being loaded in the first place. I don't know if this is
_actually_ worse, but it certainly feels worse.

There are of course some arguments against our approach. I'm aware of
some of them. I'm also very open to being told that not equating console
access with physical access is fundamentally silly or broken and that we
should rethink things.

Regards,
Daniel


Re: [PATCH V32 01/27] Add the ability to lock down access to the running kernel image

2019-04-18 Thread Daniel Axtens
Hi Andrew,

>> +If CONFIG_LOCK_DOWN_KERNEL is enabled, the kernel can be
>> +moved to a more locked down state at runtime by writing to
>> +this attribute. Valid values are:
>> +
>> +integrity:
>> +The kernel will disable functionality that allows
>> +userland to modify the running kernel image, other
>> +than through the loading or execution of appropriately
>> +signed objects.
>> +
>> +confidentiality:
>> +The kernel will disable all functionality disabled by
>> +the integrity mode, but additionally will disable
>> +features that potentially permit userland to obtain
>> +confidential information stored within the kernel.
>
> [+ linuxppc, mpe, dja, cmr]
>
> I'm thinking about whether we should lock down the powerpc xmon debug 
> monitor - intuitively, I think the answer is yes if for no other reason 
> than Least Astonishment, when lockdown is enabled you probably don't 
> expect xmon to keep letting you access kernel memory.
>
> Semantically though, xmon is not a userspace process - it's in kernel 
> and reads debug commands/outputs debug data directly from/to the 
> console. Is that a threat vector that this series cares about?

I guess there are 2 ways you could think about lockdown:

 - It adds a security boundary between the kernel and UID 0, so that
   userland cannot compromise the integrity/confidentiality of the
   locked down kernel.

 - It is a bundle of related security boundaries so that the
   integrity/confidentiality of a running, locked down kernel cannot be
   compromised, even by a privileged, physically present user.

You're right that techincally xmon is in the kernel and on the console
rather than in userland, so it doesn't fall within the first concept of
lockdown. But I think usecases for lockdown tend to expect something
more like the second concept.

IOW, lockdown is a trapdoor - once you've locked down a kernel, you
can't get out of lockdown (except by rebooting). xmon would allow you to
get out of the trapdoor, so I think it should be restricted by lockdown.

Regards,
Daniel

>
>
> -- 
> Andrew Donnellan  OzLabs, ADL Canberra
> andrew.donnel...@au1.ibm.com  IBM Australia Limited


Re: [PATCH V32 01/27] Add the ability to lock down access to the running kernel image

2019-04-16 Thread Andrew Donnellan

On 4/4/19 11:32 am, Matthew Garrett wrote:

diff --git a/Documentation/ABI/testing/lockdown 
b/Documentation/ABI/testing/lockdown
new file mode 100644
index ..5bd51e20917a
--- /dev/null
+++ b/Documentation/ABI/testing/lockdown
@@ -0,0 +1,19 @@
+What:  security/lockdown
+Date:  March 2019
+Contact:   Matthew Garrett 
+Description:
+   If CONFIG_LOCK_DOWN_KERNEL is enabled, the kernel can be
+   moved to a more locked down state at runtime by writing to
+   this attribute. Valid values are:
+
+   integrity:
+   The kernel will disable functionality that allows
+   userland to modify the running kernel image, other
+   than through the loading or execution of appropriately
+   signed objects.
+
+   confidentiality:
+   The kernel will disable all functionality disabled by
+   the integrity mode, but additionally will disable
+   features that potentially permit userland to obtain
+   confidential information stored within the kernel.


[+ linuxppc, mpe, dja, cmr]

I'm thinking about whether we should lock down the powerpc xmon debug 
monitor - intuitively, I think the answer is yes if for no other reason 
than Least Astonishment, when lockdown is enabled you probably don't 
expect xmon to keep letting you access kernel memory.


Semantically though, xmon is not a userspace process - it's in kernel 
and reads debug commands/outputs debug data directly from/to the 
console. Is that a threat vector that this series cares about?



--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited