File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 1+ ### Unreleased
2+
3+ - Fallback to ` userfaultfd ` syscall when opening ` /dev/userfaultfd ` fails due to permissions
4+
15### 0.9.0
26
37- Add support for ` UFFDIO_CONTINUE ` and ` UFFDIO_REGISTER_MODE_MINOR ` under the new ` linux5_13 ` feature.
Original file line number Diff line number Diff line change @@ -147,17 +147,23 @@ impl UffdBuilder {
147147 // fall back to calling the system call.
148148 fn open_file_descriptor ( & self , flags : i32 ) -> Result < Uffd > {
149149 // If `/dev/userfaultfd` exists we'll try to get the file descriptor from it. If the file
150- // doesn't exist we will fall back to calling the system call. This means, that if the
151- // device exists but the calling process does not have access rights to it, this will fail,
152- // i.e. we will not fall back to calling the system call.
150+ // doesn't exist or we don't have the permissions to open it, we will fall back to calling
151+ // the system call. This means, that if the device exists but the calling process does not
152+ // have access rights to it, this will fail, i.e. we will not fall back to calling the
153+ // system call.
153154 match OpenOptions :: new ( )
154155 . read ( true )
155156 . write ( true )
156157 . open ( UFFD_DEVICE_PATH )
157158 {
158159 Ok ( mut file) => self . uffd_from_dev ( & mut file, flags) ,
159- Err ( err) if err. kind ( ) == ErrorKind :: NotFound => self . uffd_from_syscall ( flags) ,
160- Err ( err) => Err ( Error :: OpenDevUserfaultfd ( err) ) ,
160+ Err ( err) => {
161+ if let ErrorKind :: NotFound | ErrorKind :: PermissionDenied = err. kind ( ) {
162+ self . uffd_from_syscall ( flags)
163+ } else {
164+ Err ( Error :: OpenDevUserfaultfd ( err) )
165+ }
166+ }
161167 }
162168 }
163169
You can’t perform that action at this time.
0 commit comments