From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 93E4F34250E; Sat, 12 Sep 2026 19:05:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789239938; cv=none; b=LVQr5KyiJkSBasv5bDzdzh/nU3uNmwUFHYH11gwtiQf12jyCdpLj9DUo6Zo/JD5sv6TUBz5kCXVApkWxTz8Yg/E+0kLMwUkx1X7EFdvVh0xuPn0poKAY3L2biCQbBZgylkkuoIR8nzvn+nrwKS7kkFfDo7+IiNAypEXEXzqajmc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789239938; c=relaxed/simple; bh=YuXYm35Kwvqw+J5n9TOfICtv+JxrTYAxHgMw0jwTiL4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z39HeGjcs9WYIwsHRIvxiN3rNBGh3Jn/G2i4dDC1rbOEf76vko4pOT8VbS7qbh0nsKTCLpB/3njUOd+wJDawb+IrcOZ0hR6GIbFzPAffyes747HhVxnn5m4tAQ/kSh13td7/uVQWzqze7U+l0ZQ9kjy3+v7DfOIl4RZpKujY1VE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HnLc3Gnf; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="HnLc3Gnf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B10EE1F000FF; Sat, 12 Sep 2026 19:05:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789239937; bh=gwA0XjlJW897Y3QIfWDsJwJfS8RySh5gRlnRhTE8fF8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HnLc3Gnf8RjyOb5Fcu3myvLd+azA+HeU2QaT42IK294izUuXh07oaD73dyA5QkRaQ L4rePIb9V9pDVrB8LCAC5t3WFg9g9X+gHL9ACaG64cR2BVNSIIyraaIdrrQUkjGO5l d9q3EEw1wWSLs2avAIqrgDTgiNdb5Wqu7VIQ8p30= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ada Couprie Diaz , Vladimir Murzin , Jinjie Ruan , Will Deacon , Sasha Levin Subject: [PATCH 5.15 723/935] arm64: hibernate: mask DAIF before restoring hibernated kernel Date: Sat, 12 Sep 2026 09:02:33 +0200 Message-ID: <20260912065543.416684086@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065526.833703348@linuxfoundation.org> References: <20260912065526.833703348@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-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ada Couprie Diaz [ Upstream commit 684bde100117931f4c51c644a95f42f2dab041bc ] The arm64 hibernate code manages the exception masking in an unsound way, leading to potential crashes and/or warnings during resume. When a hibernation image is saved in `swsusp_arch_suspend()`, all DAIF exceptions are masked (by virtue of `local_daif_save()`), and the suspended image is saved assuming that all DAIF exceptions will remain masked when the image is restored. When a hibernation image is resumed by `swsusp_arch_resume()`, only interrupts are masked (by virtue of `local_irq_disable()` in `resume_target_kernel()`). When pseudo-NMI is enabled the DAIF.IF bits will be clear, and regardless of pseudo-NMI the DAIF.DA bits will be clear. This means that there are two problems: (1) It is possible to take Debug, SError, or pseudo-NMI exceptions during the resume process. This is unsafe, as during the resume process both the old ane new kernels will tranisently be in an inconsistent state, and swsusp_arch_suspend_exit() won't retain an executable mapping of any exception vectors. Any exception taken here will be fatal and silent. (2) When re-entering the resumed kernel, some DAIF bits will be clear unexpectedly. This permits Debug, SError, or pseudo-NMI exceptions to be taken for a short period while the resumed kernel is not yet in a consistent state. This is detected by CONFIG_ARM64_DEBUG_PRIORITY_MASKING. Avoid these issues by masking all DAIF exceptions during resume. Fixes: 82869ac57b5d ("arm64: kernel: Add support for hibernate/suspend-to-disk") Signed-off-by: Ada Couprie Diaz Signed-off-by: Vladimir Murzin Reviewed-by: Jinjie Ruan Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/kernel/hibernate.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c index 579d3ec9240ed..4c7f97b7da1a4 100644 --- a/arch/arm64/kernel/hibernate.c +++ b/arch/arm64/kernel/hibernate.c @@ -494,9 +494,21 @@ int __nocfi swsusp_arch_resume(void) __hyp_set_vectors(el2_vectors); } + /* + * It is necessary to mask all DAIF exceptions here as: + * + * - The copy of swsusp_arch_suspend_exit() in the hibernation + * text cannot handle taking any exceptions. + * + * - The suspended kernel masked all DAIF exceptions in + * swsusp_arch_resume(), and expects to be re-entered in the + * same state : with all DAIF exceptions masked. + */ + local_daif_save(); hibernate_exit(virt_to_phys(tmp_pg_dir), resume_hdr.ttbr1_el1, resume_hdr.reenter_kernel, restore_pblist, resume_hdr.__hyp_stub_vectors, virt_to_phys(zero_page)); + unreachable(); return 0; } -- 2.53.0