Re: [patch 1/2] x86,module: Detect VMX modules and disable Split-Lock-Detect

From: Peter Zijlstra
Date: Mon Apr 06 2020 - 10:40:29 EST


On Mon, Apr 06, 2020 at 05:23:43AM -0700, Christoph Hellwig wrote:
> On Thu, Apr 02, 2020 at 02:32:59PM +0200, Thomas Gleixner wrote:
> > From: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> >
> > It turns out that with Split-Lock-Detect enabled (default) any VMX
> > hypervisor needs at least a little modification in order to not blindly
> > inject the #AC into the guest without the guest being ready for it.
> >
> > Since there is no telling which module implements a hypervisor, scan the
> > module text and look for the VMLAUNCH instruction. If found, the module is
> > assumed to be a hypervisor of some sort and SLD is disabled.
> >
> > Hypervisors, which have been modified and are known to work correctly,
> > can add:
> >
> > MODULE_INFO(sld_safe, "Y");
> >
> > to explicitly tell the module loader they're good.
> >
> > NOTE: it is unfortunate that struct load_info is not available to the
> > arch module code, this means CONFIG_CPU_SUP_INTEL gunk is needed
> > in generic code.
> >
> > NOTE: while we can 'trivially' fix KVM, we're still stuck with stuff
> > like VMware and VirtualBox doing their own thing.
>
> This is just crazy. We have never cared about any out tree module, why
> would we care here where it creates a real complexity. Just fix KVM
> and ignore anything else.

It is absolutely bonkers, but at the same time we can extend this
infrastructure to scan for dubious code patterns we don't want to
support. Like for instance direct manipulation of CR4.

Look at is as another layer to enforce sanity on binary only modules.

Do we want to go that way, and do you know of other code patterns you'd
want to fail module loading for?