Re: [PATCH] Only honor the FIGETBSZ ioctl for regular files,directories, and symlinks
From: Christoph Hellwig
Date: Mon Jun 14 2010 - 10:07:38 EST
On Mon, Jun 14, 2010 at 10:05:10AM -0400, Theodore Ts'o wrote:
> FIGETBSZ has an ioctl number of _IO(0x00,2) == 2, which can conflict
> with device driver ioctls. Let's avoid the potential for problems by
> only honoring the ioctl number for files where this ioctl is likely
> going to be useful: regular files, directories, and symlinks.
>
> Thanks to Johannes Stezenbach for pointing this consequence of commit
> 19ba0559.
ioctl operate on a file descriptor, so you never call them on
symbolic links.
> diff --git a/fs/ioctl.c b/fs/ioctl.c
> index 2d140a7..5c61d69 100644
> --- a/fs/ioctl.c
> +++ b/fs/ioctl.c
> @@ -597,7 +597,10 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
> {
> struct inode *inode = filp->f_path.dentry->d_inode;
> int __user *p = (int __user *)arg;
> - return put_user(inode->i_sb->s_blocksize, p);
> +
> + if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
> + S_ISLNK(inode->i_mode))
> + return put_user(inode->i_sb->s_blocksize, p);
> }
>
> default:
A comment explaining why we fall through here for special files is
almost required. Without that the chance of breaking it during the
next random cleanup are far too high.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/