From e93b464d004e23b7e58e159e6fec69e62351e72b Mon Sep 17 00:00:00 2001 From: trasz Date: Sun, 18 Oct 2015 14:36:04 +0000 Subject: MFC r286283: Fix panic triggered by code like this: open("/dev/md0", O_EXEC); Sponsored by: The FreeBSD Foundation --- sys/geom/geom_dev.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sys') diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c index bf2ba9e..1123323 100644 --- a/sys/geom/geom_dev.c +++ b/sys/geom/geom_dev.c @@ -356,6 +356,13 @@ g_dev_open(struct cdev *dev, int flags, int fmt, struct thread *td) #else e = 0; #endif + + /* + * This happens on attempt to open a device node with O_EXEC. + */ + if (r + w + e == 0) + return (EINVAL); + if (w) { /* * When running in very secure mode, do not allow -- cgit v1.1