File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -16,11 +16,22 @@ use super::State;
16
16
17
17
#[ cfg( any( target_os = "linux" , target_os = "freebsd" ) ) ]
18
18
fn create_memfile ( ) -> File {
19
- use nix:: sys:: memfd:: { memfd_create, MemFdCreateFlag } ;
19
+ use nix:: {
20
+ fcntl:: { fcntl, FcntlArg , SealFlag } ,
21
+ sys:: memfd:: { memfd_create, MemFdCreateFlag } ,
22
+ } ;
20
23
21
24
let name = unsafe { CStr :: from_bytes_with_nul_unchecked ( "softbuffer\0 " . as_bytes ( ) ) } ;
22
- let fd = memfd_create ( name, MemFdCreateFlag :: MFD_CLOEXEC )
23
- . expect ( "Failed to create memfd to store buffer." ) ;
25
+ let fd = memfd_create (
26
+ name,
27
+ MemFdCreateFlag :: MFD_CLOEXEC | MemFdCreateFlag :: MFD_ALLOW_SEALING ,
28
+ )
29
+ . expect ( "Failed to create memfd to store buffer." ) ;
30
+ let _ = fcntl (
31
+ fd,
32
+ FcntlArg :: F_ADD_SEALS ( SealFlag :: F_SEAL_SHRINK | SealFlag :: F_SEAL_SEAL ) ,
33
+ )
34
+ . expect ( "Failed to seal memfd." ) ;
24
35
unsafe { File :: from_raw_fd ( fd) }
25
36
}
26
37
You can’t perform that action at this time.
0 commit comments