From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cyrill Gorcunov Subject: Re: [patch 2/2] fs, proc: Introduce the /proc//map_files/ directory v12 Date: Wed, 14 Sep 2011 20:00:19 +0400 Message-ID: <20110914160018.GW25367@sun> References: <20110913211359.674453213@openvz.org> <20110913212447.918816776@openvz.org> <20110913235222.043927b3.akpm@linux-foundation.org> <20110914105607.GP25367@sun> <20110914111437.GA22516@atrey.karlin.mff.cuni.cz> <20110914113912.GQ25367@sun> <20110914134405.GV25367@sun> <20110914144841.GA7906@albatros> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Pavel Machek , Andrew Morton , linux-kernel@vger.kernel.org, containers@lists.osdl.org, linux-fsdevel@vger.kernel.org, Kirill Shutemov , Pavel Emelyanov , James Bottomley , Nathan Lynch , Zan Lynx , Daniel Lezcano , Tejun Heo , Alexey Dobriyan , Al Viro , Andrew Morton To: Vasiliy Kulikov Return-path: Content-Disposition: inline In-Reply-To: <20110914144841.GA7906@albatros> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Wed, Sep 14, 2011 at 06:48:41PM +0400, Vasiliy Kulikov wrote: ... > > Actually now I see the difference between having something mapped and > having an _fd_ of this something. > > Relevant code: > > +static struct dentry * > +proc_map_files_instantiate(struct inode *dir, struct dentry *dentry, > + struct task_struct *task, const void *ptr) > +{ > ... > + inode->i_mode = S_IFLNK; > + > + if (file->f_mode & FMODE_READ) > + inode->i_mode |= S_IRUSR | S_IXUSR; > + if (file->f_mode & FMODE_WRITE) > + inode->i_mode |= S_IWUSR | S_IXUSR; > > > If you have a write mmap area, but no fd, you may not trunc a file; with > map_files/ you may get an fd and ftrunc it. > This stands for anonymous memory, and if you have enough rights to access the task this ftruncate is the last problem (since having ptrace access to the task I _aready_ can trash various stuff inside, i dont need even bother to look into map_files/ or whatever). So I don't see how ftruncate migh harm you here? Cyrill