Re: [PATCH] Fix floppy ioctl (which were broken in 2.4.0-test5)

From: Tigran Aivazian (tigran@veritas.com)
Date: Sat Sep 16 2000 - 09:44:08 EDT

  • Next message: Tigran Aivazian: "Re: bug in blkdev <-> VFS interaction. (oops) (fwd)"

    Alain,

    Al Viro, myself and Linus broke this intentionally. Please read the
    comments we put in blkdev_get() in fs/block_dev.c and understand that this
    is a non-trivial issue - we had an interesting conversation about it -
    unfortunately all my mailfolders are gone (as a side-effect of truncate
    issues :) so I can't remeber the thread subject - seek and ye shall find.

    So, your patch would panic the system as it used to before the fix.

    Regards,
    Tigran

     On Sat, 16 Sep
    2000, Alain Knaff wrote:

    > The following patch (against 2.4.0-test8) restores ioctl functionality,
    > which has been broken in 2.4.0-test6-pre7:
    >
    > --- 2.4.0-test8/linux/drivers/block/floppy.c Mon Sep 11 20:09:28 2000
    > +++ linux/drivers/block/floppy.c Sat Sep 16 15:03:39 2000
    > @@ -3435,6 +3435,8 @@
    > static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
    > unsigned long param)
    > {
    > +#define FD_IOCTL_MODE_BIT 8
    > +#define FD_IOCTL_ALLOWED ((filp) && ((filp)->f_mode & FD_IOCTL_MODE_BIT))
    > #define OUT(c,x) case c: outparam = (const char *) (x); break
    > #define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0
    >
    > @@ -3502,7 +3504,7 @@
    > return -EINVAL;
    >
    > /* permission checks */
    > - if (((cmd & 0x40) && !(filp->f_mode & 2)) ||
    > + if (((cmd & 0x40) && !FD_IOCTL_ALLOWED) ||
    > ((cmd & 0x80) && !capable(CAP_SYS_ADMIN)))
    > return -EPERM;
    >
    > @@ -3774,6 +3776,12 @@
    > buffer_track = -1;
    > invalidate_buffers(MKDEV(FLOPPY_MAJOR,old_dev));
    > }
    > +
    > + /* Allow ioctls if we have write-permissions even if read-only open.
    > + * Needed so that programs such as fdrawcmd still can work on write
    > + * protected disks */
    > + if ((filp->f_mode & 2) || (permission(inode,2) == 0))
    > + filp->f_mode |= FD_IOCTL_MODE_BIT;
    >
    > if (UFDCS->rawcmd == 1)
    > UFDCS->rawcmd = 2;
    > -
    > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    > the body of a message to majordomo@vger.kernel.org
    > Please read the FAQ at http://www.tux.org/lkml/
    >

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    Please read the FAQ at http://www.tux.org/lkml/



    This archive was generated by hypermail 2b29 : Sat Sep 16 2000 - 09:37:49 EDT