$ ktrace fsirand -p /altroot
Abort trap (core dumped)
$ kdump | tail
   802 fsirand  CALL  pledge(0x16b2d3119a5e,0)
   802 fsirand  STRU  pledge promise="stdio rpath wpath disklabel"
   802 fsirand  RET   pledge 0
   802 fsirand  CALL  open(0x16b2d341f060,0<O_RDONLY>)
   802 fsirand  NAMI  "/altroot"
   802 fsirand  RET   open 3
   802 fsirand  CALL  ioctl(3,DIOCGDINFO,0x7f7ffffe6b10)
   802 fsirand  PLDG  ioctl, "ioctl", errno 1 Operation not permitted
   802 fsirand  PSIG  SIGABRT SIG_DFL code <537541152>
   802 fsirand  NAMI  "fsirand.core"


Hence let's remove the pledge before opendev opendev and the DIOCGDINFO
ioctl. Note that fsirand pledges "stdio" right after the ioctl.

Index: fsirand.c
===================================================================
RCS file: /var/cvs/src/sbin/fsirand/fsirand.c,v
retrieving revision 1.37
diff -u -p -r1.37 fsirand.c
--- fsirand.c   23 Nov 2015 19:19:30 -0000      1.37
+++ fsirand.c   28 May 2016 16:58:03 -0000
@@ -106,9 +106,6 @@ fsirand(char *device)
        u_int32_t bsize = DEV_BSIZE;
        struct disklabel label;
 
-       if (pledge("stdio rpath wpath disklabel", NULL) == -1)
-               err(1, "pledge");
-
        if ((devfd = opendev(device, printonly ? O_RDONLY : O_RDWR,
            0, &devpath)) < 0) {
                warn("Can't open %s", devpath);

Reply via email to