Skip to contentSkip to conversation

pseudo: Upgrade to latest to fix openat() with a directory symlink

PATCH Superseded Jason Wessel 2 participants 3 messages Aug 1, 2019

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pseudo: Upgrade to latest to fix openat() with a directory symlink

While working with ostree disk generation in conjunction with wic, I found a problem with pseudo where it tried to resolve a symlink when it shouldn't, based on openat() flags. I narrowed down the problem to a simple c program to reproduce the issue:

int main()

{
    /* Tested with: gcc -Wall -o app app.c ; echo "no pseudo" ; ./app ; echo "pseudo"; pseudo ./app */
    system("rm -rf tdir tlink");
    system("mkdir tdir");
    system("ln -s tdir tlink");
    DIR *dir = opendir(".");
    int dfd = dirfd(dir);

    int target_dfd = openat (dfd, "tlink", O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW);
    if (target_dfd == -1) {
        printf("This is right\n");
    } else {
        printf("This is broken\n");
    }
    return 0;
}

Many thanks to Peter Seebach for fixing the problem in the pseudo code to use the same logic which was already there for the AT_SYMLINK_NOFOLLOW.

---
 meta/recipes-devtools/pseudo/pseudo_git.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/pseudo/pseudo_git.bb +1 -1
index 51db84c4d4..3350c3fabd 100644
@@ -8,7 +8,7 @@ SRC_URI = "git://git.yoctoproject.org/pseudo \
            file://toomanyfiles.patch \
            "
 
-SRCREV = "3fa7c853e0bcd6fe23f7524c2a3c9e3af90901c3"
+SRCREV = "097ca3e245200c4a4333964af59a106c42ff3bca"
 S = "${WORKDIR}/git"
 PV = "1.9.0+git${SRCPV}"
 
Signature · 1 line
2.21.0
#1 lore raw
Quoted 3 lines · On Thu, 1 Aug 2019 10:55:45 -0700 Jason Wessel <[email protected]>…

Many thanks to Peter Seebach for fixing the problem in the pseudo code to use the same logic which was already there for the AT_SYMLINK_NOFOLLOW.

Special credit goes to Past Seebs, who thoughtfully made the parser for wrapfuncs flexible enough that flags=flags|O_NOFOLLOW would work.

-s

#2 lore raw
In reply to Jason Wessel

Looks like the checksum license changed between the prior commit and now.  So I'll send a v2, because we don't want to break the master branch of oe-core.

Cheers,
Jason.

Quoted 45 lines · Jason Wessel

While working with ostree disk generation in conjunction with wic, I found a problem with pseudo where it tried to resolve a symlink when it shouldn't, based on openat() flags. I narrowed down the problem to a simple c program to reproduce the issue:

int main()

{
     /* Tested with: gcc -Wall -o app app.c ; echo "no pseudo" ; ./app ; echo "pseudo"; pseudo ./app */
     system("rm -rf tdir tlink");
     system("mkdir tdir");
     system("ln -s tdir tlink");
     DIR *dir = opendir(".");
     int dfd = dirfd(dir);

     int target_dfd = openat (dfd, "tlink", O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW);
     if (target_dfd == -1) {
         printf("This is right\n");
     } else {
         printf("This is broken\n");
     }
     return 0;
}

Many thanks to Peter Seebach for fixing the problem in the pseudo code to use the same logic which was already there for the AT_SYMLINK_NOFOLLOW.

---
  meta/recipes-devtools/pseudo/pseudo_git.bb | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/pseudo/pseudo_git.bb +1 -1
index 51db84c4d4..3350c3fabd 100644
@@ -8,7 +8,7 @@ SRC_URI = "git://git.yoctoproject.org/pseudo \
             file://toomanyfiles.patch \
             "
 
-SRCREV = "3fa7c853e0bcd6fe23f7524c2a3c9e3af90901c3"
+SRCREV = "097ca3e245200c4a4333964af59a106c42ff3bca"
  S = "${WORKDIR}/git"
  PV = "1.9.0+git${SRCPV}"