mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Only detect mds for mitigate.
Only detect and mitigate on mds for the mitigate command. PiperOrigin-RevId: 358924466
This commit is contained in:
committed by
gVisor bot
parent
34e2cda9ad
commit
24ea8003a4
+7
-27
@@ -23,15 +23,10 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// constants of coomm
|
||||
meltdown = "cpu_meltdown"
|
||||
l1tf = "l1tf"
|
||||
mds = "mds"
|
||||
swapgs = "swapgs"
|
||||
taa = "taa"
|
||||
)
|
||||
// mds is the only bug we care about.
|
||||
mds = "mds"
|
||||
|
||||
const (
|
||||
// Constants for parsing /proc/cpuinfo.
|
||||
processorKey = "processor"
|
||||
vendorIDKey = "vendor_id"
|
||||
cpuFamilyKey = "cpu family"
|
||||
@@ -39,9 +34,8 @@ const (
|
||||
physicalIDKey = "physical id"
|
||||
coreIDKey = "core id"
|
||||
bugsKey = "bugs"
|
||||
)
|
||||
|
||||
const (
|
||||
// Path to shutdown a CPU.
|
||||
cpuOnlineTemplate = "/sys/devices/system/cpu/cpu%d/online"
|
||||
)
|
||||
|
||||
@@ -249,24 +243,10 @@ func (t *thread) shutdown() error {
|
||||
return ioutil.WriteFile(cpuPath, []byte{'0'}, 0644)
|
||||
}
|
||||
|
||||
// List of pertinent side channel vulnerablilites.
|
||||
// For mds, see: https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/mds.html.
|
||||
var vulnerabilities = []string{
|
||||
meltdown,
|
||||
l1tf,
|
||||
mds,
|
||||
swapgs,
|
||||
taa,
|
||||
}
|
||||
|
||||
// isVulnerable checks if a CPU is vulnerable to pertinent bugs.
|
||||
// isVulnerable checks if a CPU is vulnerable to mds.
|
||||
func (t *thread) isVulnerable() bool {
|
||||
for _, bug := range vulnerabilities {
|
||||
if _, ok := t.bugs[bug]; ok {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
_, ok := t.bugs[mds]
|
||||
return ok
|
||||
}
|
||||
|
||||
// isActive checks if a CPU is active from /sys/devices/system/cpu/cpu{N}/online
|
||||
|
||||
@@ -36,11 +36,7 @@ type Mitigate struct {
|
||||
func (m Mitigate) Usage() string {
|
||||
usageString := `mitigate [flags]
|
||||
|
||||
This command mitigates an underlying system against side channel attacks.
|
||||
The command checks /proc/cpuinfo for cpus having key vulnerablilities (meltdown,
|
||||
l1tf, mds, swapgs, taa). If cpus are found to have one of the vulnerabilities,
|
||||
all but one cpu is shutdown on each core via
|
||||
/sys/devices/system/cpu/cpu{N}/online.
|
||||
Mitigate mitigates a system to the "MDS" vulnerability by implementing a manual shutdown of SMT. The command checks /proc/cpuinfo for cpus having the MDS vulnerability, and if found, shutdown all but one CPU per hyperthread pair via /sys/devices/system/cpu/cpu{N}/online. CPUs can be restored by writing "2" to each file in /sys/devices/system/cpu/cpu{N}/online or performing a system reboot.
|
||||
`
|
||||
return usageString + m.other.usage()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user