From: ebiederm@xmission.com (Eric W. Biederman)
To: Pavel Emelyanov <xemul@openvz.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
"Rafael J. Wysocki" <rjw@sisk.pl>, Pavel Machek <pavel@ucw.cz>,
kernel list <linux-kernel@vger.kernel.org>,
netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH 2.6.24-rc3] Fix /proc/net breakage
Date: Tue, 27 Nov 2007 05:36:49 -0700 [thread overview]
Message-ID: <m1hcj7lva6.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <474BFD83.6060500@openvz.org> (Pavel Emelyanov's message of "Tue, 27 Nov 2007 14:20:35 +0300")
Pavel Emelyanov <xemul@openvz.org> writes:
> [snip]
>
>>
>> Well I clearly goofed when I added the initial network namespace support
>> for /proc/net. Currently things work but there are odd details visible
>> to user space, even when we have a single network namespace.
>>
>> Since we do not cache proc_dir_entry dentries at the moment we can
>> just modify ->lookup to return a different directory inode depending
>> on the network namespace of the process looking at /proc/net, replacing
>> the current technique of using a magic and fragile follow_link method.
>>
>> To accomplish that this patch:
>> - introduces a shadow_proc method to allow different dentries to
>> be returned from proc_lookup.
>> - Removes the old /proc/net follow_link magic
>> - Fixes a weakness in our not caching of proc generic dentries.
>>
>> As shadow_proc uses a task struct to decided which dentry to return we
>> can go back later and fix the proc generic caching without modifying any code
> that
>> uses the shadow_proc method.
>>
>> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
>
> Thanks, Eric.
>
> Much better ('find /proc' works and so does 'ls ..'), but one
> issue is still unsolved :(
>
> I mentioned the program, that opens the directory and dumps the
> content of the /proc/self/fd. Here it is (stupid but simple):
The cause is totally different this time, and is not limited
to /proc/net. But this is the only side effect of the changes now.
I used the one line version of your test program to confirm this:
$ cd /proc/driver/
$ ls -l /proc/self/fd/100 100< .
lr-x------ 1 eric eric 64 Nov 27 05:06 /proc/self/fd/100 -> /proc/driver/
$ ls -l /proc/self/fd/100 100< .
lr-x------ 1 eric eric 64 Nov 27 05:07 /proc/self/fd/100 -> /proc/driver (deleted)
What is happening is that the aggressive non-caching logic is dropping
the dentries and thus they show up as deleted. I.e. When something
triggers another lookup of that dentry revalidate drops the old
dentry.
This actually fixes a race in /proc today where if you open a file,
remove the module for it, reload the module for that file, and then
attempt to access it, lookup will return the old dentry with the
old fops (even if there is not a current version of that file).
kill_proc_inodes current keeps us from using the old version of
the file_operations for directories (because it removes them) but
it does not prevent this DOS attack where keeping a proc file open
always ensures everyone will see the old version.
Given that the behavior seems more correct then what we have currently
I can live with files showing up as deleted from time to time.
Ultimately the fix is to correct the caching logic in
fs/proc/generic.c to only drop dentries when necessary and then
the deleted markers will only show up when the file or directory
really goes away.
I don't expect user space will care about the semi-legitimate
(deleted) marks. So I don't think this one down side will be a big
deal for 2.6.24.
Eric
next prev parent reply other threads:[~2007-11-27 12:38 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-19 19:10 2.6.24-rc3: find complains about /proc/net Pavel Machek
2007-11-19 22:04 ` Rafael J. Wysocki
2007-11-20 15:51 ` Pavel Emelyanov
2007-11-20 21:52 ` Eric W. Biederman
2007-11-20 21:59 ` Ingo Molnar
2007-11-20 22:17 ` Eric W. Biederman
2007-11-20 22:35 ` Ingo Molnar
2007-11-20 22:54 ` Roland McGrath
2007-11-20 23:01 ` Ingo Molnar
2007-11-20 23:06 ` Guillaume Chazarain
2007-11-20 23:26 ` Roland McGrath
2007-11-20 23:32 ` Ulrich Drepper
2007-11-20 23:45 ` Ingo Molnar
2007-11-20 23:51 ` Roland McGrath
2007-11-21 0:47 ` Eric W. Biederman
2007-11-21 1:01 ` Rafael J. Wysocki
2007-11-21 0:41 ` Eric W. Biederman
2007-11-20 23:43 ` Ingo Molnar
2007-11-20 22:41 ` [PATCH] proc: Fix the threaded /proc/self Eric W. Biederman
2007-11-20 22:58 ` Guillaume Chazarain
2007-11-20 23:03 ` Ingo Molnar
2007-11-21 1:19 ` 2.6.24-rc3: find complains about /proc/net Eric W. Biederman
2007-11-21 6:36 ` Eric W. Biederman
2007-11-21 9:36 ` Pavel Emelyanov
2007-11-24 23:34 ` [CFT][PATCH] proc_net: Remove userspace visible changes Eric W. Biederman
2007-11-26 8:43 ` Eric W. Biederman
2007-11-26 22:17 ` [PATCH 2.6.24-rc3] Fix /proc/net breakage Eric W. Biederman
2007-11-27 11:20 ` Pavel Emelyanov
2007-11-27 12:36 ` Eric W. Biederman [this message]
2007-12-07 4:51 ` David Woodhouse
2007-12-07 10:23 ` Andrew Morton
2007-12-07 11:11 ` Denis V. Lunev
2007-12-27 17:40 ` Andreas Mohr
2007-12-27 18:41 ` Alexey Dobriyan
2007-12-27 22:17 ` Andreas Mohr
2007-12-28 6:22 ` Alexey Dobriyan
2007-12-28 7:21 ` Andreas Mohr
2007-12-30 16:14 ` [usb regression] " Ingo Molnar
2007-12-30 20:34 ` Alan Stern
2007-12-31 5:25 ` Greg KH
2007-12-31 17:49 ` Alan Stern
2007-12-31 19:26 ` Greg KH
2008-01-02 6:00 ` Greg KH
2008-01-02 6:13 ` Andreas Mohr
2008-01-02 7:14 ` Greg KH
2008-01-02 15:56 ` Alan Stern
2008-01-02 18:48 ` David Brownell
2008-01-02 6:04 ` Andreas Mohr
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=m1hcj7lva6.fsf@ebiederm.dsl.xmission.com \
--to=ebiederm@xmission.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=rjw@sisk.pl \
--cc=torvalds@linux-foundation.org \
--cc=xemul@openvz.org \
/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
all inboxes | Powered by JetHome®