Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp871367ybb; Wed, 8 Apr 2020 11:30:57 -0700 (PDT) X-Google-Smtp-Source: APiQypKXkjAfKgvQymrd8yJIdBjXS7gieIQ0v+4YpZ+lf3+xS2la7MmGtj1ZoNGJFr7KcR/VlI3F X-Received: by 2002:a9d:525:: with SMTP id 34mr6587425otw.80.1586370657535; Wed, 08 Apr 2020 11:30:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586370657; cv=none; d=google.com; s=arc-20160816; b=y3llIHpeNW+6lvjFjUsnXxNEcRSocBEcUmncMBB8jhGTdm+XpLOE/Iisr8s3fKT8YK pvgxkpZnbJfpgdoAWS8oDADTR2AHdKRkrJwlAKBeQhbb6PzssYsauO4+iYjt2JGDtIrS dmoRVFlhye4Kpci5NIKqDb3xV3XX3cAL/oPtlen/t2tcvIVcF2ODPogRsHCIVOCv7O4/ WtfDlkUWptSR8jEteLaFnDmPP39KcMjsNTwEVEbpCXZDp5xukIC9SvLlYgPyoNf1yLCM DbGUV9s7PDt03CpOpwvj+zh71NGevSb1cKjMoV15C4aPoZyTlJIq3+KPPKp5Axl6Uztl Stug== 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=29SKUXTwJN3v/j3/R0A3kj/FiH8JxJ//hjcnQffrrsk=; b=TreDbpOOKh6T+JJKLjcT6og6HUpzACAdM8t/khwfPVyi2plIUuebU9+rvx2tBOSEse xApuR/BpR5QbsX4YLZR95K3bY+NOMjJXuhmasrKgthF4FNP3QJyCF1fs8Sb1OI+iZ1CG V7LT2GyCbF+b5zkFFXDfJ7ApkAFVahzDiomDQoGN/IPlQ+ejlELiDU2tdAhWDamBQoV1 92Rlc9w11FiIkiOrIbpzMGdYgNHpnSV69rHf3FYoJiMMDAdDz5pcmMKZNq/Pwfi8g7w2 +BF+t6QG+sjjAJWlYdRgO5kCfKKxVCHvFell7fTv+xR6w0DMqj6yxqOQKNXRrtHt9FvA XR2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=AYcAqx9s; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z14si3177060oom.72.2020.04.08.11.30.44; Wed, 08 Apr 2020 11:30:57 -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=@linux-foundation.org header.s=google header.b=AYcAqx9s; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730273AbgDHQfJ (ORCPT + 99 others); Wed, 8 Apr 2020 12:35:09 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:44306 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728789AbgDHQfJ (ORCPT ); Wed, 8 Apr 2020 12:35:09 -0400 Received: by mail-lj1-f196.google.com with SMTP id z26so4201240ljz.11 for ; Wed, 08 Apr 2020 09:35:07 -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=29SKUXTwJN3v/j3/R0A3kj/FiH8JxJ//hjcnQffrrsk=; b=AYcAqx9sJjb46kiIhmKp/bkK+AN68urLGSJcgXbEhs7x4N5gYzXeHWQXKXujsCAYWJ kotBA8nGDaWEn8jaVmRDCJHQPeOfYXV/3m5nYTZGULNm5wn9jI3WgMuQTjtS6dyz4lRh VQf1mBw/X8G//QKg4X1b2l4JmTpectUDekeXo= 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=29SKUXTwJN3v/j3/R0A3kj/FiH8JxJ//hjcnQffrrsk=; b=jHPRXEBIPAmcUXAw/mB3fFDgJrL4TEe1A0C+dsyX7Eqy4+pZIRM3N7ilkBEacX0k9o rFNkr9SZYhOBqJWx7WnPHwWr7G+xgm/wE471BdG1/734K38SZ5Sv9V7hk7FYydNVXPma Xy+UCylrkyfEXWtft+fa6t7snxL/XYpei97ZxjnTEs5eljizYHJIP8Ag0RHbj7Y2obZb /fKIwRkdUYbDIXsivqEbxr94ZwA9KualUFnJHyByhglEyVJBMyw9eJ7SszOZOkWjhl4X q0Y+9S2zyk2tHfQUiyIpNX4WuLatzkGOIke8by/kH31N0dkWz2MbnId/Ni79pBFa7826 uz0g== X-Gm-Message-State: AGi0PubUa+jnKbbTPYq1Me4zjG5REPpw6DPIOwsEe7CO2CTSLABAClpP McQZv+/mq/lwa1XTwYnwtt4H76kKt3k= X-Received: by 2002:a2e:9655:: with SMTP id z21mr427743ljh.122.1586363705686; Wed, 08 Apr 2020 09:35:05 -0700 (PDT) Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com. [209.85.167.46]) by smtp.gmail.com with ESMTPSA id v21sm17044617lji.81.2020.04.08.09.35.03 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Apr 2020 09:35:04 -0700 (PDT) Received: by mail-lf1-f46.google.com with SMTP id r17so5636342lff.2 for ; Wed, 08 Apr 2020 09:35:03 -0700 (PDT) X-Received: by 2002:a19:240a:: with SMTP id k10mr5203163lfk.30.1586363703395; Wed, 08 Apr 2020 09:35:03 -0700 (PDT) MIME-Version: 1.0 References: <87blobnq02.fsf@x220.int.ebiederm.org> <87lfnda3w3.fsf@x220.int.ebiederm.org> <87blo45keg.fsf@x220.int.ebiederm.org> <87v9maxb5q.fsf@x220.int.ebiederm.org> In-Reply-To: <87v9maxb5q.fsf@x220.int.ebiederm.org> From: Linus Torvalds Date: Wed, 8 Apr 2020 09:34:47 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [GIT PULL] Please pull proc and exec work for 5.7-rc1 To: "Eric W. Biederman" Cc: Waiman Long , Ingo Molnar , Will Deacon , Bernd Edlinger , 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 Wed, Apr 8, 2020 at 8:17 AM Eric W. Biederman wrote: > > Yes. I missed the fact that we could take the lock killable. > We still unfortunately have the deadlock with ptrace. That, I feel, is similarly trivial. Again, anybody who takes the lock for writing should just do so killably. So you have three cases: - ptrace wins the race and gets the lock. Fine, the execve will wait until afterwards. - ptrace loses the race and is not a thread with execve. Fine, the execve() won, and the ptrace will wait until after execve. - ptrace loses the race and is a thread with execve. Fine, the execve() will kill the thing in dethread() and the ptrace thread will release the lock and die. So all three cases are fine, and none of them have any behavioral differences (as mentioned, the killing is "invisible" to users since it's fundamentally a race, and you can consider the kill to have happened before the ptrace started). > It might be simpler to make whichever lock we are dealing with per > task_struct instead of per signal_struct. Then we don't even have to > think about what de_thread does or if the lock is taken killable. Well, yes, but I think the dethread behavior of killing threads is required anyway, so.. > I keep wondering if we could do something similar to vfork. That is > allocate an new task_struct and fully set it up for the post exec > process, and then make it visible under tasklist_lock. Finally we could > free the old process. > > That would appear as if everything happened atomically from > the point of view of the rest of the kernel. I do think that would have been a lovely design originally, and would avoid a lot of things. So "execve()" would basically look like an exit and a thread creation with the same pid (without the SIGCHILD to the parent, obviously) That would also naturally handle the "flush pending signals" etc issues. The fact that we created a whole new mm-struct ended up fixing a lot of problems (even if it was painful to do). This might be similar. But it's not what we've ever done, and I do suspect you'd run into a lot of odd small special cases if we were to try to do it now. So I think it's simpler to just start making the "cred lock waiters have to be killable" rule. It's not like that's a very complex rule. Linus