summaryrefslogtreecommitdiff
path: root/sys/lib/libsa/fchmod.c
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2021-12-01 17:25:36 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2021-12-01 17:25:36 +0000
commit55b69e2901555a3283cdedab04acbc4ce5c863a4 (patch)
treee8a61f471a6d8d4f5769e267c4f5fb8997a0f645 /sys/lib/libsa/fchmod.c
parent39d8b71521756796bfca4516253686c7eb93cf75 (diff)
Fix booting from an IDE block device on the Sun Blade 100. Apparently
writing to disk using the Open Firmware interfaces is buggy and causes corruption of the disk. While it isn't entirely clear what versions of Open Firmware are affected, but it seems to only affect IDE drives. So if we detect an IDE drive, disable writing to it. This results in a small lose of bootloader functionality (bsd.upgrade loop prevention and flagging /etc/random.seed re-use) but that is better than losing the ability to run OpenBSD at all. Based on a diff by Ted Bullock (who did all the hard work of debugging this and coming up with a viable fix). ok deraadt@
Diffstat (limited to 'sys/lib/libsa/fchmod.c')
-rw-r--r--sys/lib/libsa/fchmod.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/lib/libsa/fchmod.c b/sys/lib/libsa/fchmod.c
index 7d9bc9cac36..f6252ca9e56 100644
--- a/sys/lib/libsa/fchmod.c
+++ b/sys/lib/libsa/fchmod.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fchmod.c,v 1.1 2019/08/03 15:22:17 deraadt Exp $ */
+/* $OpenBSD: fchmod.c,v 1.2 2021/12/01 17:25:35 kettenis Exp $ */
/* $NetBSD: stat.c,v 1.3 1994/10/26 05:45:07 cgd Exp $ */
/*-
@@ -53,6 +53,11 @@ fchmod(int fd, mode_t m)
errno = EOPNOTSUPP;
return (-1);
}
+ /* writing is broken or unsupported */
+ if (f->f_flags & F_NOWRITE) {
+ errno = EOPNOTSUPP;
+ return (-1);
+ }
errno = (f->f_ops->fchmod)(f, m);
return (0);