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/5b95b241aa63
branches: trunk
changeset: 983066:5b95b241aa63
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 e3dcc5961039 -r 5b95b241aa63 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 @@
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