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 532933FD959; Fri, 15 May 2026 16:05:19 +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=1778861120; cv=none; b=OKBKC7LW16tqmyGo3Mwl6RcUdBIKt/mn930Tq/oijqfap6rAWV4402rgjF4IT9Z772uKBP5IT4gX0VyOBTNgBnaqPKn9jm8XuwZgFozCBTf4BKsXn0k/+q0Uw6um62jfVQHHOASzbTZYv+4WmaBDh82qDbXcYf++wMARTI226bQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778861120; c=relaxed/simple; bh=EuS59Tfu1N2FlwMBLMi4t4Ql8gDvotG9MdHc/9aZWag=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=f825y6gMrbk+lZJMZ2f400ezXuX+g8vWzStxx9rpkp9Wa92We5tWVDpK76YTq6EloZc74hhU208tJJTYoopzVSdfud7FlOYPCYCHQj/yHMwzJaYsfVwGXy3HzQQT/wgpxowU+LityUQNKSLZ6fQXZw5VAFrpdpYWS1JtLi1Odc0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=A+0uKi3Z; 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="A+0uKi3Z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DD13C2BCB0; Fri, 15 May 2026 16:05:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778861119; bh=EuS59Tfu1N2FlwMBLMi4t4Ql8gDvotG9MdHc/9aZWag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A+0uKi3ZmsgzECH33SAbfE7TeyBixp4dbAziFykW4tGAtmSrOtSs1+UTqASnre0Kc cLrMNjkZwRt2HXN32tb0C5DI27TG9ElZzby+GW6gRKdSKTGT7v8T4+SpXlrQJcIUAW 1h7OGulW/JEWdca8xDyacDgAyd8aKIdbulbuBdxU= 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.6 155/474] x86: shadow stacks: proper error handling for mmap lock Date: Fri, 15 May 2026 17:44:24 +0200 Message-ID: <20260515154718.380127249@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260515154715.053014143@linuxfoundation.org> References: <20260515154715.053014143@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-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 19e4db582fb69..d259d7d5b962f 100644 --- a/arch/x86/kernel/shstk.c +++ b/arch/x86/kernel/shstk.c @@ -311,7 +311,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 8d38dcb6d044c..153e018677909 100644 --- a/include/linux/mmap_lock.h +++ b/include/linux/mmap_lock.h @@ -116,7 +116,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; @@ -147,7 +147,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; @@ -157,7 +157,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