diff options
author | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2024-10-28 10:18:04 +0000 |
---|---|---|
committer | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2024-10-28 10:18:04 +0000 |
commit | 669b28a560bc46a3bb3866c9f01de1261bdfdca1 (patch) | |
tree | 679e86c7d05bfd3e1e3cd6471d2c807aa69f3849 /sys/arch | |
parent | d4ced6060887d5c0d2ba01ba8712d8c18882845a (diff) |
Unlock KERN_ALLOWKMEM. The `allowkmem' is atomically accessed integer.
Also use atomic_load_int(9) to load `securelevel'. sysctl_securelevel()
is mp-safe, but will be under kernel lock until all existing
`securelevel' loading became mp-safe too.
ok mpi
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/alpha/alpha/mem.c | 6 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/mem.c | 6 | ||||
-rw-r--r-- | sys/arch/arm/arm/mem.c | 6 | ||||
-rw-r--r-- | sys/arch/arm64/arm64/mem.c | 6 | ||||
-rw-r--r-- | sys/arch/hppa/hppa/mem.c | 6 | ||||
-rw-r--r-- | sys/arch/i386/i386/mem.c | 6 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/mem.c | 6 | ||||
-rw-r--r-- | sys/arch/macppc/macppc/mem.c | 6 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/mem.c | 6 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/mem.c | 6 | ||||
-rw-r--r-- | sys/arch/riscv64/riscv64/mem.c | 6 | ||||
-rw-r--r-- | sys/arch/sh/sh/mem.c | 6 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/mem.c | 6 |
13 files changed, 52 insertions, 26 deletions
diff --git a/sys/arch/alpha/alpha/mem.c b/sys/arch/alpha/alpha/mem.c index 42e9f48d50e..88b722f2d2f 100644 --- a/sys/arch/alpha/alpha/mem.c +++ b/sys/arch/alpha/alpha/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.35 2024/06/23 22:08:37 kettenis Exp $ */ +/* $OpenBSD: mem.c,v 1.36 2024/10/28 10:18:02 mvs Exp $ */ /* $NetBSD: mem.c,v 1.26 2000/03/29 03:48:20 simonb Exp $ */ /* @@ -51,6 +51,7 @@ #include <sys/msgbuf.h> #include <sys/mman.h> #include <sys/conf.h> +#include <sys/atomic.h> #include <machine/cpu.h> @@ -76,7 +77,8 @@ mmopen(dev_t dev, int flag, int mode, struct proc *p) switch (minor(dev)) { case 0: case 1: - if (securelevel <= 0 || allowkmem) + if (atomic_load_int(&securelevel) <= 0 || + atomic_load_int(&allowkmem)) break; return (EPERM); case 2: diff --git a/sys/arch/amd64/amd64/mem.c b/sys/arch/amd64/amd64/mem.c index 55205417d6b..53db257d2fa 100644 --- a/sys/arch/amd64/amd64/mem.c +++ b/sys/arch/amd64/amd64/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.36 2024/06/23 22:08:37 kettenis Exp $ */ +/* $OpenBSD: mem.c,v 1.37 2024/10/28 10:18:02 mvs Exp $ */ /* * Copyright (c) 1988 University of Utah. * Copyright (c) 1982, 1986, 1990, 1993 @@ -51,6 +51,7 @@ #include <sys/ioccom.h> #include <sys/malloc.h> #include <sys/memrange.h> +#include <sys/atomic.h> #include <machine/cpu.h> @@ -84,7 +85,8 @@ mmopen(dev_t dev, int flag, int mode, struct proc *p) switch (minor(dev)) { case 0: case 1: - if (securelevel <= 0 || allowkmem) + if (atomic_load_int(&securelevel) <= 0 || + atomic_load_int(&allowkmem)) break; return (EPERM); case 2: diff --git a/sys/arch/arm/arm/mem.c b/sys/arch/arm/arm/mem.c index 85c0f69d5f1..25f702810ae 100644 --- a/sys/arch/arm/arm/mem.c +++ b/sys/arch/arm/arm/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.24 2024/06/23 22:08:37 kettenis Exp $ */ +/* $OpenBSD: mem.c,v 1.25 2024/10/28 10:18:02 mvs Exp $ */ /* $NetBSD: mem.c,v 1.11 2003/10/16 12:02:58 jdolecek Exp $ */ /* @@ -80,6 +80,7 @@ #include <sys/uio.h> #include <sys/malloc.h> #include <sys/rwlock.h> +#include <sys/atomic.h> #include <arm/conf.h> @@ -103,7 +104,8 @@ mmopen(dev_t dev, int flag, int mode, struct proc *p) switch (minor(dev)) { case 0: case 1: - if (securelevel <= 0 || allowkmem) + if (atomic_load_int(&securelevel) <= 0 || + atomic_load_int(&allowkmem)) break; return (EPERM); case 2: diff --git a/sys/arch/arm64/arm64/mem.c b/sys/arch/arm64/arm64/mem.c index 2084b979d04..fd0308065a7 100644 --- a/sys/arch/arm64/arm64/mem.c +++ b/sys/arch/arm64/arm64/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.7 2024/06/23 22:08:37 kettenis Exp $ */ +/* $OpenBSD: mem.c,v 1.8 2024/10/28 10:18:02 mvs Exp $ */ /* $NetBSD: mem.c,v 1.11 2003/10/16 12:02:58 jdolecek Exp $ */ /* @@ -83,6 +83,7 @@ #include <sys/proc.h> #include <sys/fcntl.h> #include <sys/rwlock.h> +#include <sys/atomic.h> #include <machine/cpu.h> #include <arm64/conf.h> @@ -107,7 +108,8 @@ mmopen(dev_t dev, int flag, int mode, struct proc *p) switch (minor(dev)) { case 0: case 1: - if (securelevel <= 0 || allowkmem) + if (atomic_load_int(&securelevel) <= 0 || + atomic_load_int(&allowkmem)) break; return (EPERM); case 2: diff --git a/sys/arch/hppa/hppa/mem.c b/sys/arch/hppa/hppa/mem.c index 90dd7da574d..2fc070e76c4 100644 --- a/sys/arch/hppa/hppa/mem.c +++ b/sys/arch/hppa/hppa/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.7 2024/06/23 22:08:37 kettenis Exp $ */ +/* $OpenBSD: mem.c,v 1.8 2024/10/28 10:18:02 mvs Exp $ */ /* * Copyright (c) 1998-2004 Michael Shalayeff @@ -81,6 +81,7 @@ #include <sys/device.h> #include <sys/errno.h> #include <sys/ioctl.h> +#include <sys/atomic.h> #include <uvm/uvm_extern.h> @@ -306,7 +307,8 @@ mmopen(dev_t dev, int flag, int ioflag, struct proc *p) switch (minor(dev)) { case 0: case 1: - if (securelevel <= 0 || allowkmem) + if (atomic_load_int(&securelevel) <= 0 || + atomic_load_int(&allowkmem)) break; return (EPERM); case 2: diff --git a/sys/arch/i386/i386/mem.c b/sys/arch/i386/i386/mem.c index 6ae49d78e0d..6d534949240 100644 --- a/sys/arch/i386/i386/mem.c +++ b/sys/arch/i386/i386/mem.c @@ -1,5 +1,5 @@ /* $NetBSD: mem.c,v 1.31 1996/05/03 19:42:19 christos Exp $ */ -/* $OpenBSD: mem.c,v 1.57 2024/06/23 22:08:37 kettenis Exp $ */ +/* $OpenBSD: mem.c,v 1.58 2024/10/28 10:18:03 mvs Exp $ */ /* * Copyright (c) 1988 University of Utah. * Copyright (c) 1982, 1986, 1990, 1993 @@ -48,6 +48,7 @@ #include <sys/malloc.h> #include <sys/memrange.h> #include <sys/rwlock.h> +#include <sys/atomic.h> #include <machine/conf.h> @@ -78,7 +79,8 @@ mmopen(dev_t dev, int flag, int mode, struct proc *p) switch (minor(dev)) { case 0: case 1: - if (securelevel <= 0 || allowkmem) + if (atomic_load_int(&securelevel) <= 0 || + atomic_load_int(&allowkmem)) break; return (EPERM); case 2: diff --git a/sys/arch/m88k/m88k/mem.c b/sys/arch/m88k/m88k/mem.c index 217d2394c8b..0157fd2a0e1 100644 --- a/sys/arch/m88k/m88k/mem.c +++ b/sys/arch/m88k/m88k/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.7 2024/06/23 22:08:37 kettenis Exp $ */ +/* $OpenBSD: mem.c,v 1.8 2024/10/28 10:18:03 mvs Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -46,6 +46,7 @@ #include <sys/systm.h> #include <sys/uio.h> #include <sys/malloc.h> +#include <sys/atomic.h> #include <machine/conf.h> @@ -64,7 +65,8 @@ mmopen(dev_t dev, int flag, int mode, struct proc *p) switch (minor(dev)) { case 0: case 1: - if (securelevel <= 0 || allowkmem) + if (atomic_load_int(&securelevel) <= 0 || + atomic_load_int(&allowkmem)) break; return (EPERM); case 2: diff --git a/sys/arch/macppc/macppc/mem.c b/sys/arch/macppc/macppc/mem.c index 1046e68e466..7e5ce6d1b31 100644 --- a/sys/arch/macppc/macppc/mem.c +++ b/sys/arch/macppc/macppc/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.29 2024/06/23 22:08:37 kettenis Exp $ */ +/* $OpenBSD: mem.c,v 1.30 2024/10/28 10:18:03 mvs Exp $ */ /* $NetBSD: mem.c,v 1.1 1996/09/30 16:34:50 ws Exp $ */ /* @@ -48,6 +48,7 @@ #include <sys/ioccom.h> #include <sys/uio.h> #include <sys/malloc.h> +#include <sys/atomic.h> #include <machine/cpu.h> @@ -196,7 +197,8 @@ mmopen(dev_t dev, int flag, int mode, struct proc *p) switch (minor(dev)) { case 0: case 1: - if (securelevel <= 0 || allowkmem) + if (atomic_load_int(&securelevel) <= 0 || + atomic_load_int(&allowkmem)) break; return (EPERM); case 2: diff --git a/sys/arch/mips64/mips64/mem.c b/sys/arch/mips64/mips64/mem.c index 6a7f2d88e1d..47d49ef0d78 100644 --- a/sys/arch/mips64/mips64/mem.c +++ b/sys/arch/mips64/mips64/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.25 2024/06/23 22:08:37 kettenis Exp $ */ +/* $OpenBSD: mem.c,v 1.26 2024/10/28 10:18:03 mvs Exp $ */ /* $NetBSD: mem.c,v 1.6 1995/04/10 11:55:03 mycroft Exp $ */ /* @@ -54,6 +54,7 @@ #include <sys/systm.h> #include <sys/uio.h> #include <sys/malloc.h> +#include <sys/atomic.h> #include <machine/autoconf.h> #include <machine/cpu.h> @@ -77,7 +78,8 @@ mmopen(dev_t dev, int flag, int mode, struct proc *p) switch (minor(dev)) { case 0: case 1: - if (securelevel <= 0 || allowkmem) + if (atomic_load_int(&securelevel) <= 0 || + atomic_load_int(&allowkmem)) break; return (EPERM); case 2: diff --git a/sys/arch/powerpc64/powerpc64/mem.c b/sys/arch/powerpc64/powerpc64/mem.c index dc691ab63cc..3174f3f61c0 100644 --- a/sys/arch/powerpc64/powerpc64/mem.c +++ b/sys/arch/powerpc64/powerpc64/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.2 2024/06/23 22:08:37 kettenis Exp $ */ +/* $OpenBSD: mem.c,v 1.3 2024/10/28 10:18:03 mvs Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -49,6 +49,7 @@ #include <sys/malloc.h> #include <sys/fcntl.h> #include <sys/rwlock.h> +#include <sys/atomic.h> #include <machine/cpu.h> #include <machine/conf.h> @@ -68,7 +69,8 @@ mmopen(dev_t dev, int flag, int mode, struct proc *p) switch (minor(dev)) { case 0: case 1: - if (securelevel <= 0 || allowkmem) + if (atomic_load_int(&securelevel) <= 0 || + atomic_load_int(&allowkmem)) break; return (EPERM); case 2: diff --git a/sys/arch/riscv64/riscv64/mem.c b/sys/arch/riscv64/riscv64/mem.c index 8fededf437e..cc6d9939dd5 100644 --- a/sys/arch/riscv64/riscv64/mem.c +++ b/sys/arch/riscv64/riscv64/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.6 2024/06/23 22:08:37 kettenis Exp $ */ +/* $OpenBSD: mem.c,v 1.7 2024/10/28 10:18:03 mvs Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -80,6 +80,7 @@ #include <sys/malloc.h> #include <sys/proc.h> #include <sys/rwlock.h> +#include <sys/atomic.h> #include <machine/conf.h> @@ -103,7 +104,8 @@ mmopen(dev_t dev, int flag, int mode, struct proc *p) switch (minor(dev)) { case 0: case 1: - if (securelevel <= 0 || allowkmem) + if (atomic_load_int(&securelevel) <= 0 || + atomic_load_int(&allowkmem)) break; return (EPERM); case 2: diff --git a/sys/arch/sh/sh/mem.c b/sys/arch/sh/sh/mem.c index d645b61cd8d..88c15695034 100644 --- a/sys/arch/sh/sh/mem.c +++ b/sys/arch/sh/sh/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.12 2024/06/23 22:08:37 kettenis Exp $ */ +/* $OpenBSD: mem.c,v 1.13 2024/10/28 10:18:03 mvs Exp $ */ /* $NetBSD: mem.c,v 1.21 2006/07/23 22:06:07 ad Exp $ */ /* @@ -88,6 +88,7 @@ #include <sys/malloc.h> #include <sys/proc.h> #include <sys/conf.h> +#include <sys/atomic.h> #include <uvm/uvm_extern.h> @@ -107,7 +108,8 @@ mmopen(dev_t dev, int flag, int mode, struct proc *p) switch (minor(dev)) { case 0: case 1: - if (securelevel <= 0 || allowkmem) + if (atomic_load_int(&securelevel) <= 0 || + atomic_load_int(&allowkmem)) break; return (EPERM); case 2: diff --git a/sys/arch/sparc64/sparc64/mem.c b/sys/arch/sparc64/sparc64/mem.c index acd60dd5fca..19b8152295d 100644 --- a/sys/arch/sparc64/sparc64/mem.c +++ b/sys/arch/sparc64/sparc64/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.21 2024/06/23 22:08:37 kettenis Exp $ */ +/* $OpenBSD: mem.c,v 1.22 2024/10/28 10:18:03 mvs Exp $ */ /* $NetBSD: mem.c,v 1.18 2001/04/24 04:31:12 thorpej Exp $ */ /* @@ -50,6 +50,7 @@ #include <sys/proc.h> #include <sys/rwlock.h> #include <sys/conf.h> +#include <sys/atomic.h> #include <machine/conf.h> #include <machine/ctlreg.h> @@ -68,7 +69,8 @@ mmopen(dev_t dev, int flag, int mode, struct proc *p) switch (minor(dev)) { case 0: case 1: - if (securelevel <= 0 || allowkmem) + if (atomic_load_int(&securelevel) <= 0 || + atomic_load_int(&allowkmem)) break; return (EPERM); case 2: |