Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp49592rdb; Mon, 15 Jan 2024 11:39:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHAnh97htkO3nLukOIwlwofsrkKjEKtFyW/SMq1DrhS5E0KxAEQIn2wiYPckjNX28ksIBu X-Received: by 2002:a17:906:254f:b0:a2e:5f51:e532 with SMTP id j15-20020a170906254f00b00a2e5f51e532mr1197ejb.76.1705347570388; Mon, 15 Jan 2024 11:39:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705347570; cv=none; d=google.com; s=arc-20160816; b=0H7VQACytJyZ8g/X23hWADXDG8d7dn+fcCgOVKNSzP1PZ8amOqK2gdrs2kj93ozOHN oW8XsOR3JVBoQJe4QGcynn7EvCKB7qVoTcR172QbjLEh8wwDFgF+yUGn/Tt35Bs0JKe0 Cotg3lwgIxPO+LqKSL7MGuiIEJAiRG9SDGlFK44laADBrBc/D+wlhhV5ZDq6GPow1BVT NxPr65krXxDMLlUWZ4nHWFcijMlbEK0Szv6KJna6uU2DFfB3kBLLAeX0YQchhAc15QDc iK37dj6JggtH35MluxGXL4AW2OTc/vYA5ijVCkADTrczr5clDj0BkHi3OMJBo4ORsd3N CP2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=VZxWDVpCvSyMMfu91KFYLQxRYf92goXw309/GJka1jA=; fh=+id2JYdcZL+fnc80FNuTKUANkAsEVr/Heuxxv6LhNRw=; b=LpUFxfrafOb6wEJXr1X8jfp++QEAx0IYBdPed6piAIHXy75MkydhQeuR6EWWJ1G96P OHJkLcKJJ4Xy64kG8i+1HLqKurnXeiYGMcc/PthzqpEjk/NNUs1bF7tCfxw2hnlKnbyr WPbcylJNYsL3H0cwjii/iHhsZU3uTVyGnhJxApJQzF0f1oATxz9Zx24Ka34E8q7e6skt Vg0M7uHvOyutdiSMgCzdzI0uAxsabTiOhfnEIK4dHR7kYS2UjGwMN1ekvGbFDsWlQHK/ x88pWUP9Kk7gM6MOi0eTfVI9l0JnrEov8iWEqhElif+HtjG0XEO5LEVoKEKjkoU+Zymm PDUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=GknGwOR3; spf=pass (google.com: domain of linux-kernel+bounces-26438-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26438-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id t7-20020a170906178700b00a28cd92bb7asi4096695eje.832.2024.01.15.11.39.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 11:39:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26438-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=GknGwOR3; spf=pass (google.com: domain of linux-kernel+bounces-26438-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26438-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 19B2B1F22A9A for ; Mon, 15 Jan 2024 19:39:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 379BB18C32; Mon, 15 Jan 2024 19:39:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="GknGwOR3" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89FDA18B06; Mon, 15 Jan 2024 19:39:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=VZxWDVpCvSyMMfu91KFYLQxRYf92goXw309/GJka1jA=; b=GknGwOR3WJOANvxNIoJBsht0dF XYsbU6l237FY/y32zn2rCALaUsCZlCV/doukPROyDgBih0N5A4poaUezz78fJAKRRw4spk15ec5Vb wt2fW49Tf5hUy1Hhnn443PL5X7S9d7/gXo4XQwx3EUazTRQxz+Shm5v9T9MI7Iht32IIsAs0U1+5m qZsX/gGVMtWr+31/fvBSc0u6UiYa6uL+Zu+yPn0SAL9/S+oSphBGk8TFTU9cdTmhlCtPPQICjWSBx bQaKlCH6vSEgmCAmZ/tYp4bqLoAYu/ZJOK5RB/ww1iUiq2qK0Pp9RvifgWHu88AeS/d5XVWIE4CNl YlL/2RBA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rPSmJ-00Ad0l-L5; Mon, 15 Jan 2024 19:37:47 +0000 Date: Mon, 15 Jan 2024 19:37:47 +0000 From: Matthew Wilcox To: Bernd Edlinger Cc: Alexander Viro , Alexey Dobriyan , Oleg Nesterov , Kees Cook , Andy Lutomirski , Will Drewry , Christian Brauner , Andrew Morton , Michal Hocko , Serge Hallyn , James Morris , Randy Dunlap , Suren Baghdasaryan , Yafang Shao , Helge Deller , "Eric W. Biederman" , Adrian Reber , Thomas Gleixner , Jens Axboe , Alexei Starovoitov , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , linux-kselftest@vger.kernel.org, linux-mm@kvack.org, tiozhang , Luis Chamberlain , "Paulo Alcantara (SUSE)" , Sergey Senozhatsky , Frederic Weisbecker , YueHaibing , Paul Moore , Aleksa Sarai , Stefan Roesch , Chao Yu , xu xin , Jeff Layton , Jan Kara , David Hildenbrand , Dave Chinner , Shuah Khan , Zheng Yejian , Elena Reshetova , David Windsor , Mateusz Guzik , Ard Biesheuvel , "Joel Fernandes (Google)" , Hans Liljestrand Subject: Re: [PATCH v14] exec: Fix dead-lock in de_thread with ptrace_attach Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Jan 15, 2024 at 08:22:19PM +0100, Bernd Edlinger wrote: > This introduces signal->exec_bprm, which is used to > fix the case when at least one of the sibling threads > is traced, and therefore the trace process may dead-lock > in ptrace_attach, but de_thread will need to wait for the > tracer to continue execution. Not entirely sure why I've been added to the cc; this doesn't seem like it's even remotely within my realm of expertise. > +++ b/include/linux/cred.h > @@ -153,6 +153,7 @@ extern const struct cred *get_task_cred(struct task_struct *); > extern struct cred *cred_alloc_blank(void); > extern struct cred *prepare_creds(void); > extern struct cred *prepare_exec_creds(void); > +extern bool is_dumpability_changed(const struct cred *, const struct cred *); Using 'extern' for function declarations is deprecated. More importantly, you have two arguments of the same type, and how do I know which one is which if you don't name them? > +++ b/kernel/cred.c > @@ -375,6 +375,28 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset) > return false; > } > > +/** > + * is_dumpability_changed - Will changing creds from old to new > + * affect the dumpability in commit_creds? > + * > + * Return: false - dumpability will not be changed in commit_creds. > + * true - dumpability will be changed to non-dumpable. > + * > + * @old: The old credentials > + * @new: The new credentials > + */ Does kernel-doc really parse this correctly? Normal style would be: /** * is_dumpability_changed - Will changing creds affect dumpability? * @old: The old credentials. * @new: The new credentials. * * If the @new credentials have no elevated privileges compared to the * @old credentials, the task may remain dumpable. Otherwise we have * to mark the task as undumpable to avoid information leaks from higher * to lower privilege domains. * * Return: True if the task will become undumpable. */ > @@ -508,6 +531,14 @@ static int ptrace_traceme(void) > { > int ret = -EPERM; > > + if (mutex_lock_interruptible(¤t->signal->cred_guard_mutex)) > + return -ERESTARTNOINTR; Do you really want this to be interruptible by a timer signal or a window resize event?