From patchwork Sat Jul 18 04:37:48 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babanpreet Singh X-Patchwork-Id: 92762 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB2B7C4450A for ; Sat, 18 Jul 2026 04:38:02 +0000 (UTC) Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.545.1784349474319354607 for ; Fri, 17 Jul 2026 21:37:54 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=C594DpRT; spf=pass (domain: gmail.com, ip: 209.85.214.177, mailfrom: bbnpreetsingh@gmail.com) Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2cf41bab353so10885425ad.0 for ; Fri, 17 Jul 2026 21:37:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784349474; x=1784954274; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Cf2DFrficqlE66poupyya5mgQfMx4Kdcxjo3xsRs0OY=; b=C594DpRTT2HbQJC9NYYJKJtXqFJlTJpYrUFIzqhea3reSFYVI1Ko70bRXl/SNvuw7A vRzk6ct3rz/ePFRuu/xvz8hH5eq/HOuCgzDq+eApZmSPk3pL629KW8tT+nK5wPl1vwa4 6icnTjJxrh4dqggeG/rFN0YXi2SY5vftTmKx0mry5cNzHExZfZbiCX+1wEsAxsLKBg0K 6iPuVqIFkM4SDZDzgmeARcdTedPEux8ynqSk77u0VErJBpJtUq4+x/lBMkJ6pSwSmsv+ 7UcNJf4oTkgX4FnWOxmiPnA5A+SZmCNP/mX8J3PK4lursYpuXkJ3evC2lEGgoFFpxCO0 eN2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784349474; x=1784954274; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Cf2DFrficqlE66poupyya5mgQfMx4Kdcxjo3xsRs0OY=; b=ZiMGVmV+Vu30XleQeWuCP4LN8z844smWGIddSvJ/sqdY/AEGNrvDCB86YikG1mIFTc 2b2QUIFfjwjKq42JVpeLYznWv54EP4x1s2yMmBpLRmcNLhtWN+++yj1BHduOpvX0Kvyi dTmBRPK9nOL9yO6DQrBWXl2/DSzknHPATbwwKEmbQr9IfzfCULWuanmtIUTZd/a9O//y MPPOMYk4znyxPRxoW3GjKN9wOiQjzvjNDg1XaXKFKtnLvpTfqT6yxwdtqSp7/uXHHoW/ eL5k1MMCQCGa8ITBXcvy48lCD/YrW4R4BBaw9DtVJ71i2eR3U4nC4mlx5jBBCJABz1Jd 4aGg== X-Gm-Message-State: AOJu0Yz6x4D0do4UDk1aR6xQBh0nqYD3lMpT8+e7T3jiBRhe+NOyOwgV SdtbZSm08JOVFh877gGXiA9RtdgFIe61xT3FdE+gYenv7vMV+Fx4k/nmkiLnmrqscpM= X-Gm-Gg: AfdE7cm3d1tdga03amBVyL0tNXzjOzI712edMc+ckZhgkadCChZzWovoPxUZtfvVj4J eU3uRQSMrdv6dj+/KqJcjyZhHU58Ol1sepEN82tqcSCYNWoUEnms8YwvLwI3MMmtCpXhMLvP7UA 7eGkPL+gNfv45v7q4jwPQu1B1+nizlbO467yK6WqnJmT/nW4Rg514DQchdolcDNR6Y1jN5fomCS siub2kTiqdKh5kAiQvmnsq4sGotcQwnqn7bIS5ipyGpMynmpGlJ8AgnrPfloC+p1Zf/GK5WPIbb kWAnc44XU6amnZ/PG0oHZHYMeqHZ6+OFio/QsnAfGY7OkL+oQ2J8LgU1GqMG1AVjsapJ8X4iRx0 QHyqM9WzD3Tz6aO9YgoddeZY9T1BkgCeOPaHfmL7bS1kexCMTRSNQlgEbuCb+jiz1dzrNoFwSgs CuW1nznzwYb1Px35+FvQbLJI4= X-Received: by 2002:a05:6a21:4516:b0:3c3:cf9b:fb8b with SMTP id adf61e73a8af0-3c3cf9bfcd0mr478347637.68.1784349473660; Fri, 17 Jul 2026 21:37:53 -0700 (PDT) Received: from ydev.. ([108.180.130.139]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cb517f8f067sm1626903a12.10.2026.07.17.21.37.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 21:37:53 -0700 (PDT) From: Babanpreet Singh To: yocto-patches@lists.yoctoproject.org Cc: Richard Purdie , Mark Hatle , Mark Hatle , Paul Barker , Randy MacLeod , Vincent Haupert , Babanpreet Singh Subject: [pseudo] [PATCH 1/3] pseudo_client: step fully past pseudo's own fds when computing startfd Date: Sat, 18 Jul 2026 04:37:48 +0000 Message-ID: <20260718043750.7-2-bbnpreetsingh@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260718043750.7-1-bbnpreetsingh@gmail.com> References: <20260716055633.7-1-bbnpreetsingh@gmail.com> <20260718043750.7-1-bbnpreetsingh@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sat, 18 Jul 2026 04:38:02 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/4508 OP_CLOSEFROM and OP_CLOSE_RANGE compute startfd, the first descriptor the caller may hand to the kernel wholesale, by stepping past each descriptor pseudo needs to keep: if (connect_fd > startfd) startfd = connect_fd + 1; A protected descriptor exactly equal to the running startfd fails that test and ends up protected by nothing: the close-by-hand loop stops below startfd, the kernel sweep starts at startfd, and the descriptor is closed even though it is on the protect list. The default descriptor layout hits this. Client init opens the local state directory fd and then connects to the server, so the two sit on consecutive numbers, say 21 and 22: the local state fd raises startfd to 22, connect_fd == 22 fails the > test, and closefrom(3) or close_range(3, ~0U, 0) hands 22 straight to the kernel. The server connection is closed out from under the client. The client transparently reconnects on the next operation, which is why this has gone unnoticed, but until that reconnect the stale descriptor number is free for the process to reuse, and anything pseudo believes about the connection is attached to the wrong descriptor. Use >= so startfd always ends up above every protected descriptor. Present since the startfd computation was introduced in 21ff2fb ("ports/linux/guts: Add closefrom support for glibc 2.34"). AI-Generated: Uses Claude (claude-sonnet-5) Signed-off-by: Babanpreet Singh --- pseudo_client.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pseudo_client.c b/pseudo_client.c index 1acd948..085a8b3 100644 --- a/pseudo_client.c +++ b/pseudo_client.c @@ -1966,15 +1966,15 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path case OP_CLOSEFROM: /* no request needed */ startfd = fd; - if (pseudo_util_debug_fd > startfd) + if (pseudo_util_debug_fd >= startfd) startfd = pseudo_util_debug_fd + 1; - if (pseudo_localstate_dir_fd > startfd) + if (pseudo_localstate_dir_fd >= startfd) startfd = pseudo_localstate_dir_fd + 1; - if (pseudo_pwd_fd > startfd) + if (pseudo_pwd_fd >= startfd) startfd = pseudo_pwd_fd + 1; - if (pseudo_grp_fd > startfd) + if (pseudo_grp_fd >= startfd) startfd = pseudo_grp_fd + 1; - if (connect_fd > startfd) + if (connect_fd >= startfd) startfd = connect_fd + 1; for (i = fd; i < startfd; ++i) { if (i == pseudo_util_debug_fd || i == pseudo_localstate_dir_fd || i == pseudo_pwd_fd || @@ -1992,15 +1992,15 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path case OP_CLOSE_RANGE: /* no request needed */ startfd = fd; - if (pseudo_util_debug_fd > startfd) + if (pseudo_util_debug_fd >= startfd) startfd = pseudo_util_debug_fd + 1; - if (pseudo_localstate_dir_fd > startfd) + if (pseudo_localstate_dir_fd >= startfd) startfd = pseudo_localstate_dir_fd + 1; - if (pseudo_pwd_fd > startfd) + if (pseudo_pwd_fd >= startfd) startfd = pseudo_pwd_fd + 1; - if (pseudo_grp_fd > startfd) + if (pseudo_grp_fd >= startfd) startfd = pseudo_grp_fd + 1; - if (connect_fd > startfd) + if (connect_fd >= startfd) startfd = connect_fd + 1; /* the fds below startfd are the ones our own are mixed in * with, so close those by hand and skip the ones we need From patchwork Sat Jul 18 04:37:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babanpreet Singh X-Patchwork-Id: 92763 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05318C4451C for ; Sat, 18 Jul 2026 04:38:03 +0000 (UTC) Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.546.1784349475515694134 for ; Fri, 17 Jul 2026 21:37:55 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=TvzfVOhl; spf=pass (domain: gmail.com, ip: 209.85.216.47, mailfrom: bbnpreetsingh@gmail.com) Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-38de840f2f0so4984389a91.0 for ; Fri, 17 Jul 2026 21:37:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784349475; x=1784954275; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=MaubIf90lb2cTNsVlSgcgxb7xw7j4mFfJsZy5gpnhiA=; b=TvzfVOhlDmAkxKgao93Oq/2+ym5gfgpkBjsewgNaWl57aDNcZM1I9LRmxe+q6taKHW wF6bTCuy7HWqBcjkS+CeL5XeufUY6+T0Br6cuRZrbL+nLPuBKMZjz2r1RQzW7zHun/RP 9u8YZwJx7p/vgkCkNB+VLGgDUtXuN42TgkDjUPVyQ67n6HNIq2p3M81rxtJtAfjA2ZkK zMSZ6QaGqC8G/zKbhyrOgk+1GBwQXcaBLLsFprYk3xb5GGLcUeavgiRSC0YyBlu4PZJa ejiE1b3Jq5ZckiYg9Xo7Fwy8dWtcFwXOwIDQZWxrSDNCeYNR3PCq8ffH0vXDIt7m+OqD Np4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784349475; x=1784954275; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=MaubIf90lb2cTNsVlSgcgxb7xw7j4mFfJsZy5gpnhiA=; b=CFrRL2OQ5KPDz3ruwbtEQbixXrkY+1UiJIC43nvqvrHlP0M+AtAbJxzJky0QOix7Xx KO3qIL4FrdCceYTgcdrLsRhHMmbjyiJfFlvr5FtyCUe+iUe2uGiLTfo6C4RkhtTDx8zc yamktSM4CzVqXfvgO5rW1PuMbKbAyVroez2sQ5khWTt5um7cOV5GTQVC5fKs1mcaMKZH qlUh28Ct9iFtVMPwjR19CRZ24G5otYjLNS1GAsRjsYyoMweyiNCRb6HRBFAel+a54H05 U1yqSmQ+syoswVrTD6fb8zgecUm3JoT48UguDNTUg8tmo8qyiqafKkXa4ok3LudU6r8Q rnRA== X-Gm-Message-State: AOJu0Yw+EtruJJsftJc42MQN6HcfY5XJrIkbkpsee+4fdwqGZ85CyHmb YWkrZMEwG+ddDZkVgm7ksIJ1OEoiBQgMUeU/85ntrokQIuGiNVrcs7YUwpmOJ8+JjCc= X-Gm-Gg: AfdE7cnnJPno0bvcpCym56PPEz84GkneerW7PhieoU/xLCvx/B3kEp7O8gVMYxXIt9n GwAjwLpj6223whPf+v/25QHjs2sn9ERIWJK9ynMH0TMasy8ovxJRJMyz6GouLyAvZrJOF0+fmgx gTpf4QzDvQVOapnT9Bac4EFKD+xavFJibD6C+UbrdUwmIV5bqOAwgXfqizI6KKKZK7YlxRCjw1G d7adG9aHYafgQ/3zBBmKaUhrsK8zCv4hOXOp2NC2MlQksSqf/opE2hcR3xeA28FfICOX0vg/AHe gKkxtO9kjMCDYl3w0YW9oglxKcH+KxRvymseIG8hK7c0bfjPTq2TsePnPIFR2hkFEvfYM1LLP8S hs0zXt5o+QJooZmLMwItdlg+ugPjtJJNiaurhoTk88WxtmAWc5x5TD/x8vKl8/VltBsDNSgXGtN EavQ== X-Received: by 2002:a05:6a20:d52b:b0:3c3:9698:daff with SMTP id adf61e73a8af0-3c3ada42d88mr5691765637.68.1784349474849; Fri, 17 Jul 2026 21:37:54 -0700 (PDT) Received: from ydev.. ([108.180.130.139]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cb517f8f067sm1626903a12.10.2026.07.17.21.37.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 21:37:54 -0700 (PDT) From: Babanpreet Singh To: yocto-patches@lists.yoctoproject.org Cc: Richard Purdie , Mark Hatle , Mark Hatle , Paul Barker , Randy MacLeod , Vincent Haupert , Babanpreet Singh Subject: [pseudo] [PATCH 2/3] pseudo_client: step around all of pseudo's own fds in closefrom/close_range Date: Sat, 18 Jul 2026 04:37:49 +0000 Message-ID: <20260718043750.7-3-bbnpreetsingh@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260718043750.7-1-bbnpreetsingh@gmail.com> References: <20260716055633.7-1-bbnpreetsingh@gmail.com> <20260718043750.7-1-bbnpreetsingh@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sat, 18 Jul 2026 04:38:03 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/4509 OP_CLOSEFROM and OP_CLOSE_RANGE step around five descriptors pseudo keeps for itself (debug output, the local state directory, passwd, group, and the server connection), but pseudo can hold three more, and a sweep will close those: - pseudo_util_evlog_fd is where pseudo_evlog_dump() writes the in-memory event log at the moment the client gives up on the server connection for good. It defaults to 2, so stepping around it matches the existing treatment of pseudo_util_debug_fd, which also defaults to 2 and is already protected. A closed (or worse, silently reused) descriptor here would misdirect exactly the diagnostics needed to debug a dead server. - pseudo_pwd_lck_fd is open between lckpwdf() and ulckpwdf(), which is precisely the window in which a caller works on the passwd files and may sweep descriptors. Once the sweep has closed it, ulckpwdf()'s close() can land on an unrelated descriptor that reused the number. - pseudo_prefix_dir_fd is opened at client init and stays open for the life of the process. pseudo_pwd_lck_fd is -1 while no lock is held, which the existing pattern already copes with: -1 never raises startfd and never matches a descriptor the close-by-hand loop visits. pseudo_util_evlog_fd had no declaration outside pseudo_util.c, so give it one in pseudo.h next to pseudo_util_debug_fd. [YOCTO #16339] AI-Generated: Uses Claude (claude-sonnet-5) Signed-off-by: Babanpreet Singh --- pseudo.h | 1 + pseudo_client.c | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/pseudo.h b/pseudo.h index b6c13f2..44ee991 100644 --- a/pseudo.h +++ b/pseudo.h @@ -29,6 +29,7 @@ extern void pseudo_debug_flags_finalize(void); extern unsigned long pseudo_util_debug_flags; extern unsigned long pseudo_util_evlog_flags; extern int pseudo_util_debug_fd; +extern int pseudo_util_evlog_fd; extern int pseudo_disabled; extern int pseudo_allow_fsync; extern int pseudo_diag(char *, ...) __attribute__ ((format (printf, 1, 2))); diff --git a/pseudo_client.c b/pseudo_client.c index 085a8b3..7f80a3b 100644 --- a/pseudo_client.c +++ b/pseudo_client.c @@ -1968,16 +1968,24 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path startfd = fd; if (pseudo_util_debug_fd >= startfd) startfd = pseudo_util_debug_fd + 1; + if (pseudo_util_evlog_fd >= startfd) + startfd = pseudo_util_evlog_fd + 1; + if (pseudo_prefix_dir_fd >= startfd) + startfd = pseudo_prefix_dir_fd + 1; if (pseudo_localstate_dir_fd >= startfd) startfd = pseudo_localstate_dir_fd + 1; if (pseudo_pwd_fd >= startfd) startfd = pseudo_pwd_fd + 1; + if (pseudo_pwd_lck_fd >= startfd) + startfd = pseudo_pwd_lck_fd + 1; if (pseudo_grp_fd >= startfd) startfd = pseudo_grp_fd + 1; if (connect_fd >= startfd) startfd = connect_fd + 1; for (i = fd; i < startfd; ++i) { - if (i == pseudo_util_debug_fd || i == pseudo_localstate_dir_fd || i == pseudo_pwd_fd || + if (i == pseudo_util_debug_fd || i == pseudo_util_evlog_fd || + i == pseudo_prefix_dir_fd || i == pseudo_localstate_dir_fd || + i == pseudo_pwd_fd || i == pseudo_pwd_lck_fd || i == pseudo_grp_fd || i == connect_fd) continue; pseudo_client_close(i); @@ -1994,10 +2002,16 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path startfd = fd; if (pseudo_util_debug_fd >= startfd) startfd = pseudo_util_debug_fd + 1; + if (pseudo_util_evlog_fd >= startfd) + startfd = pseudo_util_evlog_fd + 1; + if (pseudo_prefix_dir_fd >= startfd) + startfd = pseudo_prefix_dir_fd + 1; if (pseudo_localstate_dir_fd >= startfd) startfd = pseudo_localstate_dir_fd + 1; if (pseudo_pwd_fd >= startfd) startfd = pseudo_pwd_fd + 1; + if (pseudo_pwd_lck_fd >= startfd) + startfd = pseudo_pwd_lck_fd + 1; if (pseudo_grp_fd >= startfd) startfd = pseudo_grp_fd + 1; if (connect_fd >= startfd) @@ -2006,7 +2020,9 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path * with, so close those by hand and skip the ones we need */ for (i = fd; i < startfd && (unsigned int) i <= close_range_maxfd; ++i) { - if (i == pseudo_util_debug_fd || i == pseudo_localstate_dir_fd || i == pseudo_pwd_fd || + if (i == pseudo_util_debug_fd || i == pseudo_util_evlog_fd || + i == pseudo_prefix_dir_fd || i == pseudo_localstate_dir_fd || + i == pseudo_pwd_fd || i == pseudo_pwd_lck_fd || i == pseudo_grp_fd || i == connect_fd) continue; pseudo_client_close(i); From patchwork Sat Jul 18 04:37:50 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babanpreet Singh X-Patchwork-Id: 92764 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E289C44521 for ; Sat, 18 Jul 2026 04:38:03 +0000 (UTC) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.547.1784349476872439149 for ; Fri, 17 Jul 2026 21:37:56 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=sCX4vl2C; spf=pass (domain: gmail.com, ip: 209.85.215.177, mailfrom: bbnpreetsingh@gmail.com) Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-ca2fad0ae38so6657358a12.3 for ; Fri, 17 Jul 2026 21:37:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784349476; x=1784954276; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=SauqQ3uW1MleZ6xhT08ZIXJ4hNN3Kv8upgc6WuUeYD4=; b=sCX4vl2Cn0hSA2pOt1QUP9mmROgT+BDzFd7ywI9jdDppdcIW3eh3wHVe06t2B5Jt7j Xb59UEqb4e0kmp0QdlIZMMMtrJBCWE3gpPEE4X97z/IoX2PUlIe+T48lavuW3ZdeVb/6 bq7zXY+kfp2gGwLYjaVtkNPeMP5183wdoE6L5Q4qkjan7P8nyKJlAAoQJ2UquGd6mJ17 7g13fyH+ZHKXNqddqMUJnQSqWNj3Le9EXvu0TKBmIlL6D32GUnEaHKiFfZKQrHZOn+8Y L6ysbzCBE2c8ABg1zmJb2TV6eqOLcVEmgZt/P+4gAGYKP9LDTjgr1CyBZavHOcMZDPS8 To8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784349476; x=1784954276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=SauqQ3uW1MleZ6xhT08ZIXJ4hNN3Kv8upgc6WuUeYD4=; b=GN3Exh8IOBveg5EikPWoxitMzlZJNRVO1nREkPmkwxV0QaqcM4CWQ6X/OT/SRSDwHt GGIGsvKujYgWkBHR/d3X9ckA+Erd3o1DIUlY1WlwKYfKkH4BjSX2WKTOp/3RIBUapoBR r6WpwHRDfp20Coy5+NALQ0c0xqnd2u/Glqo6MjgndK8aUnQFr7f6vFiqBUjtM5mRORzg KeXwKgh+ACheeij3YpMNAG+NarUHQidwl1NZk6P0W1RszUkiCj29nrTtLf4atqkmMO9K 3XItQgDOZcqF6kANf7/khm/9xYBCSO4ej2uWXJ00sLBklSVuxF+WVXF96M0c9cdYR4wW bQew== X-Gm-Message-State: AOJu0Ywcg1Oj53IXO93v+asqztTFSEhVBElOoHiTjRSRoYsv31G73GRM ipltiqYtjlxR86vWfhQogxtKN3XgK+1aupXCqyisNmr/xlSO2LXZACLxZqpJl8y5Jz8= X-Gm-Gg: AfdE7cmJpaXGs2qdry27/lAOZeEJfcgFaSpsQiJTCVBhpxSkos8c6+9/SUZz4BRWAyU w1NSCzhrE+UureYLMcV6C/RS50hEy6p6LwrP/FosuuA5mCvSMm2Wwp5XsqWtSa9o+c0mr0P/IlF AZlYmV4yszqZbGM3S6t8YKFqoWwW1noUh4iTpSI4qUUpwZN4R07Vf3xM4aAWqBl2Y5UqJu1pwKJ +5DP5k5nY18H+IYCOJqfjhweJrOtKsqBE+ciVCHH09BLTDFw9FtOpM+imvnb/AbvVan1/w5ttmb f9ZfW1x+bpra6hK6AVtSab3qm8F0mplCiki/2XGXbgsGxpVSFRYXzhyWcNhUDWHeW2w1Exm5CnC 6L5Krt8QNwEuWLiOFipVrY58x4nJdCfoY33+4Y4SC0m5gsveLsRRddd4h09Z3NRpmjYhLXSNWmU +GxA== X-Received: by 2002:a05:6a20:c70b:b0:3bf:7c02:c46f with SMTP id adf61e73a8af0-3c3ad5ffb90mr5887121637.14.1784349476099; Fri, 17 Jul 2026 21:37:56 -0700 (PDT) Received: from ydev.. ([108.180.130.139]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cb517f8f067sm1626903a12.10.2026.07.17.21.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 21:37:55 -0700 (PDT) From: Babanpreet Singh To: yocto-patches@lists.yoctoproject.org Cc: Richard Purdie , Mark Hatle , Mark Hatle , Paul Barker , Randy MacLeod , Vincent Haupert , Babanpreet Singh Subject: [pseudo] [PATCH 3/3] pseudo_client: remove the unused pseudo_prefix_dir_fd Date: Sat, 18 Jul 2026 04:37:50 +0000 Message-ID: <20260718043750.7-4-bbnpreetsingh@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260718043750.7-1-bbnpreetsingh@gmail.com> References: <20260716055633.7-1-bbnpreetsingh@gmail.com> <20260718043750.7-1-bbnpreetsingh@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sat, 18 Jul 2026 04:38:03 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/4510 pseudo has kept an O_RDONLY descriptor on PSEUDO_PREFIX since its first commit (33d9386, 2010), where client_connect() fchdir()'d through it so the server socket could be reached by a path short enough for sun_path. 551bf567 ("Add new environment values to allow easy override of default locations") moved that job to pseudo_localstate_dir_fd. Nothing has read pseudo_prefix_dir_fd back since then. Two side effects of opening it go away. Client init created a missing PSEUDO_PREFIX with mkdir_p(); the default PSEUDO_LOCALSTATEDIR lives under the prefix and its own setup runs the same mkdir_p(), so the directory is still created there, while a custom PSEUDO_LOCALSTATEDIR never needed the prefix directory at client init. An unset or unopenable PSEUDO_PREFIX was a diagnostic and exit(1), and still is, from the local state setup directly below. The sweeps in OP_CLOSEFROM and OP_CLOSE_RANGE no longer need to step around the descriptor, so the entries the previous commit added for it go away again. Discussed in https://lore.kernel.org/yocto-patches/20260716055633.7-1-bbnpreetsingh@gmail.com/ AI-Generated: Uses Claude (claude-sonnet-5) Signed-off-by: Babanpreet Singh --- doc/program_flow | 1 - pseudo_client.c | 66 +++++------------------------------------------- pseudo_client.h | 1 - 3 files changed, 6 insertions(+), 62 deletions(-) diff --git a/doc/program_flow b/doc/program_flow index 3a399a7..e987e4a 100644 --- a/doc/program_flow +++ b/doc/program_flow @@ -15,7 +15,6 @@ libpseudo execution flow: setup pseudo_logfile pseudo_client.c: pseudo_init_client() setup PSEUDO_DISABLED - setup pseudo_prefix_dir_fd setup pseudo_localstate_dir_fd setup PSEUDO_NOSYMLINKEXP setup PSEUDO_UIDS diff --git a/pseudo_client.c b/pseudo_client.c index 7f80a3b..46b6a3b 100644 --- a/pseudo_client.c +++ b/pseudo_client.c @@ -46,7 +46,6 @@ static char *base_path(int dirfd, const char *path, int leave_last); static int connect_fd = -1; static int server_pid = 0; -int pseudo_prefix_dir_fd = -1; int pseudo_localstate_dir_fd = -1; int pseudo_pwd_fd = -1; int pseudo_pwd_lck_fd = -1; @@ -532,7 +531,6 @@ pseudo_init_client(void) { if (!pseudo_inited) { /* Ensure that all of the values are reset */ server_pid = 0; - pseudo_prefix_dir_fd = -1; pseudo_localstate_dir_fd = -1; pseudo_pwd_fd = -1; pseudo_pwd_lck_fd = -1; @@ -555,29 +553,6 @@ pseudo_init_client(void) { pseudo_umask = umask(022); umask(pseudo_umask); - pseudo_path = pseudo_prefix_path(NULL); - if (pseudo_prefix_dir_fd == -1) { - if (pseudo_path) { - pseudo_prefix_dir_fd = open(pseudo_path, O_RDONLY); - /* directory is missing? */ - if (pseudo_prefix_dir_fd == -1 && errno == ENOENT) { - pseudo_debug(PDBGF_CLIENT, "prefix directory '%s' doesn't exist, trying to create\n", pseudo_path); - mkdir_p(pseudo_path); - pseudo_prefix_dir_fd = open(pseudo_path, O_RDONLY); - } - pseudo_prefix_dir_fd = pseudo_fd(pseudo_prefix_dir_fd, MOVE_FD); - } else { - pseudo_diag("No prefix available to to find server.\n"); - exit(1); - } - if (pseudo_prefix_dir_fd == -1) { - pseudo_diag("Can't open prefix path '%s' for server: %s\n", - pseudo_path, - strerror(errno)); - exit(1); - } - } - free(pseudo_path); pseudo_path = pseudo_localstatedir_path(NULL); if (pseudo_localstate_dir_fd == -1) { if (pseudo_path) { @@ -1439,29 +1414,6 @@ pseudo_client_shutdown(int wait_on_socket) { char *pseudo_path; pseudo_debug(PDBGF_INVOKE, "attempting to shut down server.\n"); - pseudo_path = pseudo_prefix_path(NULL); - if (pseudo_prefix_dir_fd == -1) { - if (pseudo_path) { - pseudo_prefix_dir_fd = open(pseudo_path, O_RDONLY); - /* directory is missing? */ - if (pseudo_prefix_dir_fd == -1 && errno == ENOENT) { - pseudo_debug(PDBGF_CLIENT, "prefix directory doesn't exist, trying to create\n"); - mkdir_p(pseudo_path); - pseudo_prefix_dir_fd = open(pseudo_path, O_RDONLY); - } - pseudo_prefix_dir_fd = pseudo_fd(pseudo_prefix_dir_fd, COPY_FD); - free(pseudo_path); - } else { - pseudo_diag("No prefix available to to find server.\n"); - exit(1); - } - if (pseudo_prefix_dir_fd == -1) { - pseudo_diag("Can't open prefix path (%s) for server. (%s)\n", - pseudo_prefix_path(NULL), - strerror(errno)); - exit(1); - } - } pseudo_path = pseudo_localstatedir_path(NULL); mkdir_p(pseudo_path); if (pseudo_localstate_dir_fd == -1) { @@ -1970,8 +1922,6 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path startfd = pseudo_util_debug_fd + 1; if (pseudo_util_evlog_fd >= startfd) startfd = pseudo_util_evlog_fd + 1; - if (pseudo_prefix_dir_fd >= startfd) - startfd = pseudo_prefix_dir_fd + 1; if (pseudo_localstate_dir_fd >= startfd) startfd = pseudo_localstate_dir_fd + 1; if (pseudo_pwd_fd >= startfd) @@ -1984,9 +1934,9 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path startfd = connect_fd + 1; for (i = fd; i < startfd; ++i) { if (i == pseudo_util_debug_fd || i == pseudo_util_evlog_fd || - i == pseudo_prefix_dir_fd || i == pseudo_localstate_dir_fd || - i == pseudo_pwd_fd || i == pseudo_pwd_lck_fd || - i == pseudo_grp_fd || i == connect_fd) + i == pseudo_localstate_dir_fd || i == pseudo_pwd_fd || + i == pseudo_pwd_lck_fd || i == pseudo_grp_fd || + i == connect_fd) continue; pseudo_client_close(i); close(i); @@ -2004,8 +1954,6 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path startfd = pseudo_util_debug_fd + 1; if (pseudo_util_evlog_fd >= startfd) startfd = pseudo_util_evlog_fd + 1; - if (pseudo_prefix_dir_fd >= startfd) - startfd = pseudo_prefix_dir_fd + 1; if (pseudo_localstate_dir_fd >= startfd) startfd = pseudo_localstate_dir_fd + 1; if (pseudo_pwd_fd >= startfd) @@ -2021,9 +1969,9 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path */ for (i = fd; i < startfd && (unsigned int) i <= close_range_maxfd; ++i) { if (i == pseudo_util_debug_fd || i == pseudo_util_evlog_fd || - i == pseudo_prefix_dir_fd || i == pseudo_localstate_dir_fd || - i == pseudo_pwd_fd || i == pseudo_pwd_lck_fd || - i == pseudo_grp_fd || i == connect_fd) + i == pseudo_localstate_dir_fd || i == pseudo_pwd_fd || + i == pseudo_pwd_lck_fd || i == pseudo_grp_fd || + i == connect_fd) continue; pseudo_client_close(i); close(i); @@ -2045,8 +1993,6 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path } } else if (fd == pseudo_util_debug_fd) { pseudo_util_debug_fd = pseudo_fd(fd, COPY_FD); - } else if (fd == pseudo_prefix_dir_fd) { - pseudo_prefix_dir_fd = pseudo_fd(fd, COPY_FD); } else if (fd == pseudo_localstate_dir_fd) { pseudo_localstate_dir_fd = pseudo_fd(fd, COPY_FD); } else if (fd == pseudo_pwd_fd) { diff --git a/pseudo_client.h b/pseudo_client.h index a013f88..206f630 100644 --- a/pseudo_client.h +++ b/pseudo_client.h @@ -39,7 +39,6 @@ extern gid_t pseudo_egid; extern gid_t pseudo_sgid; extern gid_t pseudo_rgid; extern gid_t pseudo_fgid; -extern int pseudo_prefix_dir_fd; extern int pseudo_localstate_dir_fd; extern FILE *pseudo_pwd_open(void); extern FILE *pseudo_grp_open(void);