Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/miscfs/fdesc Make sure fdesc_lookup() never returns VNON...
details: https://anonhg.NetBSD.org/src/rev/a012418e1098
branches: trunk
changeset: 378965:a012418e1098
user: hannken <hannken%NetBSD.org@localhost>
date: Sat May 01 15:08:14 2021 +0000
description:
Make sure fdesc_lookup() never returns VNON vnodes.
Should fix PR kern/56130 (fdescfs create nodes with wrong major number)
diffstat:
sys/miscfs/fdesc/fdesc_vnops.c | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diffs (41 lines):
diff -r 3662731a5cab -r a012418e1098 sys/miscfs/fdesc/fdesc_vnops.c
--- a/sys/miscfs/fdesc/fdesc_vnops.c Sat May 01 14:00:57 2021 +0000
+++ b/sys/miscfs/fdesc/fdesc_vnops.c Sat May 01 15:08:14 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdesc_vnops.c,v 1.134 2020/06/27 17:29:19 christos Exp $ */
+/* $NetBSD: fdesc_vnops.c,v 1.135 2021/05/01 15:08:14 hannken Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.134 2020/06/27 17:29:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.135 2021/05/01 15:08:14 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -295,9 +295,20 @@ bad:
good:
KASSERT(ix != -1);
error = vcache_get(dvp->v_mount, &ix, sizeof(ix), vpp);
- if (error == 0 && ix == FD_CTTY)
+ if (error)
+ return error;
+
+ /*
+ * Prevent returning VNON nodes.
+ * Operation fdesc_inactive() will reset the type to VNON.
+ */
+ if (ix == FD_CTTY)
(*vpp)->v_type = VCHR;
- return error;
+ else if (ix >= FD_DESC)
+ (*vpp)->v_type = VREG;
+ KASSERT((*vpp)->v_type != VNON);
+
+ return 0;
}
int
Home |
Main Index |
Thread Index |
Old Index