All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -v3] Only honor the FIGETBSZ ioctl for regular files and directories
@ 2010-06-14 14:16 1276524911-26177-1-git-send-email-tytso
  0 siblings, 0 replies; 4+ messages in thread
From: 1276524911-26177-1-git-send-email-tytso @ 2010-06-14 14:16 UTC (permalink / raw)
  To: Linux Kernel Developers List
  Cc: Theodore Ts'o, Al Viro, Aneesh Kumar K.V, Johannes Stezenbach

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH -v3] Only honor the FIGETBSZ ioctl for regular files and directories
  2011-02-09  8:13 anders franzen
@ 2011-02-09 11:53 ` Johannes Stezenbach
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Stezenbach @ 2011-02-09 11:53 UTC (permalink / raw)
  To: anders franzen; +Cc: linux-kernel, Theodore Ts'o, Al Viro, Aneesh Kumar K.V

(restore Cc:s)

On Wed, Feb 09, 2011 at 09:13:50AM +0100, anders franzen wrote:
> 
> Vad happened with the patch below. It was ''signed off'' more than
> half a year ago, and it is not in any of the latest kernel yet.
> 
> I ask, because I spend a week debugging the 'dvbloopback' driver,
> which uses '2' as a private ioctl for a read command. Not easy to
> find.
> 
> Can a driver not have private ioctls?
> Should this be fixed in the driver?, I have now RESERVED the value 2
> in the driver. But this does not
> guarantee that someone invents FIGETBSZ_V2 and assigned the value 3 to it.
> 
> Regards
>   /Anders
> 
> 
> 
> 
> 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@xxxxxxx>
> Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
> Cc: "Aneesh Kumar K.V" <aneesh.kumar@xxxxxxxxxxxxxxxxxx>
> Cc: Johannes Stezenbach <js@xxxxxxxxx>
> ---
> 
> 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
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -v3] Only honor the FIGETBSZ ioctl for regular files and directories
@ 2011-02-09  8:13 anders franzen
  2011-02-09 11:53 ` Johannes Stezenbach
  0 siblings, 1 reply; 4+ messages in thread
From: anders franzen @ 2011-02-09  8:13 UTC (permalink / raw)
  To: linux-kernel


Vad happened with the patch below. It was ''signed off'' more than half 
a year ago, and it is not in any of the latest kernel yet.

I ask, because I spend a week debugging the 'dvbloopback' driver, which 
uses '2' as a private ioctl for a read command. Not easy to find.

Can a driver not have private ioctls?
Should this be fixed in the driver?, I have now RESERVED the value 2 in 
the driver. But this does not
guarantee that someone invents FIGETBSZ_V2 and assigned the value 3 to it.

Regards
   /Anders




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@xxxxxxx>
Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@xxxxxxxxxxxxxxxxxx>
Cc: Johannes Stezenbach <js@xxxxxxxxx>
---

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH -v3] Only honor the FIGETBSZ ioctl for regular files and directories
  2010-06-14 14:15 [PATCH -v2] " Theodore Ts'o
@ 2010-06-14 14:17 ` Theodore Ts'o
  0 siblings, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2010-06-14 14:17 UTC (permalink / raw)
  To: Linux Kernel Developers List
  Cc: Theodore Ts'o, Al Viro, Aneesh Kumar K.V, Johannes Stezenbach

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-02-09 11:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-14 14:16 [PATCH -v3] Only honor the FIGETBSZ ioctl for regular files and directories 1276524911-26177-1-git-send-email-tytso
  -- strict thread matches above, loose matches on Subject: below --
2011-02-09  8:13 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

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.