| Message ID | 20260915-work-fd-reserve-unify-folded-v1-20-4d5217d6b246@kernel.org |
|---|---|
| State | New |
| Headers | show
Return-Path: <linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=d3QGb6pe; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KlpWXuFj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hkfzy55Fbz1xwy for <incoming@patchwork.ozlabs.org>; Tue, 15 Sep 2026 21:34:06 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fnQCY0iVxuwm12CoBhWZ4dZN2HfOcSTyVDAJZSckXl4=; b=d3QGb6peFJc8wZ Nt9mi30+XrCoXxTmnOGJV5lN3VO9h/6S8ONVJtog+XWcNYFW3MxeC+zX2keGn2uIb31Jj/NlBUh1g X8YSiUkDVUCXGmGJIoBBavFfKH0WShmT9bL0d6Bd+u/B8A+l4d9y+3qDp2eVtWaQCPF1zFVvlV3d5 ByGKXx1f5KQTBwQtC8idghbGNKPpQrodTp6VqSMiWR/JGngv84Hi5ZYKEDFCcgFtv8nPFkW3QzYmC /xhjKXnClJKeIVQ4RLI7nrv+DrqqJJIT0jFQBws+1jS9eXuwsDyZkHYF2Y5V7lz4cYKBypJuc8rA+ st0Rr8IwUmpCQ8moTkMw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x6RQK-00000006ADZ-1EgH; Tue, 15 Sep 2026 11:34:04 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x6RQA-000000069yf-3wRD; Tue, 15 Sep 2026 11:33:55 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 579D2600D1; Tue, 15 Sep 2026 11:33:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E01081F000FF; Tue, 15 Sep 2026 11:33:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789472034; bh=mbTaUTx0F+8Yd8wvmtUsGd49oHWKxWwv7CwFTyLjhec=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=KlpWXuFj0+jdehVdQRW9dTm9BsasJoCQHq4y714jucc2LKezn+Raj3o0ioX232wqM jhHvMuhWUpiDNoQEY8ZOItiHHjXIh3EJ4lYCmA5rI9RGISwFKPW38moaoO3+dsZ0aK HShijMbdV4vAKfbEdZN7JwWHJCH9KbWrPxcDpTVAS0WUv3FhYQrUmcvC9ARRSnSa7u Ca768uVHlWEAIo6sTG8e8Q1xpvU8CLuiq6NSrBvgzzER0wYqMt62L865asuebsmyIW I7PEM9/+fxn9Mvp/KBLnfVW338UGGCg59dyrovq5duqMA/k5+J43h20hfjg0v7DEBj Nim9gww77JPsw== From: Christian Brauner <brauner@kernel.org> Date: Tue, 15 Sep 2026 13:31:06 +0200 Subject: [PATCH RFC POC 20/50] file: warn when the descriptor table is unshared with slots MIME-Version: 1.0 Message-Id: <20260915-work-fd-reserve-unify-folded-v1-20-4d5217d6b246@kernel.org> References: <20260915-work-fd-reserve-unify-folded-v1-0-4d5217d6b246@kernel.org> In-Reply-To: <20260915-work-fd-reserve-unify-folded-v1-0-4d5217d6b246@kernel.org> To: Linus Torvalds <torvalds@linux-foundation.org> Cc: Alexander Viro <viro@zeniv.linux.org.uk>, Jann Horn <jannh@google.com>, Jan Kara <jack@suse.cz>, Ingo Molnar <mingo@redhat.com>, Peter Zijlstra <peterz@infradead.org>, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Oleg Nesterov <oleg@redhat.com>, linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-parisc@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, Jens Axboe <axboe@kernel.dk>, io-uring@vger.kernel.org, netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-gpio@vger.kernel.org, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, bpf@vger.kernel.org, David Airlie <airlied@redhat.com>, virtualization@lists.linux.dev, kvm@vger.kernel.org, kexec@lists.infradead.org, linux-hyperv@vger.kernel.org, "Christian Brauner (Amutable)" <brauner@kernel.org> X-Mailer: b4 0.17-dev-db0b7 X-Developer-Signature: v=1; a=openpgp-sha256; l=1273; i=brauner@kernel.org; h=from:subject:message-id; bh=G9FG2jHFipdUrRTGsnorEbb5m5RZUr4ZNfIJ8EYrZNY=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWSt1Klt0PSve+Zwt2WPgtbjy2r2c+q+Ga6c6JRtXJz8V 7d7s9uBjlIWBjEuBlkxRRaHdpNwueU8FZuNMjVg5rAygQxh4OIUgIkk9TEybK8Ujbgr9+l9SPar Xzk+r7k8K/PX8z83lr3l0RmsOXPvPIb/xe7Pwk1X1l5rbbs/0/NrxfS1XTYnq53m69hY7lW8vLu CBQA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux on Synopsys ARC Processors <linux-snps-arc.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-snps-arc>, <mailto:linux-snps-arc-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-snps-arc/> List-Post: <mailto:linux-snps-arc@lists.infradead.org> List-Help: <mailto:linux-snps-arc-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-snps-arc>, <mailto:linux-snps-arc-request@lists.infradead.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-snps-arc" <linux-snps-arc-bounces@lists.infradead.org> Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org |
| Series |
file: handle files on syscall exit
|
expand
|
> If the fdtable is unshared or the task exits we can't install > reservations. The reserved fd isn't reserved anymore. execve() would > leak the reservation into the child. > > Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org> Sashiko has reviewed this patch and found no issues. It looks great!
diff --git a/fs/exec.c b/fs/exec.c index 745f6eb5279e..1aa0f7b99fc3 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1159,6 +1159,9 @@ int begin_new_exec(struct linux_binprm * bprm) */ io_uring_task_cancel(); + /* A prepared descriptor would be installed into the new program. */ + VFS_WARN_ON_ONCE(me->fd_slots.nr); + /* Ensure the files table is not shared. */ retval = unshare_files(); if (retval) diff --git a/kernel/fork.c b/kernel/fork.c index 59c5cfa3e482..bd0e1e85abb0 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -3217,6 +3217,8 @@ static int unshare_fd(unsigned long unshare_flags, struct files_struct **new_fdp if ((unshare_flags & CLONE_FILES) && (fd && atomic_read(&fd->count) > 1)) { + /* Prepared descriptors live in the table we are about to leave. */ + VFS_WARN_ON_ONCE(current->fd_slots.nr); fd = dup_fd(fd, NULL); if (IS_ERR(fd)) return PTR_ERR(fd);
If the fdtable is unshared or the task exits we can't install reservations. The reserved fd isn't reserved anymore. execve() would leak the reservation into the child. Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org> --- fs/exec.c | 3 +++ kernel/fork.c | 2 ++ 2 files changed, 5 insertions(+)