-
Notifications
You must be signed in to change notification settings - Fork 287
securitypolicy: Add enforcement point for blockdev mounts #2762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
micromaomao
wants to merge
13
commits into
microsoft:main
Choose a base branch
from
micromaomao:tingmao_github/blockdev-enforcement
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,045
−176
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a2f0523
Merged PR 12878455: Fix for the Rego "metadata desync" bug
micromaomao 72f2a51
Allow unrecoverable_error.go to build on Windows and fix IsSNP() invo…
micromaomao 9339726
Merged PR 12878148: bridge: Force sequential message handling for con…
micromaomao 07ad5d5
Fix usage of IsSNP() to handle the new error return value
micromaomao 02803cc
Merged PR 13618357: guest/network: Restrict hostname to valid characters
micromaomao 75b150b
Merged PR 12878779: Enhance uvm_state::hostMounts to track in-use mou…
micromaomao 977373d
Merged PR 13627088: guest: Don't allow host to set mount options
micromaomao d3dc733
Merged PR 13694574: hcsv2/uvm, rego: Enforce OCI spec does not contai…
micromaomao e4effb9
pkg/securitypolicy: Trim whitespaces from version_{api,framework} to …
micromaomao 7615910
Merge branch 'tingmao_github/merge-msrc-to-main' into HEAD
micromaomao 0799b39
Merge branch 'version-trim-ws' into HEAD
micromaomao 1eb357f
---------------------------------------------
micromaomao a8e3216
securitypolicy: Add enforcement point for blockdev mounts
micromaomao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,53 @@ | ||
| package gcs | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "os" | ||
| "runtime" | ||
| "time" | ||
|
|
||
| "github.com/Microsoft/hcsshim/internal/log" | ||
| "github.com/Microsoft/hcsshim/pkg/amdsevsnp" | ||
| "github.com/sirupsen/logrus" | ||
| ) | ||
|
|
||
| // UnrecoverableError logs the error and then puts the current thread into an | ||
| // infinite sleep loop. This is to be used instead of panicking, as the | ||
| // behaviour of GCS panics is unpredictable. This function can be extended to, | ||
| // for example, try to shutdown the VM cleanly. | ||
| func UnrecoverableError(err error) { | ||
| buf := make([]byte, 300*(1<<10)) | ||
| stackSize := runtime.Stack(buf, true) | ||
| stackTrace := string(buf[:stackSize]) | ||
|
|
||
| errPrint := fmt.Sprintf( | ||
| "Unrecoverable error in GCS: %v\n%s", | ||
| err, stackTrace, | ||
| ) | ||
|
|
||
| isSnp, err := amdsevsnp.IsSNP() | ||
| if err != nil { | ||
| // IsSNP() cannot fail on LCOW | ||
| // but if it does, we proceed as if we're on SNP to be safe. | ||
| isSnp = true | ||
| } | ||
|
|
||
| if isSnp { | ||
| errPrint += "\nThis thread will now enter an infinite loop." | ||
| } | ||
| log.G(context.Background()).WithError(err).Logf( | ||
| logrus.FatalLevel, | ||
| "%s", | ||
| errPrint, | ||
| ) | ||
|
|
||
| if !isSnp { | ||
| panic("Unrecoverable error in GCS: " + err.Error()) | ||
| } else { | ||
| fmt.Fprintf(os.Stderr, "%s\n", errPrint) | ||
| for { | ||
| time.Sleep(time.Hour) | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are non SNP but enforcing policy we should also force sequential to keep the dev and real environments as similar as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately at this point if we're not in SNP, we do not yet know if we will have a policy or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could still set this value after getting the policy tho, will check