Skip to content

Commit 30de14b

Browse files
svens-s390hcahca
authored andcommitted
s390: current_stack_pointer shouldn't be a function
s390 defines current_stack_pointer as function while all other architectures use 'register unsigned long asm("<stackptr reg>"). This make codes like the following from check_stack_object() fail: if (IS_ENABLED(CONFIG_STACK_GROWSUP)) { if ((void *)current_stack_pointer < obj + len) return BAD_STACK; } else { if (obj < (void *)current_stack_pointer) return BAD_STACK; } because this would compare the address of current_stack_pointer() and not the stackpointer value. Reported-by: Karsten Graul <kgraul@linux.ibm.com> Fixes: 2792d84 ("usercopy: Check valid lifetime via stack depth") Cc: Kees Cook <keescook@chromium.org> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Sven Schnelle <svens@linux.ibm.com> Reviewed-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
1 parent a25d588 commit 30de14b

4 files changed

Lines changed: 4 additions & 10 deletions

File tree

arch/s390/include/asm/entry-common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,
5858

5959
static inline bool on_thread_stack(void)
6060
{
61-
return !(((unsigned long)(current->stack) ^ current_stack_pointer()) & ~(THREAD_SIZE - 1));
61+
return !(((unsigned long)(current->stack) ^ current_stack_pointer) & ~(THREAD_SIZE - 1));
6262
}
6363

6464
#endif

arch/s390/include/asm/processor.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,7 @@ unsigned long __get_wchan(struct task_struct *p);
200200
/* Has task runtime instrumentation enabled ? */
201201
#define is_ri_task(tsk) (!!(tsk)->thread.ri_cb)
202202

203-
static __always_inline unsigned long current_stack_pointer(void)
204-
{
205-
unsigned long sp;
206-
207-
asm volatile("la %0,0(15)" : "=a" (sp));
208-
return sp;
209-
}
203+
register unsigned long current_stack_pointer asm("r15");
210204

211205
static __always_inline unsigned short stap(void)
212206
{

arch/s390/include/asm/stacktrace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct stack_frame {
4646
};
4747

4848
/*
49-
* Unlike current_stack_pointer() which simply returns current value of %r15
49+
* Unlike current_stack_pointer which simply contains the current value of %r15
5050
* current_frame_address() returns function stack frame address, which matches
5151
* %r15 upon function invocation. It may differ from %r15 later if function
5252
* allocates stack for local variables or new stack frame to call other

arch/s390/lib/test_unwind.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static __always_inline struct pt_regs fake_pt_regs(void)
147147
struct pt_regs regs;
148148

149149
memset(&regs, 0, sizeof(regs));
150-
regs.gprs[15] = current_stack_pointer();
150+
regs.gprs[15] = current_stack_pointer;
151151

152152
asm volatile(
153153
"basr %[psw_addr],0\n"

0 commit comments

Comments
 (0)