Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-10]: src/sys/uvm Pull up following revision(s) (requested by chs ...
details: https://anonhg.NetBSD.org/src/rev/f50344a176cf
branches: netbsd-10
changeset: 372703:f50344a176cf
user: martin <martin%NetBSD.org@localhost>
date: Wed Dec 21 09:33:17 2022 +0000
description:
Pull up following revision(s) (requested by chs in ticket #13):
sys/uvm/uvm_swap.c: revision 1.207
swap: disallow user opens of swap block device
the swap/drum block device was never intended to allow user opens,
but when the internal VOP_OPEN() in uvm_swap_init() was added
back in rev 1.135, the d_open method was changed from always-fail
to always-succeed in order to allow the new initial internal open.
this had the side effect of incorrectly allowing user opens too.
fix this by replacing the swap_bdevsw d_open with one that succeeds
for the first call but fails for all subsequent calls.
diffstat:
sys/uvm/uvm_swap.c | 24 ++++++++++++++++++++----
1 files changed, 20 insertions(+), 4 deletions(-)
diffs (52 lines):
diff -r 025bbadc9035 -r f50344a176cf sys/uvm/uvm_swap.c
--- a/sys/uvm/uvm_swap.c Tue Dec 20 09:55:19 2022 +0000
+++ b/sys/uvm/uvm_swap.c Wed Dec 21 09:33:17 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_swap.c,v 1.206 2021/08/23 13:08:18 hannken Exp $ */
+/* $NetBSD: uvm_swap.c,v 1.206.4.1 2022/12/21 09:33:17 martin Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 2009 Matthew R. Green
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.206 2021/08/23 13:08:18 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.206.4.1 2022/12/21 09:33:17 martin Exp $");
#include "opt_uvmhist.h"
#include "opt_compat_netbsd.h"
@@ -1190,6 +1190,22 @@
*/
/*
+ * swopen: allow the initial open from uvm_swap_init() and reject all others.
+ */
+
+static int
+swopen(dev_t dev, int flag, int mode, struct lwp *l)
+{
+ static bool inited = false;
+
+ if (!inited) {
+ inited = true;
+ return 0;
+ }
+ return ENODEV;
+}
+
+/*
* swstrategy: perform I/O on the drum
*
* => we must map the i/o request from the drum to the correct swapdev.
@@ -1308,8 +1324,8 @@
}
const struct bdevsw swap_bdevsw = {
- .d_open = nullopen,
- .d_close = nullclose,
+ .d_open = swopen,
+ .d_close = noclose,
.d_strategy = swstrategy,
.d_ioctl = noioctl,
.d_dump = nodump,
Home |
Main Index |
Thread Index |
Old Index