Commit Graph
7 Commits
Author SHA1 Message Date
Dario Faggioli e1a2cae2c0 L1TF/Linux: detect SMT via sysfs
We can figure out whether SMT is enabled or not, by checking the
topology of the CPUs, as it is exposed in /sys.

This means the information is available also when we are running
in `--sysfs-only` mode.
2019-04-19 16:11:05 +02:00
Dario Faggioli 26a5fe018a L1TF/Linux: fix Mitigtion 2 against --sysfs options
Info about 2nd mitigation to L1TF are gathered in various ways.

Some are available under /sys, and hence should be checked when
we're invoked without parameters, and with `--sysfs-only`, while
they should be ignored when we are invoked with `--no-sysfs`.

Some others use other sources, and hence should be ignored if
we are invoked with `--sysfs-only`.
2019-04-19 16:09:06 +02:00
Dario Faggioli 5e35f0a711 L1TF/Linux: fix EPT on/off detection against sysfs
Checking whether or not EPT is enabled, happens via /sys.

We should therefore also make sure that we do that when being
invoked with no options, and with `--sysfs-only`, and that we
don't when invoked with `--no-sysfs`.
2019-04-19 16:07:26 +02:00
Dario Faggioli 0421aea53f L1TF/Linux: More fixes to /sys based hypervisor detection
We are now able to figure out whether or not we are running an hypervisor
(at least potentially) via /sys, so let's actually use that information.

This commit makes sure that, both when running with no options and with
`--sysfs-only`, finding 'VMX' inside the L1TF sysfs vulnerability file
is enough for calling the system a virtualization host.
2019-04-19 16:05:20 +02:00
Dario Faggioli e819a27939 L1TF/Linux: detect "running an hypervisor" via lsmod
If the 'kvm_intel' module is loaded, this host can run VMs, and is
hence potentially L1TF-vulnerable.
2019-04-19 16:04:52 +02:00
Dario Faggioli 5e83e2cfa4 L1TF/Linux: Fix "running an hypervisor" detection via sysfs
If we can look in `/sys/devices/system/cpu/vulnerabilities/l1tf`, and
we find 'VMX' in it, it means we can run KVM guests, and hence we are
running as an hypervisor.

Right now, on a system with VMX enabled, with KVM guests running, and
booted with "l1tf=off", I see this:
`
  CVE-2018-3646 aka 'Foreshadow-NG (VMM), L1 terminal fault'
  * Information from the /sys interface: VMX: vulnerable
  * This system is a host running a hypervisor:  NO
  ... ... ...
    * L1D flush enabled:  NO
  > STATUS:  NOT VULNERABLE  (this system is not running a hypervisor)
`
Which is wrong.

In fact, as said, guests are running, so we are an hypervisor,
and with "l1tf=off" (and hence L1D flush disabled) we are vulnerable.
2019-04-18 18:59:03 +02:00
Dario Faggioli 2cfae92cb0 L1TF/Linux: remove dead code, fix --sysfs-only bug
We don't use $msg and $status.

Also, by always initializing l1d_mode, we fix the following "crash",
when running with `--sysfs-only`:
`
  CVE-2018-3646 aka 'Foreshadow-NG (VMM), L1 terminal fault'
  * Information from the /sys interface: VMX: vulnerable
  ./spectre-meltdown-checker.sh: line 3945: [: : integer expression expected
`
2019-04-18 18:08:22 +02:00