Add DescriptorHandle and return Result from descriptor table methods #2691
Merged
stevenengler merged 2 commits intoshadow:mainfrom Jan 25, 2023
Merged
Add DescriptorHandle and return Result from descriptor table methods #2691stevenengler merged 2 commits intoshadow:mainfrom
DescriptorHandle and return Result from descriptor table methods #2691stevenengler merged 2 commits intoshadow:mainfrom
Conversation
Codecov ReportBase: 68.18% // Head: 67.50% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #2691 +/- ##
==========================================
- Coverage 68.18% 67.50% -0.69%
==========================================
Files 202 202
Lines 30326 30378 +52
Branches 5916 5935 +19
==========================================
- Hits 20678 20506 -172
- Misses 4969 5214 +245
+ Partials 4679 4658 -21
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
9857571 to
08545ed
Compare
DescriptorHandle and return results from descriptor table methods
DescriptorHandle and return results from descriptor table methods DescriptorHandle and return Result from descriptor table methods
sporksmith
approved these changes
Jan 24, 2023
sporksmith
approved these changes
Jan 25, 2023
0604cb8 to
1d0a585
Compare
There is a duplicate `DescriptorTable::register_descriptor_with_fd`, so use that instead.
The descriptor table shouldn't ever allow descriptors to be registered with a handle larger than `libc::c_int::MAX`. The old code also had a loop that could wrap around unexpectedly in release builds. The public API to `DescriptorTable` now uses `DescriptorHandle` objects. The `register_descriptor` and `register_descriptor_with_min_fd` methods also now return results if the descriptor could not be added.
1d0a585 to
e4e847f
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The descriptor table shouldn't ever allow descriptors to be registered with a handle larger than
libc::c_int::MAX. The old code also had a loop that could wrap around unexpectedly in release builds.While the libc API uses
intvalues for file handles, the Linux syscall API usesunsigned intfor file handles. This means that when you pass a file handle of -1 to aclose()call for example, Linux will see this as 4,294,967,295. If we read file handles in Shadow's syscall handlers aslibc::c_uintvalues, we run into problems in these edge cases (for example withdup2(fd, -1)). We can continue reading them as signed integers and casting them to unsigned for now, but I think it's nicer to force us to handle these edge cases.The public API to
DescriptorTablenow usesDescriptorHandleobjects. Theregister_descriptorandregister_descriptor_with_min_fdmethods also now return results if the descriptor could not be added.