Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1065875ybh; Tue, 10 Mar 2020 13:57:06 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvO3MI3MYdCITFJLjtzjHeCNOXdqEyNYdlbn6NGjC4IjPPFdg3RatUTrz0GZtf+wZvGnF/s X-Received: by 2002:a9d:6c05:: with SMTP id f5mr7665472otq.232.1583873826596; Tue, 10 Mar 2020 13:57:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583873826; cv=none; d=google.com; s=arc-20160816; b=dB1LoIWATfIJ83HKACWRgE3AxwAVrICGU0S3gHzU6FyX9MXCj3axxcWL9f/zFdsVac aME3Xjn9JfsvKRv+bFpDvGrOqK27BvSiBplORT/FgARv5zWRWOH5pS4zX+DHIRafcCOI +kOqrqi+f1sgHLKAjfiRYNRfSyOIsMw0cV5edMR7TeX5M9rbcfhjVlqA2exZtT6N6g94 DgHgtmqc9dweNPqG6m+MYt2B4CnKYpGG2Xn9qDCkIp/KCy5AZel4OgnpzBHO5uBaskR2 h1HlDU5HRqXKNHRekU8EsUXkam6ZPzh55uhrW5yoZYRBXqZQyBcSXbsmW1Bl+z3FX72f sC2A== 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=XCee8pfoSpfKAyMHOiluaFP5r2d1cxa5sV/2QbU588A=; b=w1UCxJDjWNYz6uV0LqB9zyA4yZzzc3BHE8NTuNDxzbQr8luIdKax7libNxxCOwj2WK fDN8wxeL0A7Hb8NeziyodoPCtfJZB+MJIu7pAhfYJg65Y8SDhjfxrvRmDdlMQ3osEEm9 0pdqButICON2DEU9FBVxy9M4zJiElKWfWcMOvICapboLD+3/6M3IywdTPn9Dfgxr0eRI D7fhbV+PRbSO50kXX77S9KHKhabdiltJ3ym3CNDKQ3G6rzf/LbwnKX7C07tyWZPigmBW XcUrBNTMUE16RLLeG0Wk4PrjIukQN1PzfnfcD1hTbxuOMNaJMkFHh7X7hj21yCkaIjfl kWzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HoWjp37P; 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 e2si3704653otr.30.2020.03.10.13.56.54; Tue, 10 Mar 2020 13:57:06 -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=HoWjp37P; 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 S1727629AbgCJUz6 (ORCPT + 99 others); Tue, 10 Mar 2020 16:55:58 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:44945 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727496AbgCJUz5 (ORCPT ); Tue, 10 Mar 2020 16:55:57 -0400 Received: by mail-pf1-f195.google.com with SMTP id b72so17975pfb.11 for ; Tue, 10 Mar 2020 13:55:56 -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=XCee8pfoSpfKAyMHOiluaFP5r2d1cxa5sV/2QbU588A=; b=HoWjp37PtFeniqj35yD1VTg9ADYkej22MfwMB13TIeFC7foF85mFkueDcopx5DNEc6 Gnjfy52P9IdsdWJrxkP6VvsqgV7Ue9g2VZYhaEy0A6IxGTIL6JYTjbsqPyWEMiArT+m7 INOy2/C/ssYCuaWafqLRtBe62wmczU69h1pvQ= 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=XCee8pfoSpfKAyMHOiluaFP5r2d1cxa5sV/2QbU588A=; b=oKUTDr+dN15UUg2P4oJR5/7xxx/hxDCq/JqxH+7akR7RXtXiUJpsgW9A8f/YZfqsNq yqi1u39Qni7tK1XPNCuv1ATfM1+sPYmJ5f+5LSeGvsVe77/x/kavfgHauf3Zc5huRl4P mnu3zTZWK6Iavz/2Sy7hvD88qtIaKdGaeuWhrm418IkV4LWbIRLQwMOC9EWZxQt37FK+ L1Y6ZfF5EheHncZxWrSpEjDa9dKKLeZkSy9GR8k+U6MJ9zIjg5WSmwaw0ub45+Y1kjQz Kpguziwbt0k6DmoPp/DmGEhgKKRHk+kfATstJBZRtoyPoWXUi8X/Uz96wZkL4PRRtQb4 KzfQ== X-Gm-Message-State: ANhLgQ3qeCF1govuFfM66YOPTvmATuQ6cBuKIWawwGxbXCmfFH494LhQ 1IlWfJGscBMaEOwkjEVz4hIOVg== X-Received: by 2002:a63:450b:: with SMTP id s11mr22416425pga.45.1583873756120; Tue, 10 Mar 2020 13:55:56 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id w138sm5130844pff.145.2020.03.10.13.55.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2020 13:55:55 -0700 (PDT) Date: Tue, 10 Mar 2020 13:55:54 -0700 From: Kees Cook To: "Eric W. Biederman" Cc: Bernd Edlinger , 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 v2 5/5] exec: Add a exec_update_mutex to replace cred_guard_mutex Message-ID: <202003101352.28BE3BEB4@keescook> References: <87v9ne5y4y.fsf_-_@x220.int.ebiederm.org> <87zhcq4jdj.fsf_-_@x220.int.ebiederm.org> <878sk94eay.fsf@x220.int.ebiederm.org> <87r1y12yc7.fsf@x220.int.ebiederm.org> <87k13t2xpd.fsf@x220.int.ebiederm.org> <87d09l2x5n.fsf@x220.int.ebiederm.org> <871rq12vxu.fsf@x220.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <871rq12vxu.fsf@x220.int.ebiederm.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 09, 2020 at 02:02:37PM -0500, Eric W. Biederman wrote: > exec: Add exec_update_mutex to replace cred_guard_mutex > > The cred_guard_mutex is problematic as it is held over possibly > indefinite waits for userspace. The possilbe indefinite waits for > userspace that I have identified are: The cred_guard_mutex is held in > PTRACE_EVENT_EXIT waiting for the tracer. The cred_guard_mutex is > held over "put_user(0, tsk->clear_child_tid)" in exit_mm(). The > cred_guard_mutex is held over "get_user(futex_offset, ...") in > exit_robust_list. The cred_guard_mutex held over copy_strings. I suspect you're not trying to make a comprehensive list here, but do you want to mention seccomp too (since it's yet another weird case). > [...] > Holding a mutex over any of those possibly indefinite waits for > userspace does not appear necessary. Add exec_update_mutex that will > just cover updating the process during exec where the permissions and > the objects pointed to by the task struct may be out of sync. Should the specific resources be pointed out here? creds, mm, ... ? But otherwise, yup, looks sane: Reviewed-by: Kees Cook -- Kees Cook