All of lore.kernel.org
 help / color / mirror / Atom feed
From: <1276524911-26177-1-git-send-email-tytso@mit.edu>
To: Linux Kernel Developers List <linux-kernel@vger.kernel.org>
Cc: "Theodore Ts'o" <tytso@mit.edu>,
	Al Viro <viro@ZenIV.linux.org.uk>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
	Johannes Stezenbach <js@sig21.net>
Subject: [PATCH -v3] Only honor the FIGETBSZ ioctl for regular files and directories
Date: Mon, 14 Jun 2010 10:16:36 -0400	[thread overview]
Message-ID: <1276524996-26270-1-git-send-email-1276524911-26177-1-git-send-email-tytso@mit.edu> (raw)

From: Theodore Ts'o <tytso@mit.edu>

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: for regular files and directories

Thanks to Johannes Stezenbach for pointing this consequence of commit
19ba0559.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Cc: Johannes Stezenbach <js@sig21.net>
---

Fixed up commit description

 fs/compat_ioctl.c |    6 +++++-
 fs/ioctl.c        |    5 ++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 641640d..b8607fe 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -1715,8 +1715,12 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
 		goto out_fput;
 #endif
 
-	case FIBMAP:
 	case FIGETBSZ:
+		if (S_ISDIR(filp->f_path.dentry->d_inode->i_mode))
+			break;
+		/*FALL THROUGH */
+
+	case FIBMAP:
 	case FIONREAD:
 		if (S_ISREG(filp->f_path.dentry->d_inode->i_mode))
 			break;
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 2d140a7..e578dab 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))
+			return put_user(inode->i_sb->s_blocksize, p);
+		/* FALL THROUGH */
 	}
 
 	default:
-- 
1.7.0.4


             reply	other threads:[~2010-06-14 14:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-14 14:16 1276524911-26177-1-git-send-email-tytso [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-02-09  8:13 [PATCH -v3] Only honor the FIGETBSZ ioctl for regular files and directories anders franzen
2011-02-09 11:53 ` Johannes Stezenbach
2010-06-14 14:15 [PATCH -v2] " Theodore Ts'o
2010-06-14 14:17 ` [PATCH -v3] " Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1276524996-26270-1-git-send-email-1276524911-26177-1-git-send-email-tytso@mit.edu \
    --to=1276524911-26177-1-git-send-email-tytso@mit.edu \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=js@sig21.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.