From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E4CCECAAD1 for ; Thu, 1 Sep 2022 04:22:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65A7F6B0072; Thu, 1 Sep 2022 00:21:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6088C6B0073; Thu, 1 Sep 2022 00:21:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D1208D0001; Thu, 1 Sep 2022 00:21:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3DC226B0072 for ; Thu, 1 Sep 2022 00:21:59 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 09965120EB1 for ; Thu, 1 Sep 2022 04:21:59 +0000 (UTC) X-FDA: 79862218758.07.6E43BA0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf31.hostedemail.com (Postfix) with ESMTP id A0B6620057 for ; Thu, 1 Sep 2022 04:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662006118; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=neGhyK7pkD6eqSZHik1Qe4PD8FiO+8vxC39rTdxsXS8=; b=Ae6c/j2q029BY44Mp+UbT+yFuiVZ+lBL8exg2oNd77socNcbAUy+icmMLBhIVDMklWUrPX +cSUhmIfHFF5/Tm8yQAP+cRSNa4vN27prYgeof3Npo0aON6r5Sl0ZzLyyBFYivat3NLao+ Tz+rlrQ8IfJOhN4dzq1et0rz6Y6SuhE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-532-MhF9hAKjN_GtuqERlDsDEg-1; Thu, 01 Sep 2022 00:21:56 -0400 X-MC-Unique: MhF9hAKjN_GtuqERlDsDEg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5173E85A58A; Thu, 1 Sep 2022 04:21:56 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.37]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 16BDE2166B26; Thu, 1 Sep 2022 04:21:53 +0000 (UTC) From: Florian Weimer To: Andrei Vagin Cc: Christian Brauner , Dmitry Safonov <0x7f454c46@gmail.com>, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Eric Biederman , Kees Cook , Alexey Izbyshev Subject: Re: Potentially undesirable interactions between vfork() and time namespaces References: Date: Thu, 01 Sep 2022 06:21:51 +0200 In-Reply-To: (Andrei Vagin's message of "Wed, 31 Aug 2022 20:45:30 -0700") Message-ID: <87tu5ru3kw.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 ARC-Authentication-Results: i=1; imf31.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Ae6c/j2q"; spf=pass (imf31.hostedemail.com: domain of fweimer@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=fweimer@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662006118; a=rsa-sha256; cv=none; b=Gi75qR8z2TloIMve1RG5KzcJ4R0YvmMbdv/e7zoyXZNisN5kzNjmy4zvR7PIYsMR9RXCwN Yy6bvo9iGACXYijZ2zUAoNGyaUXJtaNCxt4y4Ngy3YDEciOuMny1Qa4lMfjcL/3vu7maLF pnSKfQSbUONWalDZcPWYcVILPmd/INw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662006118; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=neGhyK7pkD6eqSZHik1Qe4PD8FiO+8vxC39rTdxsXS8=; b=cbQ+JkZaTGMZV80hEvyS1B/NWork152Wx+PZ1NVCQxqBqCWc4HfSL4Z0emd5yxvvq0nXH8 XFe4gCqAS1aEtbO7VwKYH8TYkKzVEtWn1hG8NygmLRJUncUtZTRolBYGZET8+tbuNCZQOk R6Wwmpv7PRUombGsQeDYfQPZQ5qMEiM= Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Ae6c/j2q"; spf=pass (imf31.hostedemail.com: domain of fweimer@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=fweimer@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-Stat-Signature: ybj9k13aha3t5xdinxrj9oqb8ns86f9i X-Rspamd-Queue-Id: A0B6620057 X-Rspamd-Server: rspam09 X-HE-Tag: 1662006118-579080 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: * Andrei Vagin: > On Tue, Aug 30, 2022 at 6:18 PM Andrei Vagin wrote: >>On Tue, Aug 30, 2022 at 10:49:43PM +0300, Alexey Izbyshev wrote: > >>> @@ -1030,6 +1033,10 @@ static int exec_mmap(struct mm_struct *mm) >>> tsk->mm->vmacache_seqnum = 0; >>> vmacache_flush(tsk); >>> task_unlock(tsk); >>> + >>> + if (vfork) >>> + timens_on_fork(tsk->nsproxy, tsk); >>> + >>> >>> Similarly, even after a normal vfork(), time namespace switch could be >>> silently skipped if the parent dies before "tsk->vfork_done" is read. Again, >>> I don't know whether anybody cares, but this behavior seems non-obvious and >>> probably unintended to me. >> This is the more interesting case. I will try to find out how we can >> handle it properly. > > It might not be a good idea to use vfork_done in this case. Let's > think about what we have and what we want to change. We don't want to > allow switching timens if a process mm is used by someone else. But we > forgot to handle execve that creates a new mm, and we can't change this > behavior right now because it can affect current users. Right? > > So maybe the best choice, in this case, is to change behavior by adding > a new control that enables it. The first interface that comes to my mind > is to introduce a new ioctl for a namespace file descriptor. Here is a > draft patch below that should help to understand what I mean. Doesn't this bring back the old posix_spawn (vfork) failure? Thanks, Florian