Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E82FDC433F5 for ; Mon, 13 Dec 2021 15:25:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237170AbhLMPZG convert rfc822-to-8bit (ORCPT ); Mon, 13 Dec 2021 10:25:06 -0500 Received: from out02.mta.xmission.com ([166.70.13.232]:50962 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230072AbhLMPZE (ORCPT ); Mon, 13 Dec 2021 10:25:04 -0500 Received: from in02.mta.xmission.com ([166.70.13.52]:39534) by out02.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1mwnCJ-006sx4-4u; Mon, 13 Dec 2021 08:25:03 -0700 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95]:40714 helo=email.froward.int.ebiederm.org.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1mwnCI-00BGma-6R; Mon, 13 Dec 2021 08:25:02 -0700 From: ebiederm@xmission.com (Eric W. Biederman) To: Michal =?utf-8?Q?Koutn=C3=BD?= Cc: linux-kernel@vger.kernel.org, Jens Axboe , Kees Cook , Oleg Nesterov , Peter Zijlstra , Thomas Gleixner , Jim Newsome , Alexey Gladkov , Tejun Heo , security@kernel.org, Andy Lutomirski , Jann Horn References: <20211208180501.11969-1-mkoutny@suse.com> <87sfv3540t.fsf@email.froward.int.ebiederm.org> Date: Mon, 13 Dec 2021 09:24:55 -0600 In-Reply-To: ("Michal \=\?utf-8\?Q\?Koutn\=C3\=BD\?\= \=\?utf-8\?Q\?\=22's\?\= message of "Sat, 11 Dec 2021 00:12:35 +0100") Message-ID: <874k7c34u0.fsf@email.froward.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-XM-SPF: eid=1mwnCI-00BGma-6R;;;mid=<874k7c34u0.fsf@email.froward.int.ebiederm.org>;;;hst=in02.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX19xtx73jMmO3jF6HYxsRRJf4v3O2ksAPZM= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH] exit: Retain nsproxy for exit_task_work() work entries X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Michal Koutný writes: > On Wed, Dec 08, 2021 at 12:45:54PM -0600, "Eric W. Biederman" wrote: >> TL;DR the cgroup file system is checking permissions at write time. > > Thank you for bringing that up (handled in a separate thread now). > >> I think I follow your reasoning and I think it will even fix the issue >> but no. > > FTR, part of Tejun's series [1] ensures that cgroup_ns is accessed > directly without nsproxy and a reference to it is kept while the file > is opened. I.e. that'd properly fix this particular crash reported by > syzbot. > >> Please don't apply this patch. >> >> exit_task_work running after exit_task_namespaces is the messenger >> that just told us about something ugly. > > In (my) theory some other task_work callbacks could (transitively) rely > on the current->nsproxy which could still be cleared by > exit_task_namespaces(). > Is there another reason why to have exit_task_namespaces() before > exit_task_work()? We already have the principle that things are going to be cleaned up before exit_task_work is called and exit_files depends upon that. So I think the burden is to find a good reason why exit_task_work should move not to defend it. If we don't want things cleaned up before exit_task_work it should come at the start of do_exit and exit_files and others need to stop depending upon it. Which seems like challenging change to make. Eric