Skip to content

Commit c79cf42

Browse files
torvaldsgregkh
authored andcommitted
x86: shadow stacks: proper error handling for mmap lock
[ Upstream commit 52f657e ] 김영민 reports that shstk_pop_sigframe() doesn't check for errors from mmap_read_lock_killable(), which is a silly oversight, and also shows that we haven't marked those functions with "__must_check", which would have immediately caught it. So let's fix both issues. Reported-by: 김영민 <osori@hspace.io> Acked-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Dave Hansen <dave.hansen@intel.com> Acked-by: Rick Edgecombe <rick.p.edgecombe@intel.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 4a0bb8f commit c79cf42

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

arch/x86/kernel/shstk.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ static int shstk_pop_sigframe(unsigned long *ssp)
311311
need_to_check_vma = PAGE_ALIGN(*ssp) == *ssp;
312312

313313
if (need_to_check_vma)
314-
mmap_read_lock_killable(current->mm);
314+
if (mmap_read_lock_killable(current->mm))
315+
return -EINTR;
315316

316317
err = get_shstk_data(&token_addr, (unsigned long __user *)*ssp);
317318
if (unlikely(err))

include/linux/mmap_lock.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static inline void mmap_write_lock_nested(struct mm_struct *mm, int subclass)
116116
__mmap_lock_trace_acquire_returned(mm, true, true);
117117
}
118118

119-
static inline int mmap_write_lock_killable(struct mm_struct *mm)
119+
static inline int __must_check mmap_write_lock_killable(struct mm_struct *mm)
120120
{
121121
int ret;
122122

@@ -147,7 +147,7 @@ static inline void mmap_read_lock(struct mm_struct *mm)
147147
__mmap_lock_trace_acquire_returned(mm, false, true);
148148
}
149149

150-
static inline int mmap_read_lock_killable(struct mm_struct *mm)
150+
static inline int __must_check mmap_read_lock_killable(struct mm_struct *mm)
151151
{
152152
int ret;
153153

@@ -157,7 +157,7 @@ static inline int mmap_read_lock_killable(struct mm_struct *mm)
157157
return ret;
158158
}
159159

160-
static inline bool mmap_read_trylock(struct mm_struct *mm)
160+
static inline bool __must_check mmap_read_trylock(struct mm_struct *mm)
161161
{
162162
bool ret;
163163

0 commit comments

Comments
 (0)