From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Lutomirski Subject: Re: [PATCH 1/9] procfs: use flags to deny or allow access to /proc//$entry Date: Mon, 26 May 2014 09:57:16 -0700 Message-ID: References: <1401110850-3552-1-git-send-email-tixxdz@opendz.org> <1401110850-3552-2-git-send-email-tixxdz@opendz.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Cc: Kees Cook , Andrew Morton , Alexey Dobriyan , "Eric W. Biederman" , Al Viro , Linus Torvalds , Ingo Molnar , Oleg Nesterov , Peter Zijlstra , LKML , Linux FS Devel To: Djalal Harouni Return-path: In-Reply-To: <1401110850-3552-2-git-send-email-tixxdz@opendz.org> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Mon, May 26, 2014 at 6:27 AM, Djalal Harouni wrote: > Add the deny or allow flags, so we can perform proper permission checks > and set the result accordingly. These flags are needed in case we have > to cache the result of permission checks that are done during ->open() > time. Later during ->read(), we can decide to allow or deny the read(). > > The pid entries that need these flags are: > /proc//stat > /proc//wchan > /proc//maps (will be handled in next patches). > > These files are world readable, userspace depend on that. To prevent > ASLR leaks and to avoid breaking userspace, we follow this scheme: > > a) Perform permission checks during ->open() > b) Cache the result of a) and return success > c) Recheck the cached result during ->read() Why is (c) needed? > > /* > + * Flags used to deny or allow current to access /proc//$entry > + * after proper permission checks. > + */ > +enum { > + PID_ENTRY_DENY = 0, /* Deny access */ > + PID_ENTRY_ALLOW = 1, /* Allow access */ > +}; I think this would be less alarming if this were: #define PID_ENTRY_DENY ((void *)1UL) #define PID_ENTRY_ALLOW ((void *)2UL) Also, I don't like DENY and ALLOW. It's not denying and allowing. How about PID_ENTRY_OPENER_MAY_PTRACE and PID_ENTRY_OPENER_MAY_NOT_PTRACE? --Andy