linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: mtk.manpages@googlemail.com, drepper@redhat.com,
	akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	linux-man@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] utimensat() non-conformances and fixes [v3]
Date: Tue, 3 Jun 2008 14:05:39 +0100	[thread overview]
Message-ID: <20080603130538.GA28946@ZenIV.linux.org.uk> (raw)
In-Reply-To: <E1K3VRJ-00065P-Pq@pomaz-ex.szeredi.hu>

On Tue, Jun 03, 2008 at 02:16:33PM +0200, Miklos Szeredi wrote:
> > > > > I'm not sure of the correct way to get the required nameidata (to do a
> > > > > vfs_permission() call) from the file descriptor.  Can you give me a
> > > > > tip there?
> > > > 
> > > > Could you point me at the right way of doing this?
> > > 
> > > You don't need nameidata for this at all.  Just call permission() with
> > > a NULL nameidata.
> > > 
> > > Ugly API?  Yes, will be cleaned up if we manage to find some common
> > > ground with the VFS maintainers.
> > 
> > As soon as I'm done with sysctls...
> 
> Can't you just do that independently (for now just put a
> d_find_alias() in there and be done with it)?  If you fix every piece
> of horrid code that you come across, it'll never be done...

There's not much left to do, actually...  FWIW, solution goes like this:
	* introduce structure on the classes of sysctls
(currently - root and per-network-namespace).  Namely "X is parent of Y",
with "if task T sees Y, it also sees X" as defining property.
	* when adding a sysctl table, find a "parent" one.  Which is to say,
find the deepest node on its stem that already is present in one of the
tables from our class or its ancestor classes.  That table will be our
parent and that node in it - attachment point.
	* delay freeing the table headers; have them refcounted and instead
of unconditionally freeing the sucker on unregistration just drop the refcount.

Now we can keep a pair (reference to header, pointer to ctl table entry)
as long as we hold refcount on header.  It won't affect unregistration
in any way.  And at any point we can try to acquire "active" (use) reference
to header.  If that succeeds, we know that
	+ unregistration hadn't been started
	+ unregistration won't be finished until we unuse the sucker
	+ table entry is alive and will stay alive until then.

So we can hold references to those puppies from inodes under /proc/sys
without blocking unregistration, etc.

What's more, we can associate such pair with each node in sysctl tree.
For non-directories that's obvious.  For directories, take the tree such
that directory belongs to tree \setminus parent of tree.

That's pretty much it.  Filesystem side is simple - we keep a pointer to
class of tree responsible for a node (see directly above) in dentry.
And ->d_compare() checks that class of candidate match should be visible
for task doing the lookup.  ->lookup() tries finding an entry with requested
name in sysctl table (found by directory inode) and in case of miss it goes
through the list of tables attached at that node, searching in those that
ought to be visible to us.

As the result, we have direct access to sysctl table entry right from inode,
maintain these references accross lookups without going through the contortions
done by current code and we do *NOT* use the same dentry for flipping between
unrelated sysctl nodes with different visibility...

  reply	other threads:[~2008-06-03 13:05 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-16  8:31 [PATCH] utimensat() non-conformances and fixes -- version 2 Michael Kerrisk
     [not found] ` <482D4665.4050401-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-05-16  8:34   ` Michael Kerrisk
2008-05-16 16:59   ` Miklos Szeredi
     [not found]     ` <E1Jx3Gw-0002eA-55-8f8m9JG5TPIdUIPVzhDTVZP2KDSNp7ea@public.gmane.org>
2008-05-17 19:57       ` Michael Kerrisk
2008-05-19  9:50         ` Miklos Szeredi
2008-05-19 10:12           ` Miklos Szeredi
2008-05-19 12:24           ` Michael Kerrisk
2008-05-19 13:17             ` Miklos Szeredi
2008-05-30 15:34       ` [PATCH] utimensat() non-conformances and fixes [v3] Michael Kerrisk
     [not found]         ` <48401E7E.9090304-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-05-30 16:37           ` Miklos Szeredi
2008-05-30 18:24             ` Michael Kerrisk
2008-05-30 19:22               ` Miklos Szeredi
     [not found]                 ` <E1K2ABK-0002ck-UT-8f8m9JG5TPIdUIPVzhDTVZP2KDSNp7ea@public.gmane.org>
2008-05-30 19:32                   ` Matthew Wilcox
     [not found]                     ` <20080530193207.GB28074-6jwH94ZQLHl74goWV3ctuw@public.gmane.org>
2008-05-30 20:08                       ` Miklos Szeredi
     [not found]               ` <cfd18e0f0805301124o5f217dden10726b268d05d81a-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-05-30 19:43                 ` Michael Kerrisk
     [not found]                   ` <cfd18e0f0805301243h7d862963o8320a2c1f48942ce-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-05-30 20:17                     ` Miklos Szeredi
     [not found]                       ` <E1K2B2k-0002kS-Cz-8f8m9JG5TPIdUIPVzhDTVZP2KDSNp7ea@public.gmane.org>
2008-05-31  5:28                         ` Michael Kerrisk
2008-05-30 20:17               ` Andrew Morton
2008-05-31  5:44                 ` Michael Kerrisk
2008-06-03 11:05         ` Michael Kerrisk
     [not found]           ` <cfd18e0f0806030405u1c32b114pa0fdd979f36f87fb-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-06-03 11:13             ` Miklos Szeredi
2008-06-03 11:22               ` Al Viro
2008-06-03 11:27                 ` Michael Kerrisk
2008-06-03 11:30                   ` Jamie Lokier
     [not found]                     ` <20080603113018.GA27955-yetKDKU6eevNLxjTenLetw@public.gmane.org>
2008-06-03 11:39                       ` Michael Kerrisk
2008-06-03 11:49                         ` Al Viro
     [not found]                           ` <20080603114921.GX28946-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2008-06-03 11:58                             ` Al Viro
2008-06-03 12:01                           ` Jamie Lokier
     [not found]                             ` <20080603120135.GA28905-yetKDKU6eevNLxjTenLetw@public.gmane.org>
2008-06-03 12:08                               ` Al Viro
     [not found]                                 ` <20080603120850.GZ28946-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2008-06-03 12:10                                   ` Jamie Lokier
     [not found]                 ` <20080603112221.GW28946-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2008-06-03 12:16                   ` Miklos Szeredi
2008-06-03 13:05                     ` Al Viro [this message]
2008-06-03 11:52               ` Michael Kerrisk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080603130538.GA28946@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=drepper@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-man@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=mtk.manpages@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).