Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc/sparc Reject setting unaligned Program Counter
details: https://anonhg.NetBSD.org/src/rev/b8ffb92fc0cb
branches: trunk
changeset: 971979:b8ffb92fc0cb
user: kamil <kamil%NetBSD.org@localhost>
date: Mon May 11 18:38:26 2020 +0000
description:
Reject setting unaligned Program Counter
Patch taken from OpenBSD.
Tested in qemu.
Fixes PR port-sparc/54734 by Andreas Gustafsson
diffstat:
sys/arch/sparc/sparc/process_machdep.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diffs (38 lines):
diff -r d626586708e8 -r b8ffb92fc0cb sys/arch/sparc/sparc/process_machdep.c
--- a/sys/arch/sparc/sparc/process_machdep.c Mon May 11 18:29:59 2020 +0000
+++ b/sys/arch/sparc/sparc/process_machdep.c Mon May 11 18:38:26 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: process_machdep.c,v 1.19 2016/12/30 17:54:43 christos Exp $ */
+/* $NetBSD: process_machdep.c,v 1.20 2020/05/11 18:38:26 kamil Exp $ */
/*
* Copyright (c) 1993 The Regents of the University of California.
@@ -95,7 +95,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.19 2016/12/30 17:54:43 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.20 2020/05/11 18:38:26 kamil Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -122,6 +122,9 @@
{
int psr = l->l_md.md_tf->tf_psr & ~PSR_ICC;
+ if (((regs->r_pc | regs->r_npc) & 0x03) != 0)
+ return EINVAL;
+
memcpy(l->l_md.md_tf, regs, sizeof(*regs));
l->l_md.md_tf->tf_psr = psr | (regs->r_psr & PSR_ICC);
return 0;
@@ -140,6 +143,9 @@
process_set_pc(struct lwp *l, void *addr)
{
+ if (((u_int)addr & 0x03) != 0)
+ return EINVAL;
+
l->l_md.md_tf->tf_pc = (u_int)addr;
l->l_md.md_tf->tf_npc = (u_int)addr + 4;
return 0;
Home |
Main Index |
Thread Index |
Old Index