Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/aarch64 Fixed a bug that pte's __BIT(63,48) could b...



details:   https://anonhg.NetBSD.org/src/rev/c6048f6675af
branches:  trunk
changeset: 369461:c6048f6675af
user:      ryo <ryo%NetBSD.org@localhost>
date:      Fri Aug 19 08:17:32 2022 +0000

description:
Fixed a bug that pte's __BIT(63,48) could be set when accessing addresses above 0x0001000000000000 in /dev/mem with mmap().

diffstat:

 sys/arch/aarch64/aarch64/aarch64_machdep.c |  7 +++++--
 sys/arch/aarch64/aarch64/pmap.c            |  5 +++--
 sys/arch/aarch64/include/pte.h             |  3 ++-
 3 files changed, 10 insertions(+), 5 deletions(-)

diffs (71 lines):

diff -r 8f7e51118370 -r c6048f6675af sys/arch/aarch64/aarch64/aarch64_machdep.c
--- a/sys/arch/aarch64/aarch64/aarch64_machdep.c        Fri Aug 19 07:52:22 2022 +0000
+++ b/sys/arch/aarch64/aarch64/aarch64_machdep.c        Fri Aug 19 08:17:32 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: aarch64_machdep.c,v 1.65 2022/03/12 09:16:05 skrll Exp $ */
+/* $NetBSD: aarch64_machdep.c,v 1.66 2022/08/19 08:17:32 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.65 2022/03/12 09:16:05 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.66 2022/08/19 08:17:32 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cpuoptions.h"
@@ -619,6 +619,9 @@
        if (in_dram_p(pa, 0))
                return 0;
 
+       if (pa >= AARCH64_MAX_PA)
+               return EFAULT;
+
        return kauth_authorize_machdep(kauth_cred_get(),
            KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL);
 }
diff -r 8f7e51118370 -r c6048f6675af sys/arch/aarch64/aarch64/pmap.c
--- a/sys/arch/aarch64/aarch64/pmap.c   Fri Aug 19 07:52:22 2022 +0000
+++ b/sys/arch/aarch64/aarch64/pmap.c   Fri Aug 19 08:17:32 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.138 2022/08/19 07:45:50 ryo Exp $   */
+/*     $NetBSD: pmap.c,v 1.139 2022/08/19 08:17:32 ryo Exp $   */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.138 2022/08/19 07:45:50 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.139 2022/08/19 08:17:32 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cpuoptions.h"
@@ -1915,6 +1915,7 @@
        KASSERT_PM_ADDR(pm, va);
        KASSERT(!IN_DIRECTMAP_ADDR(va));
        KASSERT((prot & VM_PROT_ALL) != VM_PROT_NONE);
+       KASSERT(pa < AARCH64_MAX_PA);
 
 #ifdef PMAPCOUNTERS
        PMAP_COUNT(mappings);
diff -r 8f7e51118370 -r c6048f6675af sys/arch/aarch64/include/pte.h
--- a/sys/arch/aarch64/include/pte.h    Fri Aug 19 07:52:22 2022 +0000
+++ b/sys/arch/aarch64/include/pte.h    Fri Aug 19 08:17:32 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pte.h,v 1.13 2021/10/10 07:15:25 skrll Exp $ */
+/* $NetBSD: pte.h,v 1.14 2022/08/19 08:17:32 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -93,6 +93,7 @@
 #define L1_BLK_OA              __BITS(47, 30)  /* 1GB */
 #define L2_BLK_OA              __BITS(47, 21)  /* 2MB */
 #define L3_PAG_OA              __BITS(47, 12)  /* 4KB */
+#define AARCH64_MAX_PA         __BIT(48)
 
 
 /* L0 table, 512GB/entry * 512 */



Home | Main Index | Thread Index | Old Index