From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424331AbcBQWr0 (ORCPT ); Wed, 17 Feb 2016 17:47:26 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:37385 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423979AbcBQWrZ (ORCPT ); Wed, 17 Feb 2016 17:47:25 -0500 Date: Wed, 17 Feb 2016 14:53:37 -0800 From: Andrew Morton To: John Stultz Cc: Kees Cook , Thomas Gleixner , Arjan van de Ven , lkml , Oren Laadan , Ruchi Kandoi , Rom Lemarchand , Android Kernel Team Subject: Re: [PATCH 2/2] proc: Add /proc//timerslack_ns interface Message-Id: <20160217145337.9f640ce0.akpm@linux-foundation.org> In-Reply-To: References: <1455671191-32105-1-git-send-email-john.stultz@linaro.org> <1455671191-32105-3-git-send-email-john.stultz@linaro.org> <20160217113547.6487174b9c6d365927095080@linux-foundation.org> <20160217121813.8a49986ebf66cedaf43e901b@linux-foundation.org> X-Mailer: Sylpheed 2.7.1 (GTK+ 2.18.9; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 17 Feb 2016 14:29:29 -0800 John Stultz wrote: > On Wed, Feb 17, 2016 at 12:18 PM, Andrew Morton > wrote: > > On Wed, 17 Feb 2016 12:09:08 -0800 Kees Cook wrote: > >> On Wed, Feb 17, 2016 at 11:35 AM, Andrew Morton > >> > The procfs file's permissions are 0644, yes? So a process's > >> > timer_slack is world-readable? hm. > >> > >> This should be 600, IMO. > > > > Sounds safer. > > So I've gone ahead and addressed this and the other feedback you had. > But this bit made me realize that I may have missed a key aspect to > the interface that Android needs. > > In particular, the whole point here is to allow a controlling task to > modify other tasks' timerslack to limit background tasks' power usage > (and to modify them back to normal when the background tasks become > foreground tasks). Note that on android different tasks run as > different users. > > Currently, the controlling process has minimally elevated privileges > (CAP_SYS_NICE). The initial review suggested those privileges should > be higher (PTRACE_MODE_ATTACH), which I've implemented. However, I'm > realizing that by moving to the proc interface, the filesystem > permissions here put yet another barrier in the way. > > While the 600 permissions makes initial sense, it does limit these > controlling tasks with extra privileges (though not root) from > modifying the timerslack, since they cannot open the file to begin > with. > > So.... Does world writable (plus the PTRACE_MODE_ATTACH_FSCREDS check) > make more sense here? Or is there a better way for a system to tweak > the default permissions for procfs entries? (And if so, does that > render the PTRACE_MODE_ATTACH... check unnecessary?). I can't immediately think of a problem with it. Could we check PTRACE_MODE_ATTACH_FSCREDS in open() to prevent bad guys from reading our timerslack?