Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4604860ybz; Tue, 28 Apr 2020 14:39:51 -0700 (PDT) X-Google-Smtp-Source: APiQypIYkKWq9x9TXiWl+YJGAByBrdUWYG4WJsUxWbcUp9iRlWfRUZiUxRgyEleTU3OpGRWQTDN0 X-Received: by 2002:a05:6402:22cd:: with SMTP id dm13mr12239746edb.56.1588109991180; Tue, 28 Apr 2020 14:39:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588109991; cv=none; d=google.com; s=arc-20160816; b=xmO9CU/JslUs7AiFAyvQr4KmEqwrurU6WeAg2ZvdBpvc+GZN4CwzPdPG4TXBLAC0qC R2eziit5yrN4Gktl1Y+9W23KiFUPaiIQgex7UZD5y2/J1x0EFB+xOI36//36QSttmXbQ pgZuuNHvTDDWDc5WmAQn80s6BnMlqE1lJrSKG4WegzOCvRnEmssH+iXt8BMW3WVClN2p uVsx69lGBXyqz9gfyfBEMSOVhY85k6flkFOf6GUUOOE9u7PPHt8ybjirUguUKE5m2wC+ MF9pAmliMKISSN1D/dFg8xfmhaf7J2e0EDDwTtPNTc+yZUO52z+PS0SXifWJ6TxuUOs4 HCsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=byKFbf6/4dlMbIbNFz7mzcw9H9m+Hnm7ILov1GMUf20=; b=x/4YSyzk2E5U+/FQAq+egmhh9G9NV9+CIS2HNZlG/P0zGV4U5kPUNb2kQ0K0xzar2F fkXtSNlMglzX9sdnnKKidqsq5NAysoAtslI+YG2PS1NKMPdZZq4gsobhuLdS3KXYTP2p FsGIukqMky9hfh/eouTk37pgi7gad1UGabTxExrgCKDGDoXPEwqXLnfrAd+rcE8mwKc6 6PlSjySNI8kcolPC/rEXaZzLbG5cDm4Ci8YZpWSN8oXkQxLzd5fyLIIG9NdgrbQQtqjG mh/A2iSoXqM0RSs0vFtuFw1a/ruG5+G5XpgKrC8X5sS4BuWdpUtW+vipmRutvrPVyCw8 CAlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=c5V540DX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oz15si2730908ejb.24.2020.04.28.14.39.28; Tue, 28 Apr 2020 14:39:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=c5V540DX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726861AbgD1VhF (ORCPT + 99 others); Tue, 28 Apr 2020 17:37:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726282AbgD1VhF (ORCPT ); Tue, 28 Apr 2020 17:37:05 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A292C03C1AC for ; Tue, 28 Apr 2020 14:37:04 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id e25so411294ljg.5 for ; Tue, 28 Apr 2020 14:37:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=byKFbf6/4dlMbIbNFz7mzcw9H9m+Hnm7ILov1GMUf20=; b=c5V540DX5qA6TExpwN82zDgCG62wkqprBQKUL+iKPh4WlRl/iYQMUxVRhV6k+zsiT3 LdHMx69qD/cpw5w0oGC5Q0372ifsczILIVK5UMTuNG1Z2+H4Chzy4fZoyZE2yARv/Qes lhUI/+ul3xggWnP/fqFH3tT8S0RA9vGMxghbU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=byKFbf6/4dlMbIbNFz7mzcw9H9m+Hnm7ILov1GMUf20=; b=h7VcGVp6sMHBovZThSDYbD/cxpPD4W3kWYc0thFf5ItVJmdepTS2r7TOMxj5HYCoRq llsrMsELzLvMLICt7NMsVQtdtsSsAHxPs4Dyv9bwXLNYn6JIslA2bAYx38jB4rhKd0Td c7wRm8iHcV9PbL8pFUVbj/UiAs4/eD3OBXMT67dI9yKeJpxZHJp5jNYgweHT6ysbqKKz s9EKEANH4m7JfEMgsGGXFuV9WaiWzylQ2YgphTbZtYbaByRXCdQh/VMTy9tmMQ1a1ij4 aidA+RJBHJTuxg7Nbww9a9CAVgR12GDUGHYK+OB/Jiq1CiQrwWjhXU/v7w6wX8YZH1s1 mG1w== X-Gm-Message-State: AGi0PuYPRG4p2fLSjNEUEmMvm2x1HVpjd0Wjd626IIxIPVTU5B1G9RlN unSVH8iOMIFYCIQny3mtEMg0gQp1pKQ= X-Received: by 2002:a05:651c:c8:: with SMTP id 8mr17858806ljr.182.1588109822370; Tue, 28 Apr 2020 14:37:02 -0700 (PDT) Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com. [209.85.208.176]) by smtp.gmail.com with ESMTPSA id k18sm516708lfg.81.2020.04.28.14.37.00 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Apr 2020 14:37:00 -0700 (PDT) Received: by mail-lj1-f176.google.com with SMTP id u15so423050ljd.3 for ; Tue, 28 Apr 2020 14:37:00 -0700 (PDT) X-Received: by 2002:a2e:9a54:: with SMTP id k20mr17622095ljj.265.1588109820160; Tue, 28 Apr 2020 14:37:00 -0700 (PDT) MIME-Version: 1.0 References: <87imi8nzlw.fsf@x220.int.ebiederm.org> <20200411182043.GA3136@redhat.com> <20200412195049.GA23824@redhat.com> <20200428190836.GC29960@redhat.com> In-Reply-To: From: Linus Torvalds Date: Tue, 28 Apr 2020 14:36:43 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [GIT PULL] Please pull proc and exec work for 5.7-rc1 To: Jann Horn Cc: Oleg Nesterov , Bernd Edlinger , "Eric W. Biederman" , Waiman Long , Ingo Molnar , Will Deacon , Linux Kernel Mailing List , Alexey Gladkov Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 28, 2020 at 2:06 PM Jann Horn wrote: > > In execve: > > - After the point of no return, but before we start waiting for the > other threads to go away, finish calculating our post-execve creds > and stash them somewhere in the task_struct or so. > - Drop the cred_guard_mutex. > - Wait for the other threads to die. > - Take the cred_guard_mutex again. > - Clear out the pointer in the task_struct. > - Finish execve and install the new creds. > - Drop the cred_guard_mutex again. > > Then in ptrace_may_access, after taking the cred_guard_mutex, we'd > know that the target task is either outside execve or in the middle of > execve, with old and new credentials known; and then we could say "you > only get to access that task if you're capable relative to *both* its > old and new credentials, since the task currently has both state from > the old executable and from the new one". That doesn't solve the problem with "check_unsafe_exec()" - you might miss setting LSM_UNSAFE_PTRACE. Although maybe that whole function could be moved down (to after you get the cred_guard_mutex the second time). Linus