vfswrap_getxattrat_do_async and unshare(CLONE_FS)

Florian Weimer fweimer at redhat.com
Mon Oct 24 21:46:22 UTC 2022


As far as I can tell, vfswrap_getxattrat_do_async relies on
unshare(CLONE_FS) to do fgetxattrat emulation with a thread-local fchdir
and getxattr.  There do not seem to be any other uses in the sources.

I think the more usual way to emulate the missing fgetxattrat system
call is to open the file with openat and O_PATH, and then use getxattr
on the synthetic path under /proc/self/fd.  While these paths present as
symbolic links, they actually are not, so there is no race possible.
(fgetxattr cannot operate on the open file descriptor directly.)

Why wasn't the /proc-based approach chosen for Samba?  It looks a bit
simpler to implement, and does not do strange things to the process
state behind glibc's back.

This came up in a discussion regarding a proposal to implement an
interface for per-thread current working directories in glibc:

  Per-thread file system attributes
  <https://www.openwall.com/lists/libc-coord/2022/10/24/1>

Thanks,
Florian




More information about the samba-technical mailing list