From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:38570 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752150AbcJCQDe (ORCPT ); Mon, 3 Oct 2016 12:03:34 -0400 Date: Mon, 3 Oct 2016 18:02:20 +0200 From: Oleg Nesterov To: "Eric W. Biederman" Cc: Jann Horn , Alexander Viro , Roland McGrath , John Johansen , James Morris , "Serge E. Hallyn" , Paul Moore , Stephen Smalley , Eric Paris , Casey Schaufler , Kees Cook , Andrew Morton , Janis Danisevskis , Seth Forshee , Thomas Gleixner , Benjamin LaHaise , Ben Hutchings , Andy Lutomirski , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org, security@kernel.org Subject: Re: [PATCH v2 1/8] exec: introduce cred_guard_light Message-ID: <20161003160219.GB4758@redhat.com> References: <1474663238-22134-1-git-send-email-jann@thejh.net> <1474663238-22134-2-git-send-email-jann@thejh.net> <20160930153505.GA17573@redhat.com> <87k2dtp7jj.fsf@x220.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87k2dtp7jj.fsf@x220.int.ebiederm.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 09/30, Eric W. Biederman wrote: > > Oleg Nesterov writes: > > > And I think that cred_guard_mutex is already over-used in fs/proc. Say, > > I think lock_trace() must die, I simply can't understand why it is useful. > > > > Suppose we modify, say, proc_pid_stack() to do > > > > save_stack_trace_tsk(task, &trace); > > if (!ptrace_may_access(task, ...)) > > goto return -EPERM; > > > > for (i = 0; i < trace.nr_entries; i++) > > seq_printf(...); > > > > return 0; > > > > is there any problem if it shows some trace before setuid exec does > > install_exec_creds() ? > > You should make certain that the mm doesn't change in that picture, > perhaps like /proc//mem does. Why? We do not care I think, /proc/pid/stack has nothing to do with task->mm. OK, we can use __ptrace_may_access() and call save_stack_trace_tsk() under task_lock(), but I don't understand why should we worry. And again, do you see any security problem with the code above? Yes, it is "racy" but I think it is fine to occasionally succeed when it races with credentials change. I fail to understand why the current code abuses cred_guard_mutex to close the race with setuid exec. Oleg.