File tree Expand file tree Collapse file tree 5 files changed +12
-14
lines changed Expand file tree Collapse file tree 5 files changed +12
-14
lines changed Original file line number Diff line number Diff line change 4
4
5
5
#ifdef __ASSEMBLY__
6
6
7
+ #include <asm/asm-offsets.h>
8
+
7
9
#ifdef CONFIG_SHADOW_CALL_STACK
8
10
.macro scs_load tsk , tmp
9
- ldp x18 , \tmp , [\tsk , #TSK_TI_SCS_BASE ]
10
- add x18 , x18 , \tmp
11
+ ldr x18 , [\tsk , #TSK_TI_SCS_SP ]
11
12
.endm
12
13
13
14
.macro scs_save tsk , tmp
14
- ldr \tmp , [\tsk , #TSK_TI_SCS_BASE ]
15
- sub \tmp , x18 , \tmp
16
- str \tmp , [\tsk , #TSK_TI_SCS_OFFSET ]
15
+ str x18 , [\tsk , #TSK_TI_SCS_SP ]
17
16
.endm
18
17
#else
19
18
.macro scs_load tsk , tmp
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ struct thread_info {
43
43
};
44
44
#ifdef CONFIG_SHADOW_CALL_STACK
45
45
void * scs_base ;
46
- unsigned long scs_offset ;
46
+ void * scs_sp ;
47
47
#endif
48
48
};
49
49
@@ -107,7 +107,7 @@ void arch_release_task_struct(struct task_struct *tsk);
107
107
#ifdef CONFIG_SHADOW_CALL_STACK
108
108
#define INIT_SCS \
109
109
.scs_base = init_shadow_call_stack, \
110
- .scs_offset = 0 ,
110
+ .scs_sp = init_shadow_call_stack ,
111
111
#else
112
112
#define INIT_SCS
113
113
#endif
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ int main(void)
36
36
#endif
37
37
#ifdef CONFIG_SHADOW_CALL_STACK
38
38
DEFINE (TSK_TI_SCS_BASE , offsetof(struct task_struct , thread_info .scs_base ));
39
- DEFINE (TSK_TI_SCS_OFFSET , offsetof(struct task_struct , thread_info .scs_offset ));
39
+ DEFINE (TSK_TI_SCS_SP , offsetof(struct task_struct , thread_info .scs_sp ));
40
40
#endif
41
41
DEFINE (TSK_STACK , offsetof(struct task_struct , stack ));
42
42
#ifdef CONFIG_STACKPROTECTOR
Original file line number Diff line number Diff line change 27
27
#define SCS_END_MAGIC (0x5f6UL + POISON_POINTER_DELTA)
28
28
29
29
#define task_scs (tsk ) (task_thread_info(tsk)->scs_base)
30
- #define task_scs_offset (tsk ) (task_thread_info(tsk)->scs_offset )
30
+ #define task_scs_sp (tsk ) (task_thread_info(tsk)->scs_sp )
31
31
32
32
void scs_init (void );
33
33
int scs_prepare (struct task_struct * tsk , int node );
@@ -39,7 +39,7 @@ static inline void scs_task_reset(struct task_struct *tsk)
39
39
* Reset the shadow stack to the base address in case the task
40
40
* is reused.
41
41
*/
42
- task_scs_offset (tsk ) = 0 ;
42
+ task_scs_sp (tsk ) = task_scs ( tsk ) ;
43
43
}
44
44
45
45
static inline unsigned long * __scs_magic (void * s )
@@ -50,9 +50,9 @@ static inline unsigned long *__scs_magic(void *s)
50
50
static inline bool scs_corrupted (struct task_struct * tsk )
51
51
{
52
52
unsigned long * magic = __scs_magic (task_scs (tsk ));
53
+ unsigned long sz = task_scs_sp (tsk ) - task_scs (tsk );
53
54
54
- return (task_scs_offset (tsk ) >= SCS_SIZE - 1 ||
55
- READ_ONCE_NOCHECK (* magic ) != SCS_END_MAGIC );
55
+ return sz >= SCS_SIZE - 1 || READ_ONCE_NOCHECK (* magic ) != SCS_END_MAGIC ;
56
56
}
57
57
58
58
#else /* CONFIG_SHADOW_CALL_STACK */
Original file line number Diff line number Diff line change @@ -60,8 +60,7 @@ int scs_prepare(struct task_struct *tsk, int node)
60
60
if (!s )
61
61
return - ENOMEM ;
62
62
63
- task_scs (tsk ) = s ;
64
- task_scs_offset (tsk ) = 0 ;
63
+ task_scs (tsk ) = task_scs_sp (tsk ) = s ;
65
64
scs_account (tsk , 1 );
66
65
return 0 ;
67
66
}
You can’t perform that action at this time.
0 commit comments