From d836be949cdd43691d70c3bf99410c2a8f0550f0 Mon Sep 17 00:00:00 2001 From: kib Date: Sun, 22 Oct 2017 08:11:45 +0000 Subject: [PATCH] Remove the support for mknod(S_IFMT), which created dummy vnodes with VBAD type. FFS ffs_write() VOP catches such vnodes and panics, other VOPs do not check for the type and their behaviour is really undefined. The comment claims that this support was done for 'badsect' to flag bad sectors, we do not have such facility in kernel anyway. Reported by: Dmitry Vyukov Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/kern/vfs_syscalls.c | 6 ------ sys/sys/priv.h | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index dac26f115427..be8a9f512ed1 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1248,9 +1248,6 @@ kern_mknodat(struct thread *td, int fd, char *path, enum uio_seg pathseg, if (error == 0 && dev == VNOVAL) error = EINVAL; break; - case S_IFMT: - error = priv_check(td, PRIV_VFS_MKNOD_BAD); - break; case S_IFWHT: error = priv_check(td, PRIV_VFS_MKNOD_WHT); break; @@ -1288,9 +1285,6 @@ restart: whiteout = 0; switch (mode & S_IFMT) { - case S_IFMT: /* used by badsect to flag bad sectors */ - vattr.va_type = VBAD; - break; case S_IFCHR: vattr.va_type = VCHR; break; diff --git a/sys/sys/priv.h b/sys/sys/priv.h index 86ea05e92ac3..828c19f25efb 100644 --- a/sys/sys/priv.h +++ b/sys/sys/priv.h @@ -266,7 +266,7 @@ #define PRIV_VFS_GETFH 327 /* Can retrieve file handles. */ #define PRIV_VFS_GETQUOTA 328 /* getquota(). */ #define PRIV_VFS_LINK 329 /* bsd.hardlink_check_uid */ -#define PRIV_VFS_MKNOD_BAD 330 /* Can mknod() to mark bad inodes. */ +#define PRIV_VFS_MKNOD_BAD 330 /* Was: mknod() can mark bad inodes. */ #define PRIV_VFS_MKNOD_DEV 331 /* Can mknod() to create dev nodes. */ #define PRIV_VFS_MKNOD_WHT 332 /* Can mknod() to create whiteout. */ #define PRIV_VFS_MOUNT 333 /* Can mount(). */