git: f9984cda9609 - stable/14 - arm unwind: Reject unaligned stack pointers

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 11 Oct 2023 15:44:22 UTC
The branch stable/14 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=f9984cda960915c594a777d6423804bcaa0fab4e

commit f9984cda960915c594a777d6423804bcaa0fab4e
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-08-25 19:00:37 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-10-11 15:10:31 +0000

    arm unwind: Reject unaligned stack pointers
    
    Reviewed by:    andrew
    Differential Revision:  https://reviews.freebsd.org/D41533
    
    (cherry picked from commit 247e8662d2c080c27937ec4d62e80b2358e8c74f)
---
 sys/arm/arm/unwind.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sys/arm/arm/unwind.c b/sys/arm/arm/unwind.c
index cdc9ef225ee7..591bae3dfc26 100644
--- a/sys/arm/arm/unwind.c
+++ b/sys/arm/arm/unwind.c
@@ -398,6 +398,9 @@ unwind_exec_insn(struct unwind_state *state)
 		if (mask == 0)
 			return 1;
 
+		if (!__is_aligned(vsp, sizeof(register_t)))
+			return 1;
+
 		/* Update SP */
 		update_vsp = 1;
 
@@ -430,6 +433,9 @@ unwind_exec_insn(struct unwind_state *state)
 		/* Read how many registers to load */
 		count = insn & INSN_POP_COUNT_MASK;
 
+		if (!__is_aligned(vsp, sizeof(register_t)))
+			return 1;
+
 		/* Update sp */
 		update_vsp = 1;
 
@@ -460,6 +466,9 @@ unwind_exec_insn(struct unwind_state *state)
 		if (mask == 0 || (mask & 0xf0) != 0)
 			return 1;
 
+		if (!__is_aligned(vsp, sizeof(register_t)))
+			return 1;
+
 		/* Update SP */
 		update_vsp = 1;