[Bug 272127] fdescfs with linkrdlnk fails openat with O_DIRECTORY unless "ls -l" done in fdescfs dir first...

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 21 Jun 2023 13:58:47 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=272127

--- Comment #2 from Peter Eriksson <pen@lysator.liu.se> ---
It's not just related to O_DIRECTORY but a more general problem with fdescfs...

root@runur00:/export/build/samba # umount /compat/linux/dev/fd
root@runur00:/export/build/samba # mount /compat/linux/dev/fd

root@runur00:/export/build/samba # ./t -d /home/peter86 RUNUR00
open("/home/peter86", O_PATH) -> 3
  facl(3, ACE_GETACLCNT) -> -1 [errno=9 (Bad file descriptor)]
  openat(3, "RUNUR00", O_RDONLY) -> 4
    facl(4, ACE_GETACLCNT) -> 3
    acl("/compat/linux/dev/fd/4", ACE_GETACLCNT) -> -1 [errno=78 (Function not
implemented)]
  openat(3, "RUNUR00", O_PATH) -> 4
    facl(4, ACE_GETACLCNT) -> -1 [errno=9 (Bad file descriptor)]
    acl("/compat/linux/dev/fd/4", ACE_GETACLCNT) -> -1 [errno=78 (Function not
implemented)]
    openat(4, "", O_EMPTY_PATH) -> 5
      facl(5, ACE_GETACLCNT) -> 3
    open("/compat/linux/dev/fd/4", O_RDONLY) -> -1 [errno=20 (Not a directory)]

root@runur00:/export/build/samba # ls -ld /home/peter86/RUNUR00
drwx------+ 2 peter86  employee-liu.se  2 Jun 20 10:52 /home/peter86/RUNUR00

root@runur00:/export/build/samba # ./t -ssd /home/peter86 RUNUR00
open("/home/peter86", O_PATH) -> 3
  facl(3, ACE_GETACLCNT) -> -1 [errno=9 (Bad file descriptor)]
  openat(3, "RUNUR00", O_RDONLY) -> 4
    facl(4, ACE_GETACLCNT) -> 3
    stat("/compat/linux/dev/fd/4") -> 0 [type=symlink, size=0, uid=0, gid=0]
    readlink("/compat/linux/dev/fd/4") -> 28
[path=/export/home/peter86/RUNUR00]
    stat("/compat/linux/dev/fd/4") -> 0 [type=dir, size=2, uid=1003258,
gid=100001000]
    acl("/compat/linux/dev/fd/4", ACE_GETACLCNT) -> 3
  openat(3, "RUNUR00", O_PATH) -> 4
    facl(4, ACE_GETACLCNT) -> -1 [errno=9 (Bad file descriptor)]
    stat("/compat/linux/dev/fd/4") -> 0 [type=dir, size=2, uid=1003258,
gid=100001000]
    stat("/compat/linux/dev/fd/4") -> 0 [type=dir, size=2, uid=1003258,
gid=100001000]
    acl("/compat/linux/dev/fd/4", ACE_GETACLCNT) -> 3
    openat(4, "", O_EMPTY_PATH) -> 5
      facl(5, ACE_GETACLCNT) -> 3
    open("/compat/linux/dev/fd/4", O_RDONLY) -> 5
      facl(5, ACE_GETACLCNT) -> 3

root@runur00:/export/build/samba # ./t -d /home/peter86 RUNUR00
open("/home/peter86", O_PATH) -> 3
  facl(3, ACE_GETACLCNT) -> -1 [errno=9 (Bad file descriptor)]
  openat(3, "RUNUR00", O_RDONLY) -> 4
    facl(4, ACE_GETACLCNT) -> 3
    acl("/compat/linux/dev/fd/4", ACE_GETACLCNT) -> 3
  openat(3, "RUNUR00", O_PATH) -> 4
    facl(4, ACE_GETACLCNT) -> -1 [errno=9 (Bad file descriptor)]
    acl("/compat/linux/dev/fd/4", ACE_GETACLCNT) -> 3
    openat(4, "", O_EMPTY_PATH) -> 5
      facl(5, ACE_GETACLCNT) -> 3
    open("/compat/linux/dev/fd/4", O_RDONLY) -> 5
      facl(5, ACE_GETACLCNT) -> 3


See how the first stat() call to a fd in the fdescfs also gives invalid size,
uid & gid data but as soon as that stat call has pulled in the information
about the target things work fine.

-- 
You are receiving this mail because:
You are the assignee for the bug.