In message <20071023090739.GA19758@infradead.org>, Christoph Hellwig writes:
OK, I'll be shortly posting a couple of patches to fs/ioctl.c.
I was able to test this idea and it works fine. Now unionfs calls
permission(), post-processes the return value, and I don't need my own
modified version of permission() in unionfs. This saved me ~50 LoC and
reduced stack pressure a little.
Christoph, I looked more closely at that and the selinux code. Only
sys_ioctl calls security_file_ioctl. And security_file_ioctl performs all
sorts of checks that mostly have to do with the currently running task or
the open file. The running task is still the same, whether filesystem
stacking is involved or not. Also, the unionfs-level struct file is
logically the same file at the lower level: they refer to the same object,
just at two layers. I can't see any reason why unionfs_ioctl should have to
call security_file_ioctl(lower_file) the way sys_ioctl does: that check is
already done well before the file system's ->ioctl is invoked. I also don't
see how it would ever be possible that sys_ioctl will succeed in its call to
security_file_ioctl(upper_file), but unionfs will fail the same security
check on the lower file.
So I commented out unionfs's call to security_file_ioctl(lower_file) and
tested it on a bunch of things, including an selinux-enabled livecd.
Everything seemed to work just fine, so I'll be sending some patches to that
effect, and we can drop the -mm patch which exports security_file_ioctl().
BTW, ecryptfs doesn't call security_file_ioctl().
Cheers,
Erez.
-