File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -177,11 +177,24 @@ psm_stack_manipulation! {
177
177
old_stack_limit: get_stack_limit( ) ,
178
178
} ;
179
179
let above_guard_page = new_stack. add( page_size) ;
180
+ #[ cfg( not( target_os = "openbsd" ) ) ]
180
181
let result = libc:: mprotect(
181
182
above_guard_page,
182
183
stack_bytes - page_size,
183
184
libc:: PROT_READ | libc:: PROT_WRITE
184
185
) ;
186
+ #[ cfg( target_os = "openbsd" ) ]
187
+ let result = if libc:: mmap(
188
+ above_guard_page,
189
+ stack_bytes - page_size,
190
+ libc:: PROT_READ | libc:: PROT_WRITE ,
191
+ libc:: MAP_FIXED | libc:: MAP_PRIVATE | libc:: MAP_ANON | libc:: MAP_STACK ,
192
+ -1 ,
193
+ 0 ) == above_guard_page {
194
+ 0
195
+ } else {
196
+ -1
197
+ } ;
185
198
if result == -1 {
186
199
drop( guard) ;
187
200
panic!( "unable to set stack permissions" )
You can’t perform that action at this time.
0 commit comments