From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAF0633C192; Mon, 20 Apr 2026 15:48:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776700106; cv=none; b=EVlz93lifqNLtWbhLA4lheTHrVbcQufVIkgMvjnGEkTLBup+USrrDO/Dsk3kBv0p8Pi5G2Ta9Cq26EEyr6ZUjqHIFBfk4+aTwaI2HDsYXaVCIdeHVAHBaN8JHPvUsWMaOtEgCcxZ9qYpOEYtZQRLLwu7QoKSvaGTAwvxHC3GJng= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776700106; c=relaxed/simple; bh=ogMpkuXAyPgNbZ0sdwfto16QIIEqsd7bY+vHiPLnSoA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KIj31YC4tCTeEYZsoNUdUFerAyKmdR4VLpFdkuYBhlCkLTWCWgDtRrpyV6r0VRSeCqKXcevtOthnG5ixHXMpc8AMa2OHU1Krc7oD4iF+YS2lAGt7f1bHTFpIhXIoKhZMIQr60hdDJrddA20yJWp2pBbpAXXit+rfmU6IervJQd0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nbng3+KQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="nbng3+KQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DB56C19425; Mon, 20 Apr 2026 15:48:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776700106; bh=ogMpkuXAyPgNbZ0sdwfto16QIIEqsd7bY+vHiPLnSoA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nbng3+KQTLuTm/KlaD7wW3GKtHjIDNO8WiuGWiOw/7KKqiiZve4U416JOnxobKXpP uPhttff5FCL5GBJX66eo3rTXNAjBoui5c0ut2F3D1kGW32H1LJw61wekpNVB0/BloX 1gqKQgNP688IS7/p/mUNUBbf4dUoE13NCOj3av84= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?=EA=B9=80=EC=98=81=EB=AF=BC?= , Oleg Nesterov , Dave Hansen , Rick Edgecombe , Linus Torvalds , Sasha Levin Subject: [PATCH 6.19 045/220] x86: shadow stacks: proper error handling for mmap lock Date: Mon, 20 Apr 2026 17:39:46 +0200 Message-ID: <20260420153935.660146474@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260420153934.013228280@linuxfoundation.org> References: <20260420153934.013228280@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Linus Torvalds [ Upstream commit 52f657e34d7b21b47434d9d8b26fa7f6778b63a0 ] 김영민 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: 김영민 Acked-by: Oleg Nesterov Acked-by: Dave Hansen Acked-by: Rick Edgecombe Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- arch/x86/kernel/shstk.c | 3 ++- include/linux/mmap_lock.h | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/shstk.c b/arch/x86/kernel/shstk.c index 978232b6d48d7..ff8edea8511b4 100644 --- a/arch/x86/kernel/shstk.c +++ b/arch/x86/kernel/shstk.c @@ -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)) diff --git a/include/linux/mmap_lock.h b/include/linux/mmap_lock.h index d53f72dba7fee..81fcfde3563dd 100644 --- a/include/linux/mmap_lock.h +++ b/include/linux/mmap_lock.h @@ -345,7 +345,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; @@ -392,7 +392,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; @@ -402,7 +402,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; -- 2.53.0