Re: [AppArmor 32/45] Enable LSM hooks to distinguish operations on file descriptors from operations on pathnames

Previous thread: [AppArmor 29/45] Fix __d_path() for lazy unmounts and make it unambiguous by jjohansen on Friday, October 26, 2007 - 2:40 am. (1 message)

Next thread: [AppArmor 34/45] Factor out sysctl pathname code by jjohansen on Friday, October 26, 2007 - 2:40 am. (2 messages)
To: <akpm@...>
Cc: <linux-kernel@...>, <linux-security-module@...>, Andreas Gruenbacher <agruen@...>, John Johansen <jjohansen@...>, Miklos Szeredi <mszeredi@...>
Date: Friday, October 26, 2007 - 2:40 am

[Empty message]
To: <jjohansen@...>
Cc: <akpm@...>, <linux-kernel@...>, <linux-security-module@...>, Andreas Gruenbacher <agruen@...>
Date: Friday, October 26, 2007 - 7:30 am

There's a slight problem (other than HCH not liking it) with this
approach of passing the open file in iattr: for special files, the
struct file pointer makes no sense to the filesystem, since it is always
opened by the generic functions.

This wasn't a problem with ftruncate(), because that one only works on
regular files, but fchmod/fchown/futimes will work on special files as
well, and the filesystem interpreting file->private_data could cause
nasty bugs.

So I think the correct solution (which was suggested by Trond and
others) is to define an f_op->fsetattr() method, which interested
filesystems can define.

-

To: Miklos Szeredi <mszeredi@...>
Cc: <jjohansen@...>, <akpm@...>, <linux-kernel@...>, <linux-security-module@...>
Date: Friday, October 26, 2007 - 4:24 pm

So what do you think where the inodes come from for syscalls like fchmod? Out
of struct file, of course. But your f_op->getattr and f_op->setattr patches
are meant for passing struct file down to filesystems anyway, so that

That's nothing but a replacement for ATTR_FILE and iattr->ia_file. Except by
removing the ATTR_FILE flag, LSMs will no longer get that information for
distinguishing file descriptor operations from other operations.

AppArmor needs to know when notify_change is called on a file descriptor, but
it doesn't care about the file descriptor itself. So any way of passing along
that information will be fine.

Thanks,
Andreas
-

To: Andreas Gruenbacher <agruen@...>
Cc: <jjohansen@...>, <akpm@...>, <linux-kernel@...>, <linux-security-module@...>
Date: Friday, October 26, 2007 - 4:58 pm

For special files, f_op->fsetattr will be NULL, since
init_special_inode() will set up i_fop that way.

So the filesystem's fsetattr() will only be called for regular files
and/or directories, depending on how it sets up i_fop.

With the ia_file thing, the filesystem would receive the struct file
pointer in all cases. So the posted patch would break AFS and FUSE,
because they unconditionally use ia_file if available and don't check
the file type. They could check the file type, but still the interface

Ah, so if we kept ATTR_FILE and got rid of iattr_file, would that be OK
for AppArmor?

Thanks,
Miklos

-

To: Miklos Szeredi <mszeredi@...>
Cc: <jjohansen@...>, <akpm@...>, <linux-kernel@...>, <linux-security-module@...>
Date: Friday, October 26, 2007 - 5:56 pm

No problem, yes.

Thanks,
Andreas
-

To: Miklos Szeredi <mszeredi@...>
Cc: <jjohansen@...>, <akpm@...>, <linux-kernel@...>, <linux-security-module@...>, Andreas Gruenbacher <agruen@...>
Date: Friday, October 26, 2007 - 2:49 pm

yeah that does sound like the way to go, thank Miklos

regards
john

To: <jjohansen@...>
Cc: <akpm@...>, <linux-kernel@...>, <linux-security-module@...>, Andreas Gruenbacher <agruen@...>
Date: Friday, October 26, 2007 - 7:45 am

[Empty message]
Previous thread: [AppArmor 29/45] Fix __d_path() for lazy unmounts and make it unambiguous by jjohansen on Friday, October 26, 2007 - 2:40 am. (1 message)

Next thread: [AppArmor 34/45] Factor out sysctl pathname code by jjohansen on Friday, October 26, 2007 - 2:40 am. (2 messages)