[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <871seakg0u.fsf@xmission.com>
Date: Thu, 17 May 2018 00:28:01 -0500
From: ebiederm@...ssion.com (Eric W. Biederman)
To: Christoph Hellwig <hch@....de>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
Alexey Dobriyan <adobriyan@...il.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jslaby@...e.com>,
Alessandro Zummo <a.zummo@...ertech.it>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
linux-acpi@...r.kernel.org, drbd-dev@...ts.linbit.com,
linux-ide@...r.kernel.org, netdev@...r.kernel.org,
linux-rtc@...r.kernel.org, megaraidlinux.pdl@...adcom.com,
linux-scsi@...r.kernel.org, devel@...verdev.osuosl.org,
linux-afs@...ts.infradead.org, linux-ext4@...r.kernel.org,
jfs-discussion@...ts.sourceforge.net,
netfilter-devel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 11/40] ipv6/flowlabel: simplify pid namespace lookup
Christoph Hellwig <hch@....de> writes:
> On Sat, May 05, 2018 at 07:37:33AM -0500, Eric W. Biederman wrote:
>> Christoph Hellwig <hch@....de> writes:
>>
>> > The shole seq_file sequence already operates under a single RCU lock pair,
>> > so move the pid namespace lookup into it, and stop grabbing a reference
>> > and remove all kinds of boilerplate code.
>>
>> This is wrong.
>>
>> Move task_active_pid_ns(current) from open to seq_start actually means
>> that the results if you pass this proc file between callers the results
>> will change. So this breaks file descriptor passing.
>>
>> Open is a bad place to access current. In the middle of read/write is
>> broken.
>>
>>
>> In this particular instance looking up the pid namespace with
>> task_active_pid_ns was a personal brain fart. What the code should be
>> doing (with an appropriate helper) is:
>>
>> struct pid_namespace *pid_ns = inode->i_sb->s_fs_info;
>>
>> Because each mount of proc is bound to a pid namespace. Looking up the
>> pid namespace from the super_block is a much better way to go.
>
> What do you have in mind for the helper? For now I've thrown it in
> opencoded into my working tree, but I'd be glad to add a helper.
>
> struct pid_namespace *proc_pid_namespace(struct inode *inode)
> {
> // maybe warn on for s_magic not on procfs??
> return inode->i_sb->s_fs_info;
> }
That should work. Ideally out of line for the proc_fs.h version.
Basically it should be a cousin of PDE_DATA.
Eric
Powered by blists - more mailing lists