Skip to content

Commit 7f1385f

Browse files
authored
Merge pull request #62 from kawasin73/ioctlflags
Make IoctlFlags robust to unknown flags
2 parents 9f1631b + afdc3c1 commit 7f1385f

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "userfaultfd"
3-
version = "0.7.0"
3+
version = "0.8.0"
44
authors = ["The Wasmtime Project Developers"]
55
edition = "2018"
66
license = "MIT OR Apache-2.0"

src/builder.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ impl UffdBuilder {
187187
unsafe {
188188
raw::api(uffd.fd, &mut api as *mut raw::uffdio_api)?;
189189
}
190-
let supported =
191-
IoctlFlags::from_bits(api.ioctls).ok_or(Error::UnrecognizedIoctls(api.ioctls))?;
190+
let supported = IoctlFlags::from_bits_retain(api.ioctls);
192191
if !supported.contains(self.req_ioctls) {
193192
Err(Error::UnsupportedIoctls(supported))
194193
} else {

src/error.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ pub enum Error {
3838
#[error("Unrecognized event in uffd_msg: {0}")]
3939
UnrecognizedEvent(u8),
4040

41-
/// An unrecognized ioctl bit was set in the result of API initialization or registration.
42-
#[error("Unrecognized ioctl flags: {0}")]
43-
UnrecognizedIoctls(u64),
44-
4541
/// Requested ioctls were not available when initializing the API.
4642
#[error("Requested ioctls unsupported; supported: {0:?}")]
4743
UnsupportedIoctls(IoctlFlags),

src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl Uffd {
118118
unsafe {
119119
raw::register(self.as_raw_fd(), &mut register as *mut raw::uffdio_register)?;
120120
}
121-
IoctlFlags::from_bits(register.ioctls).ok_or(Error::UnrecognizedIoctls(register.ioctls))
121+
Ok(IoctlFlags::from_bits_retain(register.ioctls))
122122
}
123123

124124
/// Unregister a memory address range from the userfaultfd object.
@@ -377,6 +377,9 @@ bitflags! {
377377
#[cfg(feature = "linux5_7")]
378378
const WRITE_PROTECT = 1 << raw::_UFFDIO_WRITEPROTECT;
379379
const API = 1 << raw::_UFFDIO_API;
380+
381+
/// Unknown ioctls flags are allowed to be robust to future kernel changes.
382+
const _ = !0;
380383
}
381384
}
382385

0 commit comments

Comments
 (0)