Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754016AbbGOXkH (ORCPT ); Wed, 15 Jul 2015 19:40:07 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:24403 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753905AbbGOXkF (ORCPT ); Wed, 15 Jul 2015 19:40:05 -0400 Date: Wed, 15 Jul 2015 16:39:22 -0700 From: Calvin Owens To: Andrew Morton CC: Alexey Dobriyan , "Eric W. Biederman" , Al Viro , Miklos Szeredi , Zefan Li , Oleg Nesterov , Joe Perches , David Howells , , , , Andy Lutomirski , Cyrill Gorcunov , "Kirill A. Shutemov" Subject: Re: [PATCH v7] procfs: Always expose /proc//map_files/ and make it readable Message-ID: <20150715233922.GA3509821@mail.thefacebook.com> References: <1433821173-2804704-1-git-send-email-calvinowens@fb.com> <1434681138-2968009-1-git-send-email-calvinowens@fb.com> <20150715152149.0f6158c2c2f806d0be44c110@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline In-Reply-To: <20150715152149.0f6158c2c2f806d0be44c110@linux-foundation.org> User-Agent: Mutt/1.5.20 (2009-12-10) X-Originating-IP: [192.168.52.123] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.14.151,1.0.33,0.0.0000 definitions=2015-07-15_07:2015-07-15,2015-07-15,1970-01-01 signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2884 Lines: 67 On Wednesday 07/15 at 15:21 -0700, Andrew Morton wrote: > On Thu, 18 Jun 2015 19:32:18 -0700 Calvin Owens wrote: > > > Currently, /proc//map_files/ is restricted to CAP_SYS_ADMIN, and > > is only exposed if CONFIG_CHECKPOINT_RESTORE is set. > > > > Each mapped file region gets a symlink in /proc//map_files/ > > corresponding to the virtual address range at which it is mapped. The > > symlinks work like the symlinks in /proc//fd/, so you can follow > > them to the backing file even if that backing file has been unlinked. > > > > Currently, files which are mapped, unlinked, and closed are impossible > > to stat() from userspace. Exposing /proc//map_files/ closes this > > functionality "hole". > > > > Not being able to stat() such files makes noticing and explicitly > > accounting for the space they use on the filesystem impossible. You can > > work around this by summing up the space used by every file in the > > filesystem and subtracting that total from what statfs() tells you, but > > that obviously isn't great, and it becomes unworkable once your > > filesystem becomes large enough. > > > > This patch moves map_files/ out from behind CONFIG_CHECKPOINT_RESTORE, > > and adjusts the permissions enforced on it as follows: > > proc_pid_follow_link() got changed while you weren't looking, causing > > fs/proc/base.c: In function 'proc_map_files_follow_link': > fs/proc/base.c:1963: warning: passing argument 2 of 'proc_pid_follow_link' from incompatible pointer type > fs/proc/base.c:1578: note: expected 'void **' but argument is of type 'struct nameidata *' > fs/proc/base.c:1963: warning: return discards qualifiers from pointer target type > fs/proc/base.c: At top level: > fs/proc/base.c:1971: warning: initialization from incompatible pointer type > > I just changed it to pass NULL: Thanks for cleaning this up, I'll make sure to check outstanding patches against new -rcs and -nexts in the future. Thanks, Calvin > --- a/fs/proc/base.c~procfs-always-expose-proc-pid-map_files-and-make-it-readable-fix > +++ a/fs/proc/base.c > @@ -1955,12 +1955,13 @@ struct map_files_info { > * symlinks may be used to bypass permissions on ancestor directories in the > * path to the file in question. > */ > -static void *proc_map_files_follow_link(struct dentry *dentry, struct nameidata *nd) > +static void * > +proc_map_files_follow_link(struct dentry *dentry, struct nameidata *nd) > { > if (!capable(CAP_SYS_ADMIN)) > return ERR_PTR(-EPERM); > > - return proc_pid_follow_link(dentry, nd); > + return proc_pid_follow_link(dentry, NULL); > } > > /* > _ > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/