From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796329093; b=Ehg3JTJDNTwGngWOA2eOeD7ATUNqhntdwOxj/NsWCBPfd+Dva7p6BjXkj+8TSQMydao9 bU183OLmJOP6dS8KielbgGfNgHL5UCrrC8rLFm/jyB+SFwuDES/Ji7ilWkyJptJd85QjV 4IaeXZ9QJC9L2anzh6FyK381N1gu+F1Hhq7zm7X2fPjnrGYxtBQzh70O4CDvEhqbrTE8c noinL1sUz3Sjmk7OatK7Fy1DFytrpx7PhzUxCO6tROdYjo+UzqQ2xSobAVSLwEb8Mg1/s 1wRZ/MPwNxVDOY6cWa3VWapm7Mvz9CFdQDGBkHDteXufdpllj52L+0S7gHKa8mWAZUA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796329093; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=kHdOQZVz+Sb2H9f0nXCzcJKBpEy3BFShG64+qEjGuAU=; b=lrfW+rNtHfF67VAzPWJ6gJCNlgZiznSHznQy1A2NnIkmzR+acB/PbUL8AA7Kd30U8HsI wniWptJwD8Pnui03MsBGU6/G7eElVopWaCesRCZAPzO6Hh2J1BzptBkm0lfvi7NDQMPw9 zSUeWjDFdTuuJx1oJYv3PxfLapUbe6uawK+zkeKPjv3wRZiPpnRvYqY1VgCN+IJd0NwTU 7c9KH/eaRVAnGvGv4JTBr41GPV1Q5A7vD2zTGKXQDdA1WDIRgM6c19b2CLMtaFIXGy1cQ peUq2dvISdsbeHTxDDOeJAPGLjK51px1HPev8BkPk4gzpPbB3TSt/uz+VM8PiFJpDjg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Rn5Lsjsv; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1040606A322; Thu, 3 Dec 2026 20:18:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Rn5Lsjsv Received: by smtp.kernel.org (Postfix) with ESMTPSA id 507631F000C2; Thu, 3 Dec 2026 20:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796329093; bh=kHdOQZVz+Sb2H9f0nXCzcJKBpEy3BFShG64+qEjGuAU=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=Rn5LsjsvuzNVZ8RR+wJW/fdHxM/+V+eSknHQC2kS4lOJ/Q4QK3Lr+mLzbMoE7IZ7v IrYHIYBFMMYVJkNL8eFjIQdW0YMU5o3pZWbdx+g6yFLty84wbsF+aIQJBZHZ5KOkyk tKxEl8hrpt6xaJ2z12/Qoew0labz2ypON88VbmvbMngkYmzjLjuOMkcs9WGTz9TqH4 WHzAFl+JYKI4ulyai5JO08rF1oYJGgBbWRak1oTLb5QEHd0mG0fXTFw1xlASsr6Tgn XJUDtZP7zDH2kbVN8+me0urolnpq/oy6IcU3rEHRw5cOcJ7HV2fixYySEqDmijZWZY Z/BPK6y62x8+A== Date: Thu, 3 Dec 2026 14:18:09 -0600 From: "Serge Hallyn (AMD)" To: Christian Brauner Cc: Jann Horn , Linus Torvalds , linux-fsdevel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-perf-users@vger.kernel.org, bpf@vger.kernel.org, selinux@vger.kernel.org, Kees Cook , linux-mm@kvack.org, linux-security-module@vger.kernel.org, apparmor@lists.ubuntu.com, David Hildenbrand , stable@vger.kernel.org Subject: Re: [PATCH RFC 01/19] proc: copy namespace link after dropping exec_update_lock Message-ID: References: <20261124-work-exec-update_lock-v1-0-e489035395b8@kernel.org> <20261124-work-exec-update_lock-v1-1-e489035395b8@kernel.org> X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261124-work-exec-update_lock-v1-1-e489035395b8@kernel.org> On Tue, Nov 24, 2026 at 11:58:24PM +0100, Christian Brauner wrote: > proc_ns_readlink() copies the name of the namespace to userspace under > exec_update_lock. If that faults the lock is held for as long as the > fault takes. With a buffer in a mapping of a file on a FUSE filesystem > or in a range registered with userfaultfd it's the caller who decides > how long that is: > > locks held by ns-reader/230: > #0: (&sig->exec_update_lock){++++}-{4:4}, at: proc_ns_readlink+0x180/0x340 > > In the meantime an exec of the task waits for exec_update_lock past the > point of no return. And everyone else who needs the exec_update_lock of > the task queues up behind the exec. So a read of /proc//stat hangs > as well: > > task:exec-task state:D pid:229 > Call Trace: > __schedule+0x1691/0x4b00 > schedule+0xe0/0x2e0 > schedule_preempt_disabled+0x11/0x20 > rwsem_down_write_slowpath+0x472/0x1820 > down_write_killable+0x1ba/0x240 > begin_new_exec+0xa4b/0x2df0 > load_elf_binary+0x340/0x4af0 > bprm_execve+0x772/0x1400 > do_execveat_common.isra.0+0x3d9/0x540 > __x64_sys_execve+0x8c/0xc0 > do_syscall_64+0x110/0x600 > entry_SYSCALL_64_after_hwframe+0x77/0x7f > > task:stat-reader state:D pid:231 > Call Trace: > __schedule+0x1691/0x4b00 > schedule+0xe0/0x2e0 > schedule_preempt_disabled+0x11/0x20 > rwsem_down_read_slowpath+0x5cc/0x10c0 > down_read_killable+0xf1/0x5f0 > do_task_stat+0x13b/0x2870 > proc_single_show+0x110/0x1d0 > seq_read_iter+0x2e4/0x1280 > seq_read+0x29b/0x550 > vfs_read+0x171/0xb20 > ksys_read+0x111/0x250 > do_syscall_64+0x110/0x600 > entry_SYSCALL_64_after_hwframe+0x77/0x7f > > All it takes is being allowed to read the namespace links of the task. > > The name is formatted into a buffer on the stack anyway. So drop the > lock before it's copied out. > > Fixes: 6650527444da ("proc: protect ptrace_may_access() with exec_update_lock (part 1)") > Cc: stable@vger.kernel.org > Signed-off-by: Christian Brauner (Amutable) Reviewed-by: Serge Hallyn (AMD) > --- > fs/proc/namespaces.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c > index ea6ec61a0430b..4c91ccbed21ef 100644 > --- a/fs/proc/namespaces.c > +++ b/fs/proc/namespaces.c > @@ -92,12 +92,11 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl > goto out_put_task; > > res = -EACCES; > - if (ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) { > + if (ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) > res = ns_get_name(name, sizeof(name), task, ns_ops); > - if (res >= 0) > - res = readlink_copy(buffer, buflen, name, strlen(name)); > - } > up_read(&task->signal->exec_update_lock); > + if (res >= 0) > + res = readlink_copy(buffer, buflen, name, strlen(name)); > out_put_task: > put_task_struct(task); > return res; > > -- > 2.53.0 >