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! {
177177 old_stack_limit: get_stack_limit( ) ,
178178 } ;
179179 let above_guard_page = new_stack. add( page_size) ;
180+ #[ cfg( not( target_os = "openbsd" ) ) ]
180181 let result = libc:: mprotect(
181182 above_guard_page,
182183 stack_bytes - page_size,
183184 libc:: PROT_READ | libc:: PROT_WRITE
184185 ) ;
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+ } ;
185198 if result == -1 {
186199 drop( guard) ;
187200 panic!( "unable to set stack permissions" )
You can’t perform that action at this time.
0 commit comments