x86-64: switch order of user code and data segments for syscall instruction

This commit is contained in:
Matheus
2023-05-07 17:46:26 -03:00
parent 42b28716a4
commit 9c1e92831d
4 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ arch_context_switch:
add rsp,8 ; remove error code
; check if swapgs is needed
cmp qword [rsp+8], 0x18
cmp qword [rsp+8], 0x23
jne .notneeded2
swapgs
.notneeded2:
+2 -2
View File
@@ -9,8 +9,8 @@ static uint64_t template[7] = {
0, // NULL 0x0
0x00af9b000000ffff, // code64 0x8
0x00af93000000ffff, // data64 0x10
0x00affb000000ffff, // ucode64 0x18
0x00aff3000000ffff, // udata64 0x20
0x00aff3000000ffff, // udata64 0x18
0x00affb000000ffff, // ucode64 0x20
0x0020890000000000, // low ist 0x28
0x0000000000000000 // high ist
};
+2 -2
View File
@@ -9,7 +9,7 @@ isr_%+ i:
; check if swapgs is needed
cmp qword [rsp+16], 0x18
cmp qword [rsp+16], 0x23
jne .notneeded1
swapgs
.notneeded1:
@@ -73,7 +73,7 @@ isr_%+ i:
add rsp,8 ; remove error code
; check if swapgs is needed
cmp qword [rsp+8], 0x18
cmp qword [rsp+8], 0x23
jne .notneeded2
swapgs
.notneeded2:
+2 -2
View File
@@ -44,8 +44,8 @@ typedef struct {
#define CTX_INIT(x,u) \
if (u) { \
(x)->cs = 0x1b; \
(x)->ds = (x)->es = (x)->ss = 0x23; \
(x)->cs = 0x23; \
(x)->ds = (x)->es = (x)->ss = 0x1b; \
} else { \
(x)->cs = 0x8; \
(x)->ds = (x)->es = (x)->ss = 0x10; \