All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Hatle <mark.hatle@kernel.crashing.org>
To: yocto-patches@lists.yoctoproject.org
Cc: seebs@seebs.net, richard.purdie@linuxfoundation.org
Subject: [pseudo][PATCH 09/20] ports/unix/guts/realpath.c: realpath fails if the resolved path doesn't exist
Date: Thu, 15 Jan 2026 17:43:25 -0600	[thread overview]
Message-ID: <1768520616-7289-10-git-send-email-mark.hatle@kernel.crashing.org> (raw)
In-Reply-To: <1768520616-7289-1-git-send-email-mark.hatle@kernel.crashing.org>

From: Gauthier HADERER <ghaderer@wyplay.com>

The pseudo implementation of `realpath()' may return a path which doesn't
exist. This is not POSIX compliant and causes troubles with uutils (coreutils
in Rust).

For example, the tail commands tries to determine the file path of its standard
input file descriptor by calling `realpath("/dev/fd/0")'. When the input is a
pipe, the GNU C library returns NULL but pseudo returns
`/proc/<pid>/fd/pipe:[xxxxxx]'. As it got a path, the tail command tries to
open it and fails.

Contributed-by: Gauthier HADERER <ghaderer@wyplay.com> via
yocto-patches@lists.yoctoproject.org

Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
---
 ports/unix/guts/realpath.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/ports/unix/guts/realpath.c b/ports/unix/guts/realpath.c
index 8d8118b..c13eb93 100644
--- a/ports/unix/guts/realpath.c
+++ b/ports/unix/guts/realpath.c
@@ -14,6 +14,15 @@
 		errno = ENAMETOOLONG;
 		return NULL;
 	}
+
+	/* We must fail if the target path doesn't exist. */
+	PSEUDO_STATBUF buf;
+
+	if (base_lstat(rname, &buf) == -1) {
+		errno = EINVAL;
+		return NULL;
+	}
+
 		len = strlen(rname);
 		char *ep = rname + len - 1;
 		while (ep > rname && *ep == '/') {
-- 
2.43.0



  parent reply	other threads:[~2026-01-15 23:43 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-15 23:43 [pseudo][PATCH 00/20] Consolidated pseudo patches Mark Hatle
2026-01-15 23:43 ` [pseudo][PATCH 01/20] test-syscall: Remove build warning Mark Hatle
2026-01-15 23:43 ` [pseudo][PATCH 02/20] test: Cleanup test output Mark Hatle
2026-01-15 23:43 ` [pseudo][PATCH 03/20] test/test-statx.sh: It should be a failure if pseudo prints an error Mark Hatle
2026-01-15 23:43 ` [pseudo][PATCH 04/20] test-realpath: Verify the realpath behavior matches glibc Mark Hatle
2026-01-15 23:43 ` [pseudo][PATCH 05/20] run_tests.sh: In verbose mode, include pseudo.log in output Mark Hatle
2026-01-15 23:43 ` [pseudo][PATCH 06/20] test/test-statx: Add uutils test case Mark Hatle
2026-01-15 23:43 ` [pseudo][PATCH 07/20] test/test-nftw: Avoid compile warnings Mark Hatle
2026-01-15 23:43 ` [pseudo][PATCH 08/20] test-tclsh-fork: Skip test if tclsh is not available Mark Hatle
2026-01-15 23:43 ` Mark Hatle [this message]
2026-01-15 23:43 ` [pseudo][PATCH 10/20] test/test-proc-pipe.sh: Add test case for proc pipes Mark Hatle
2026-01-15 23:43 ` [pseudo][PATCH 11/20] pseudo_util.c: Skip realpath like expansion for /proc on Linux Mark Hatle
2026-01-15 23:43 ` [pseudo][PATCH 12/20] ports/unix/guts/realpath.c: Fix indents Mark Hatle
2026-01-15 23:43 ` [pseudo][PATCH 13/20] ports/linux/pseudo_wrappers.c: Reorder the syscall operations Mark Hatle
2026-01-15 23:43 ` [pseudo][PATCH 14/20] ports/linux/pseudo_wrappers.c: Call the wrappers where possible Mark Hatle
2026-01-15 23:43 ` [pseudo][PATCH 15/20] ports/linux: Add additional EFAULTS for Linux functions Mark Hatle
2026-01-15 23:43 ` [pseudo][PATCH 16/20] Update COPYRIGHT files Mark Hatle
2026-01-15 23:43 ` [pseudo][PATCH 17/20] makewrappers: improve error handling and robustness Mark Hatle
2026-01-15 23:43 ` [pseudo][PATCH 18/20] pseudo: code quality scan - resolved various potential issues Mark Hatle
2026-01-15 23:43 ` [pseudo][PATCH 19/20] configure: Minor code quality changes Mark Hatle
2026-01-15 23:43 ` [pseudo][PATCH 20/20] Makefile.in: Bump version to 1.9.3 Mark Hatle
     [not found] ` <188B0C23901378A4.2703508@lists.yoctoproject.org>
2026-01-17 16:08   ` [yocto-patches] [pseudo][PATCH 13/20] ports/linux/pseudo_wrappers.c: Reorder the syscall operations Mark Hatle
     [not found] ` <188B0C2348C47D4E.2703508@lists.yoctoproject.org>
2026-01-17 16:10   ` [yocto-patches] [pseudo][PATCH 15/20] ports/linux: Add additional EFAULTS for Linux functions Mark Hatle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1768520616-7289-10-git-send-email-mark.hatle@kernel.crashing.org \
    --to=mark.hatle@kernel.crashing.org \
    --cc=richard.purdie@linuxfoundation.org \
    --cc=seebs@seebs.net \
    --cc=yocto-patches@lists.yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.