]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86: shadow stacks: proper error handling for mmap lock
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 8 Apr 2026 20:18:57 +0000 (13:18 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 8 Apr 2026 20:18:57 +0000 (13:18 -0700)
김영민 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>
arch/x86/kernel/shstk.c
include/linux/mmap_lock.h

index 978232b6d48d76b166cdd4ea96b19ef67fdff4ed..ff8edea8511b4849aa620e007b9d15577ceb207f 100644 (file)
@@ -351,7 +351,8 @@ static int shstk_pop_sigframe(unsigned long *ssp)
        need_to_check_vma = PAGE_ALIGN(*ssp) == *ssp;
 
        if (need_to_check_vma)
-               mmap_read_lock_killable(current->mm);
+               if (mmap_read_lock_killable(current->mm))
+                       return -EINTR;
 
        err = get_shstk_data(&token_addr, (unsigned long __user *)*ssp);
        if (unlikely(err))
index 93eca48bc443ab77a8260a32f7949cad4326d31b..04b8f61ece5d8e6216f9b66d00dbb5a57a123c2e 100644 (file)
@@ -546,7 +546,7 @@ static inline void mmap_write_lock_nested(struct mm_struct *mm, int subclass)
        __mmap_lock_trace_acquire_returned(mm, true, true);
 }
 
-static inline int mmap_write_lock_killable(struct mm_struct *mm)
+static inline int __must_check mmap_write_lock_killable(struct mm_struct *mm)
 {
        int ret;
 
@@ -593,7 +593,7 @@ static inline void mmap_read_lock(struct mm_struct *mm)
        __mmap_lock_trace_acquire_returned(mm, false, true);
 }
 
-static inline int mmap_read_lock_killable(struct mm_struct *mm)
+static inline int __must_check mmap_read_lock_killable(struct mm_struct *mm)
 {
        int ret;
 
@@ -603,7 +603,7 @@ static inline int mmap_read_lock_killable(struct mm_struct *mm)
        return ret;
 }
 
-static inline bool mmap_read_trylock(struct mm_struct *mm)
+static inline bool __must_check mmap_read_trylock(struct mm_struct *mm)
 {
        bool ret;