On Mon, Jul 24, 2023 at 08:53:32AM -0700, Linus Torvalds wrote: > Is it too late to just fix pidfd_getfd() to duplicate the 'struct > file', and act like a new open, and act like /proc/<pid>/fd/<xyz>? So thinking a little about it I think that doesn't work. /proc/<pid>/fd/<xyz> does a reopen and for good reasons. The original open will have gone through the module's/subsytem's ->open() method which might stash additional refcounted data in e.g., file->private_data if we simply copy that file or sm then we risk UAFs. If we don't skip ->open() though and effectively emulate /proc/<pid>/fd/<xyz> completely then we break any such use-cases where a socket or something else is shared as they cannot be reopened. So the module/subsystem really needs to be informed that a new struct file is created and not simply refd.