From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932297AbbA3BbP (ORCPT ); Thu, 29 Jan 2015 20:31:15 -0500 Received: from mail-oi0-f44.google.com ([209.85.218.44]:40828 "EHLO mail-oi0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757194AbbA3BbN (ORCPT ); Thu, 29 Jan 2015 20:31:13 -0500 MIME-Version: 1.0 In-Reply-To: <20150127212044.GO651@moon> References: <20150127094103.GK651@moon> <20150127212044.GO651@moon> Date: Thu, 29 Jan 2015 17:31:12 -0800 X-Google-Sender-Auth: nGOcvHE0UzLBczl_MIMYDEbIVso Message-ID: Subject: Re: [PATCH] docs: procs -- Describe /proc//map_files entry From: Kees Cook To: Cyrill Gorcunov Cc: LKML , Andrew Morton , "Kirill A. Shutemov" , Calvin Owens , Alexey Dobriyan , Oleg Nesterov , "Eric W. Biederman" , Al Viro , Peter Feiner , Pavel Emelyanov Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 27, 2015 at 1:20 PM, Cyrill Gorcunov wrote: > On Tue, Jan 27, 2015 at 11:50:49AM -0800, Kees Cook wrote: >> > + >> > +The main purpose of map_files directory is to be able to retrieve a set of >> > +memory mapped files in a fast way instead of parsing /proc//maps or >> > +/proc//smaps which contain a way more records. Same time one can open(2) >> > +mappings from the listings of two processes and comparing inodes figure out >> > +which anonymous memory areas are actually shared. >> >> Thanks for details! I still don't understand how this is used for >> checkpoint/restore when the mmap offset isn't shown. Can't a process >> map, say 4K of a file, from different offsets, and it would show up >> as: >> >> 400000-401000 -> /some/file >> 401000-402000 -> /some/file >> >> but there'd be no way to know how to restore that mapping? > > In criu we use a few sources of information (ie we scan not only > map_files, but have to use /proc/pid/smaps as well which has > offset for mapping). So at the end we have all picture under > our hands. > >> Are these symlinks "regular" symlinks, or are they something more >> special that bypasses VFS? If it bypasses VFS, I think adding and open >> check with PTRACE_ATTACH is needed, since now you're able to _modify_ >> the memory space of the target process instead of just reading it. > > Opening them goes same way as open of /proc/pid/fd/ entries as > far as I can tell. This should be enough, or I miss something > obvious here? Otherwise opening /proc/pid/fd/ should use > PTRACE_ATTACH instead of PTRACE_MODE_READ (as in proc_fd_access_allowed). I wouldn't object to enhancing the check to ATTACH from READ, but I worry what would break on the existing interface. -Kees -- Kees Cook Chrome OS Security