diff options
author | phk <phk@FreeBSD.org> | 2004-12-12 10:09:05 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2004-12-12 10:09:05 +0000 |
commit | 35b3c9fdfbd8e466654ebad62b044a7d3c01f3b7 (patch) | |
tree | c331a8f51b025987771bf29e5baf7455e29185d9 /sys/geom/geom_bsd.c | |
parent | cfac934dde18f8d08432e5509b2dd827eb77be2c (diff) | |
download | FreeBSD-src-35b3c9fdfbd8e466654ebad62b044a7d3c01f3b7.zip FreeBSD-src-35b3c9fdfbd8e466654ebad62b044a7d3c01f3b7.tar.gz |
Pass the file->flags down to geom ioctl handlers.
Reject certain ioctls if write permission is not indicated.
Bump geom API version.
Reported by: Ruben de Groot <mail25@bzerk.org>
Diffstat (limited to 'sys/geom/geom_bsd.c')
-rw-r--r-- | sys/geom/geom_bsd.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/geom/geom_bsd.c b/sys/geom/geom_bsd.c index 0f880a3..eaddb98 100644 --- a/sys/geom/geom_bsd.c +++ b/sys/geom/geom_bsd.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include <sys/endian.h> #include <sys/systm.h> #include <sys/kernel.h> +#include <sys/fcntl.h> #include <sys/conf.h> #include <sys/bio.h> #include <sys/malloc.h> @@ -315,7 +316,7 @@ g_bsd_hotwrite(void *arg, int flag) * * Don't call biowait, g_getattr(), g_setattr() or g_read_data() */ static int -g_bsd_ioctl(struct g_provider *pp, u_long cmd, void * data, struct thread *td) +g_bsd_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, struct thread *td) { struct g_geom *gp; struct g_bsd_softc *ms; @@ -339,6 +340,8 @@ g_bsd_ioctl(struct g_provider *pp, u_long cmd, void * data, struct thread *td) int error, i; uint64_t sum; + if (!(fflag & FWRITE)) + return (EPERM); /* The disklabel to set is the ioctl argument. */ buf = g_malloc(BBSIZE, M_WAITOK); p = *(void **)data; @@ -369,6 +372,8 @@ g_bsd_ioctl(struct g_provider *pp, u_long cmd, void * data, struct thread *td) case DIOCWDINFO: { label = g_malloc(LABELSIZE, M_WAITOK); + if (!(fflag & FWRITE)) + return (EPERM); /* The disklabel to set is the ioctl argument. */ bsd_disklabel_le_enc(label, data); |