Re: Linux guest kernel threat model for Confidential Computing

From: Carlos Bilbao
Date: Tue Feb 07 2023 - 14:53:46 EST


On 2/7/23 00:03, Greg Kroah-Hartman wrote:

On Mon, Feb 06, 2023 at 06:27:48PM -0600, Carlos Bilbao wrote:
On 1/25/23 6:28 AM, Reshetova, Elena wrote:
2) One of the described in the above doc mitigations is "hardening of the enabled
code". What we mean by this, as well as techniques that are being used are
described in this document: > https://intel.github.io/ccc-linux-guest-hardening-docs/tdx-guest-hardening.html
Regarding driver hardening, does anyone have a better filtering idea?

The current solution assumes the kernel command line is trusted and cannot
avoid the __init() functions that waste memory.
That is two different things (command line trust and __init()
functions), so I do not understand the relationship at all here. Please
explain it better.


No relation other than it would be nice to have a solution that does not
require kernel command line and that prevents __init()s.



Also, why would an __init() function waste memory? Memory usage isn't
an issue here, right?

I don't know if the
__exit() routines of the filtered devices are called, but it doesn't sound
much better to allocate memory and free it right after.
What device has a __exit() function? Drivers have module init/exit
functions but they should do nothing but register themselves with the
relevant busses and they are only loaded if the device is found in the
system.

And what exactly is incorrect about allocating memory and then freeing
it when not needed?


Currently proposed device filtering does not stop the __init() functions
from these drivers to be called. Whatever memory is allocated by
blacklisted drivers is wasted because those drivers cannot ever be used.
Sure, memory can be allocated and freed as soon as it is no longer needed,
but these memory would never be needed.


More pressing concern than wasted memory, which may be unimportant, there's
the issue of what are those driver init functions doing. For example, as
part of device setup, MMIO regs may be involved, which we cannot trust. It's
a lot more code to worry about from a CoCo perspective.



So again, I don't understand the question, sorry.


Given the limitations of current approach, does anyone have any other ideas
for filtering devices prior to their initialization?



thanks,

greg k-h


Thanks,
Carlos