Skip to content
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

Bitflags and unknown bits #3192

Open
stevenengler opened this issue Sep 28, 2023 · 0 comments
Open

Bitflags and unknown bits #3192

stevenengler opened this issue Sep 28, 2023 · 0 comments
Labels
Type: Enhancement New functionality or improved design

Comments

@stevenengler
Copy link
Contributor

stevenengler commented Sep 28, 2023

We use the bitflags library in Shadow. One of the larger use-cases is for representing syscall API flags. Since we don't control the values passed into syscall handlers, the application may have set bits that aren't represented where we define the type using the bitflags! macro.

It's unclear exactly how the bitflags library handles unknown bits. For example if you invert/negate a bitflags type, does it only flip the known bits, or all of the bits? In bitflags 2.3.3 there were changes to the ! operator, and it also introduced a const ALL = !0 flag to indicate that any bit pattern is valid. The bitflags author also introduced a specification document that supposedly explains the current behaviour. They have also indicated that the default behaviour may be changing in the future.

Since this is all confusing, we should figure out exactly what the current behaviour is, make sure our current code is behaving properly, and preferably make any changes needed so that it will continue to work in the future. This probably involves adding a const ALL = !0 to a bunch of types, especially around the syscall interface and in the "linux-api" library.

@stevenengler stevenengler added the Type: Enhancement New functionality or improved design label Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement New functionality or improved design
Projects
None yet
Development

No branches or pull requests

1 participant