-
Notifications
You must be signed in to change notification settings - Fork 0
Verify sandbox state on the execution thread #22
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
Open
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| kind: Fixed | ||
| body: Verify application sandbox capabilities on the exact Linux thread that will launch the workload. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| //go:build linux | ||
|
|
||
| package probe | ||
|
|
||
| import ( | ||
| "os" | ||
| "runtime" | ||
| "strconv" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "golang.org/x/sys/unix" | ||
| ) | ||
|
|
||
| func TestReadApplicationKernelStatusUsesCallingThread(t *testing.T) { | ||
| type result struct { | ||
| tid int | ||
| content []byte | ||
| err error | ||
| } | ||
| results := make(chan result, 2) | ||
| release := make(chan struct{}) | ||
| done := make(chan struct{}, 2) | ||
| defer func() { | ||
| close(release) | ||
| for range 2 { | ||
| <-done | ||
| } | ||
| }() | ||
| for range 2 { | ||
| go func() { | ||
| runtime.LockOSThread() | ||
| defer runtime.UnlockOSThread() | ||
| defer func() { done <- struct{}{} }() | ||
| content, err := readApplicationKernelStatus() | ||
| results <- result{tid: unix.Gettid(), content: content, err: err} | ||
| <-release | ||
| }() | ||
| } | ||
|
|
||
| observedNonLeader := false | ||
| for range 2 { | ||
| result := <-results | ||
| if result.err != nil { | ||
| t.Fatal(result.err) | ||
| } | ||
| if result.tid != os.Getpid() { | ||
| observedNonLeader = true | ||
| } | ||
| var statusPID string | ||
| for _, line := range strings.Split(string(result.content), "\n") { | ||
| name, raw, found := strings.Cut(line, ":") | ||
| if found && name == "Pid" { | ||
| fields := strings.Fields(raw) | ||
| if len(fields) == 1 { | ||
| statusPID = fields[0] | ||
| } | ||
| break | ||
| } | ||
| } | ||
| if statusPID != strconv.Itoa(result.tid) { | ||
| t.Fatalf("status Pid = %q, want calling thread %d", statusPID, result.tid) | ||
| } | ||
| } | ||
| if !observedNonLeader { | ||
| t.Fatal("test did not observe a non-leader OS thread") | ||
| } | ||
| } |
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.
On Linux kernels before 3.17,
/proc/thread-selfdoes not exist, so every sandboxed persistent or transient workload now fails closed while reading this path instead of launching. The repository supports Linux Docker Engine without declaring a newer kernel floor, and the previous/proc/self/statuspath worked on these systems; use the current TID via/proc/self/task/<tid>/statusas a compatibility fallback while retaining thread-local verification.Useful? React with 👍 / 👎.