]> err.no Git - linux-2.6/commitdiff
selinux: handle files opened with flags 3 by checking ioctl permission
authorStephen Smalley <sds@tycho.nsa.gov>
Mon, 17 Mar 2008 12:55:18 +0000 (08:55 -0400)
committerJames Morris <jmorris@namei.org>
Wed, 2 Apr 2008 05:05:52 +0000 (16:05 +1100)
Handle files opened with flags 3 by checking ioctl permission.

Default to returning FILE__IOCTL from file_to_av() if the f_mode has neither
FMODE_READ nor FMODE_WRITE, and thus check ioctl permission on exec or
transfer, thereby validating such descriptors early as with normal r/w
descriptors and catching leaks of them prior to attempted usage.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Acked-by: Eric Paris <eparis@redhat.com>
Signed-off-by: James Morris <jmorris@namei.org>
security/selinux/hooks.c

index 41a049f50f58f43e131219c2318df9c265d76782..c2fef7b12dc7de21bb32cb40d8dbc1032b256f38 100644 (file)
@@ -1630,6 +1630,12 @@ static inline u32 file_to_av(struct file *file)
                else
                        av |= FILE__WRITE;
        }
+       if (!av) {
+               /*
+                * Special file opened with flags 3 for ioctl-only use.
+                */
+               av = FILE__IOCTL;
+       }
 
        return av;
 }