From: Christoph Hellwig on
On Mon, May 05, 2008 at 11:54:44AM +0200, Miklos Szeredi wrote:
> From: Miklos Szeredi <mszeredi(a)suse.cz>
>
> cgroup_clone() calls vfs_mkdir() to create a directory in the cgroup
> filesystem. Replace with explicit call to cgroup_mkdir() and
> fsnotify_mkdir().
>
> This is equivalent, except that the following functions are not called
> before cgroup_mkdir():
>
> - may_create()
> - security_inode_mkdir()
> - DQUOT_INIT()
>
> Permission to clone the cgroup has already been checked in
> copy_namespaces() (requiring CAP_SYS_ADMIN). Additional file system
> related capability checks are inappropriate and confusing.
>
> The quota check is unnecessary, as quotas don't make any sense for
> this filesystem.

Looks correct but I don't think it's a good idea. Spreading more logic
into filesystems without a good reason is rarely a good idea.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Miklos Szeredi on
> > From: Miklos Szeredi <mszeredi(a)suse.cz>
> >
> > cgroup_clone() calls vfs_mkdir() to create a directory in the cgroup
> > filesystem. Replace with explicit call to cgroup_mkdir() and
> > fsnotify_mkdir().
> >
> > This is equivalent, except that the following functions are not called
> > before cgroup_mkdir():
> >
> > - may_create()
> > - security_inode_mkdir()
> > - DQUOT_INIT()
> >
> > Permission to clone the cgroup has already been checked in
> > copy_namespaces() (requiring CAP_SYS_ADMIN). Additional file system
> > related capability checks are inappropriate and confusing.
> >
> > The quota check is unnecessary, as quotas don't make any sense for
> > this filesystem.
>
> Looks correct but I don't think it's a good idea. Spreading more logic
> into filesystems without a good reason is rarely a good idea.

(Thanks for the review, Christoph)

Agreed completely, but vfs_* aren't for filesystems to call, rather
for entities calling _into_ filesystems from the outside. This is
actually a very rare thing, so adding some extra logic for the sake of
cleanliness should be OK.

Now it can be argued, that cgroup_clone() is calling into the
filesystem from the outside. But it's not really doing that, rather
it's making an internal modification to a specific filesystem,
triggered by some external action.

Miklos
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Christoph Hellwig on
On Mon, May 05, 2008 at 02:32:22PM +0200, Miklos Szeredi wrote:
> > Looks correct but I don't think it's a good idea. Spreading more logic
> > into filesystems without a good reason is rarely a good idea.
>
> (Thanks for the review, Christoph)
>
> Agreed completely, but vfs_* aren't for filesystems to call, rather
> for entities calling _into_ filesystems from the outside. This is
> actually a very rare thing, so adding some extra logic for the sake of
> cleanliness should be OK.
>
> Now it can be argued, that cgroup_clone() is calling into the
> filesystem from the outside. But it's not really doing that, rather
> it's making an internal modification to a specific filesystem,
> triggered by some external action.

I don't think that matters. We're not about overly strict layering, and
especialy this kind where you call into a higher layer to get back into
the lower one is not harmful at all. For cgroup it's only a small
duplication, but e.g. I don't really like all the duplications in the
reiserfs case. Unless we have a very good reason why the useage of the
vfs_ function should go away from the filesystem code I don't think
we want this.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Miklos Szeredi on
> > > Looks correct but I don't think it's a good idea. Spreading more logic
> > > into filesystems without a good reason is rarely a good idea.
> >
> > (Thanks for the review, Christoph)
> >
> > Agreed completely, but vfs_* aren't for filesystems to call, rather
> > for entities calling _into_ filesystems from the outside. This is
> > actually a very rare thing, so adding some extra logic for the sake of
> > cleanliness should be OK.
> >
> > Now it can be argued, that cgroup_clone() is calling into the
> > filesystem from the outside. But it's not really doing that, rather
> > it's making an internal modification to a specific filesystem,
> > triggered by some external action.
>
> I don't think that matters. We're not about overly strict layering, and
> especialy this kind where you call into a higher layer to get back into
> the lower one is not harmful at all. For cgroup it's only a small
> duplication, but e.g. I don't really like all the duplications in the
> reiserfs case.

I think there's some good reasons, other than just to get rid of the
vfs recursion. I took this change from Jeff Mahoney's patchset.

> Unless we have a very good reason why the useage of the
> vfs_ function should go away from the filesystem code I don't think
> we want this.

We do have a good reason: r/o bind mounts and AppArmor. And please
don't tell me, you also think that moving the security hooks to
callers is a good idea ;) That would actually be a change with a much
larger impact, both in terms of code duplication and of verifying
correctness.

Miklos
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Christoph Hellwig on
On Mon, May 05, 2008 at 03:29:38PM +0200, Miklos Szeredi wrote:
> We do have a good reason: r/o bind mounts and AppArmor. And please
> don't tell me, you also think that moving the security hooks to
> callers is a good idea ;) That would actually be a change with a much
> larger impact, both in terms of code duplication and of verifying
> correctness.

I think AppArmor is a horribly stupid idea to start with, and I'm not
willing up to mess up the kernel tree for it.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/