-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pr feedback: internal/guest/linux package, Makefile, refactor
Add new internal/guest/linux package, which for now includes linux specific ioctl definitions and Ioctl call. Refactor devicemapper to use the new package. Update makefile to conditionally include snp-report binary in initrd Signed-off-by: Maksim An <[email protected]>
- Loading branch information
Showing
12 changed files
with
102 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
internal/guest/snp/fake_report.go → internal/guest/amdsev/fake_report.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
//go:build linux | ||
// +build linux | ||
|
||
package snp | ||
package amdsev | ||
|
||
import ( | ||
"bytes" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//go:build linux | ||
// +build linux | ||
|
||
package linux | ||
|
||
import ( | ||
"os" | ||
|
||
"golang.org/x/sys/unix" | ||
) | ||
|
||
const ( | ||
IocWrite = 1 | ||
IocRead = 2 | ||
IocNRBits = 8 | ||
IocTypeBits = 8 | ||
IocSizeBits = 14 | ||
IocDirBits = 2 | ||
|
||
IocNRMask = (1 << IocNRBits) - 1 | ||
IocTypeMask = (1 << IocTypeBits) - 1 | ||
IocSizeMask = (1 << IocSizeBits) - 1 | ||
IocDirMask = (1 << IocDirBits) - 1 | ||
IocTypeShift = IocNRBits | ||
IocSizeShift = IocTypeShift + IocTypeBits | ||
IocDirShift = IocSizeShift + IocSizeBits | ||
IocWRBase = (IocRead | IocWrite) << IocDirShift | ||
) | ||
|
||
func Ioctl(f *os.File, code int, payloadPtr uintptr) error { | ||
_, _, errno := unix.Syscall(unix.SYS_IOCTL, f.Fd(), uintptr(code), payloadPtr) | ||
if errno != 0 { | ||
return errno | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//go:build linux | ||
// +build linux | ||
|
||
package hcsv2 | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/Microsoft/hcsshim/internal/guest/amdsev" | ||
) | ||
|
||
// ValidateHostData fetches SNP report (if applicable) and validates `hostData` against | ||
// HostData set at UVM launch. | ||
func ValidateHostData(hostData, reportData string) error { | ||
report, err := amdsev.FetchParsedSNPReport(reportData) | ||
if err != nil { | ||
// For non-SNP hardware /dev/sev will not exist | ||
if os.IsNotExist(err) { | ||
return nil | ||
} | ||
return err | ||
} | ||
|
||
if report.HostData != hostData { | ||
return fmt.Errorf( | ||
"security policy digest %q doesn't match HostData provided at launch %q", | ||
hostData, | ||
report.HostData, | ||
) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 3 additions & 2 deletions
5
test/vendor/github.com/Microsoft/hcsshim/pkg/securitypolicy/securitypolicy.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.