From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6D30C2BAEE for ; Wed, 11 Mar 2020 18:59:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7A44E20786 for ; Wed, 11 Mar 2020 18:59:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="cEKMyEQq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730734AbgCKS7l (ORCPT ); Wed, 11 Mar 2020 14:59:41 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:38367 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730977AbgCKS7k (ORCPT ); Wed, 11 Mar 2020 14:59:40 -0400 Received: by mail-pf1-f193.google.com with SMTP id z5so1852577pfn.5 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=FcVmR69R/PN0rZROjCirPLOOJFQC3TAZJiC+uA7hsekX0vbr99hEs1HSAg0JWqplhJ J7iVnAOhEj63bMNwqBkBPILHSUXm2b7k6h4lCaDkTO+hGBwGUasdIiPaXMaOwwGSw46Q pwFhW/10J9bk6F2aBtiJvHFftFBKNvLB9sN2TsUdqHW9OeC/dFmA/mod+ilR6/rPy/lI P1yvVJPSaa3O+XNhjeuxtBm6aUCLOTZIe1IrEhrpcyNEg/FVVoa3ndvCYtga8kz0eWBb /mKoie/UR5ynwpC1yxxpAJvqiXb2ihgwi4Rwl1ikqxa1o8aIZNdJX9bGG8DAmj5QtDAW 7nWQ== X-Gm-Message-State: ANhLgQ1ydoJojG9XVeWZUMOCZiF0bcaTcaD+71NkrPEuiCReBS68w4of 6nKvvVUngz2rpUB8gSeL+6Z+SQ== X-Google-Smtp-Source: ADFU+vtJO9kiWA5K8fGpjclsKmfTQP+X/SjYQbVg72YZU8IhHMuYBgcwUyPQP2L+QH+kQwQAMxmaFA== 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-api-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-api@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