Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp846058ybh; Wed, 11 Mar 2020 12:01:27 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvZCB4ZE2ZuoqDgHiX2IvsknD7+uJmJhHvGnfA+jShix83sjxL6OcFA/XGmQVugs0pZUFGy X-Received: by 2002:a05:6830:1144:: with SMTP id x4mr3437003otq.59.1583953287059; Wed, 11 Mar 2020 12:01:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583953287; cv=none; d=google.com; s=arc-20160816; b=BWLYWgsBEnJjFBYouvvRmhAyg4iGSSQ2eKCrGGA34T+RNEGt5Fpu4Qua3mxX6MF2tl yUUHe6POqe9nkViu9I16MPrHQNBpJLm5cac3FoOSvSjlKVAhP0KQbhdBP8lQxohyuqX6 y0qugL5DaGiny7CDMdAT9qbwmg6bHD0D3OEFvbUUSguZqChLN8qtzEugA0HfY2jUDnMP +1cca+2fL74p0FurPJTfJQIk7mJgwVwAdwnMPee0i/j/VT1SHSnX7HiPbJU8tTzV5kF4 EEtN+smumdIacts2CkDES00S0TiyA6KVgm3BFP20ciCluVhZjUs96zxLKSNaQblMZ8D0 FM0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ZLCmQGD2nYRFngV6EM0JVcVHQdhqOzhhGYnboeZx+J8=; b=Lk/mNU39Y/iSa6F1JZXtIYL1PZRYnPMBpNkRmdo22veTFz/oeKEN+OIkcdGj+ZmrRr DupYfjCal8EPSrnJHaliBNLS43woAKGaACfoyJ6e7JvB+5icP0x+6IJeumTzWLdNkLz8 zWWNg6sv5ymav7KaXhaan5Zqnn7QyITeM4Okrhq6X1Byv68tpeAZVn5SWnr7JzgThO5x SwdwcRfsUYOHRULLPPNfJhp8FKBiHDkJ88O7p7vgDQviodyGdSgNY8KXdncki8uCjBNq wOx35UgQcXjSWQLg5zi9pkmGHCd1sH/6GFJezOLscsZetiEzzU6ziS1x0vlx4gM40vul mCXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cEKMyEQq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q3si1626315otc.141.2020.03.11.12.01.12; Wed, 11 Mar 2020 12:01:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cEKMyEQq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730993AbgCKS7l (ORCPT + 99 others); Wed, 11 Mar 2020 14:59:41 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:33046 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730944AbgCKS7k (ORCPT ); Wed, 11 Mar 2020 14:59:40 -0400 Received: by mail-pg1-f196.google.com with SMTP id m5so1704040pgg.0 for ; Wed, 11 Mar 2020 11:59:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ZLCmQGD2nYRFngV6EM0JVcVHQdhqOzhhGYnboeZx+J8=; b=cEKMyEQqNjfrWLH7u32sjCQs4hChIhKsIZ0FmnXtkC4MfbJpY9o3rNlK4rYMDjh+45 TETh5DQbErQLvzWXaM972+gECBSACcKku69Qsqowk2Q+HH8YsxB50x9QUNsub6EDIwnL 4s6qwTsKVQ00/U+uZE5pymcXQkSM0FEMRbO4o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZLCmQGD2nYRFngV6EM0JVcVHQdhqOzhhGYnboeZx+J8=; b=SU6+wY/GKBH/ANN/II71OBVnqUQQ6eIjxUzIYeYbxXsgSZ9bp//n8nks86aTGvJuhc fwfVSlZEqMNL1q3KUouHSJTr4bjXfcrPEUdfPHAvasxNC6M4rPQhYZ6wR/i5Io9Mo415 KQvdFPoRB7kxVs8D0hBW5zSffIt3soWuXC2mQcP/kI+dQKlYaKPH9cpf7+Rt/MI4U2xm VcxDf/57UfN3j1GoGbULydnGhuu1XFosp5qsSzzy+HHB8vZSx4sg/6MOya4RoUE4RBnb qwh5TwQwojj5Gdk2bs3gev+PaI/6eo8bPH/7K+Gs1gfWWAUAwJ+WnoqWCzmgwsbHaejd nwxw== X-Gm-Message-State: ANhLgQ3uJMW2RiZa8t3CUYyr/yvar4Q+Vx8fWXwof5a82RKaHr0qdqjU Mg1mmiCh8QCBdojS5Jb55wuSvg== X-Received: by 2002:aa7:988f:: with SMTP id r15mr4221796pfl.252.1583953179891; Wed, 11 Mar 2020 11:59:39 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 11sm1155601pfv.43.2020.03.11.11.59.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2020 11:59:39 -0700 (PDT) Date: Wed, 11 Mar 2020 11:59:38 -0700 From: Kees Cook To: Bernd Edlinger Cc: "Eric W. Biederman" , Christian Brauner , Jann Horn , Jonathan Corbet , Alexander Viro , Andrew Morton , Alexey Dobriyan , Thomas Gleixner , Oleg Nesterov , Frederic Weisbecker , Andrei Vagin , Ingo Molnar , "Peter Zijlstra (Intel)" , Yuyang Du , David Hildenbrand , Sebastian Andrzej Siewior , Anshuman Khandual , David Howells , James Morris , Greg Kroah-Hartman , Shakeel Butt , Jason Gunthorpe , Christian Kellner , Andrea Arcangeli , Aleksa Sarai , "Dmitry V. Levin" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "stable@vger.kernel.org" , "linux-api@vger.kernel.org" Subject: Re: [PATCH 2/4] proc: Use new infrastructure to fix deadlocks in execve Message-ID: <202003111159.5D5B240F@keescook> References: <87r1y12yc7.fsf@x220.int.ebiederm.org> <87k13t2xpd.fsf@x220.int.ebiederm.org> <87d09l2x5n.fsf@x220.int.ebiederm.org> <871rq12vxu.fsf@x220.int.ebiederm.org> <877dzt1fnf.fsf@x220.int.ebiederm.org> <875zfcxlwy.fsf@x220.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 10, 2020 at 06:45:32PM +0100, Bernd Edlinger wrote: > This changes lock_trace to use the new exec_update_mutex > instead of cred_guard_mutex. > > This fixes possible deadlocks when the trace is accessing > /proc/$pid/stack for instance. > > This should be safe, as the credentials are only used for reading, > and task->mm is updated on execve under the new exec_update_mutex. > > Signed-off-by: Bernd Edlinger Reviewed-by: Kees Cook -Kees > --- > fs/proc/base.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/fs/proc/base.c b/fs/proc/base.c > index ebea950..4fdfe4f 100644 > --- a/fs/proc/base.c > +++ b/fs/proc/base.c > @@ -403,11 +403,11 @@ static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns, > > static int lock_trace(struct task_struct *task) > { > - int err = mutex_lock_killable(&task->signal->cred_guard_mutex); > + int err = mutex_lock_killable(&task->signal->exec_update_mutex); > if (err) > return err; > if (!ptrace_may_access(task, PTRACE_MODE_ATTACH_FSCREDS)) { > - mutex_unlock(&task->signal->cred_guard_mutex); > + mutex_unlock(&task->signal->exec_update_mutex); > return -EPERM; > } > return 0; > @@ -415,7 +415,7 @@ static int lock_trace(struct task_struct *task) > > static void unlock_trace(struct task_struct *task) > { > - mutex_unlock(&task->signal->cred_guard_mutex); > + mutex_unlock(&task->signal->exec_update_mutex); > } > > #ifdef CONFIG_STACKTRACE > -- > 1.9.1 -- Kees Cook