From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 42F4E33507D for ; Mon, 4 May 2026 20:59:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777928342; cv=none; b=iac9tl9EP1x3ku6hj3W4M/swBc97LlXtegTt6fVnXNtH6QP73Ko2zE4lLFtqilgH2PJ0IKtueUzpj3b9xmnTPvFW2evi2cdD2A/EJsDK0eoHsUEkSYiyavvzXqXz9JSXuSoiciPjxnjSStw+7xBIbezfBIgIxl+NQVaCC1WUJL8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777928342; c=relaxed/simple; bh=zb/1UFKL+RAMdOzSbGbh89cM1XeOU9GBkUzFF3SezVw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=k9pZUomcRFMh7bbt6CZ9CZHN2/wWnVCFMuszeZt3Sr7bKCuuNvFSUPtVKaVbNaxtuSFvJVVan7eBXFIGrY2vMcbdoH48BQKcfnXqQzO4OiEq0C/CxmHbQumSiLqBMT9eGWWsChbCrjnoFStIMCHS546r6aXWXZeO3LkEYQqASno= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=WWQ0f2Wh; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WWQ0f2Wh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1777928341; x=1809464341; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=zb/1UFKL+RAMdOzSbGbh89cM1XeOU9GBkUzFF3SezVw=; b=WWQ0f2WhMw18LZ5t5+ITxzqi9e09r/dV9ZDjU3Q+zJqh8rBwz2axScHC Bv7j3y9JTCdAL+/mseqXZdvwSiQTR+P4O+zml3oaBt7Av08Gt4UfKuS2R OfSAGxgrD5G0QFQ3WSu7blRzbV77uPTNa/+K3MEyxvtu5MEpmXeoHqS7S A9DlpAPUuVChCAB1utMrCUfMWEdGAuCPuX8zaEpZZSJSOCNFunjZ51oSU AzQbue7FnuAWdFjGmbSN3mIKH3Tal07nR/d0PHLpvXMdbRKMGajXRMowY 9orzu4kOgyUBkrO5tQh1ZpoL8IoVRqqTUsRRvu3hWzVp5cn5iSFlrSYr2 w==; X-CSE-ConnectionGUID: EzQivUuaRzO9UaUAT2rJJA== X-CSE-MsgGUID: DZ0Dtg3pTSetgLeCLOsmnQ== X-IronPort-AV: E=McAfee;i="6800,10657,11776"; a="78891412" X-IronPort-AV: E=Sophos;i="6.23,216,1770624000"; d="scan'208";a="78891412" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2026 13:59:00 -0700 X-CSE-ConnectionGUID: poO50ANxRuqHtclN0jUOPA== X-CSE-MsgGUID: kAOTgSngQS20UK1KEFP9RQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,216,1770624000"; d="scan'208";a="234750759" Received: from rpedgeco-desk.jf.intel.com ([10.88.27.139]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2026 13:59:00 -0700 From: Rick Edgecombe To: stable@vger.kernel.org Cc: Linus Torvalds , =?UTF-8?q?=EA=B9=80=EC=98=81=EB=AF=BC?= , Oleg Nesterov , Dave Hansen , Rick Edgecombe , Sasha Levin Subject: [PATCH 6.12.y] x86: shadow stacks: proper error handling for mmap lock Date: Mon, 4 May 2026 13:58:56 -0700 Message-ID: <20260504205856.536296-1-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.54.0 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 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 Signed-off-by: Rick Edgecombe --- 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 059685612362d..0dc983b33b003 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 de9dc20b01ba7..004112f118eab 100644 --- a/include/linux/mmap_lock.h +++ b/include/linux/mmap_lock.h @@ -114,7 +114,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; @@ -145,7 +145,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; @@ -155,7 +155,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.54.0