pidfd design
Quoted 3 lines
What would be your opinion to having a
/proc/<pid>/handle
file instead of having a dirfd.
This is even worse than depending on PROC_FS. Just for the dependency pidfd code should be backed out immediately. Forget about /proc.
Quoted 6 lines · Alexey Dobriyan
Quoted 3 lines
What would be your opinion to having a
/proc/<pid>/handle
file instead of having a dirfd.This is even worse than depending on
PROC_FS. Just for the dependency pidfd code should be backed out immediately. Forget about /proc.
We already have pidfds, and we've had them since /proc was added ages ago. Backing out procfs is a bold proposal.
Quoted 10 lines · Daniel Colascione
Quoted 6 lines · Alexey Dobriyan
Quoted 3 lines
What would be your opinion to having a
/proc/<pid>/handle
file instead of having a dirfd.This is even worse than depending on
PROC_FS. Just for the dependency pidfd code should be backed out immediately. Forget about /proc.We already have pidfds, and we've had them since /proc was added ages ago.
New pidfd code (or whatever the name) should NOT depend on /proc and should not interact with VFS at all at any point (other than probably being a descriptor on a fake filesystem). The reason is that /proc is full of crap and you don't want to spill that into new and hopefully properly designed part of new code.
Quoted 9 lines · Alexey Dobriyan
Quoted 8 lines · Daniel Colascione
Quoted 6 lines · Alexey Dobriyan
Quoted 3 lines
What would be your opinion to having a
/proc/<pid>/handle
file instead of having a dirfd.This is even worse than depending on
PROC_FS. Just for the dependency pidfd code should be backed out immediately. Forget about /proc.
Quoted 8 lines
Quoted 2 lines
We already have pidfds, and we've had them since /proc was added ages ago.
New pidfd code (or whatever the name) should NOT depend on /proc and should not interact with VFS at all at any point (other than probably being a descriptor on a fake filesystem). The reason is that /proc is full of crap and you don't want to spill that into new and hopefully properly designed part of new code.
Yes, I agree. That's why I was thinking that translate_pid() is a good candidate to provide that decoupling.
Quoted 14 lines · Christian Brauner
Quoted 12 lines · Alexey Dobriyan
Quoted 10 lines · Daniel Colascione
Quoted 6 lines · Alexey Dobriyan
Quoted 3 lines
What would be your opinion to having a
/proc/<pid>/handle
file instead of having a dirfd.This is even worse than depending on
PROC_FS. Just for the dependency pidfd code should be backed out immediately. Forget about /proc.We already have pidfds, and we've had them since /proc was added ages ago.
Quoted 8 lines
Quoted 5 lines
New pidfd code (or whatever the name) should NOT depend on /proc and should not interact with VFS at all at any point (other than probably being a descriptor on a fake filesystem). The reason is that /proc is full of crap and you don't want to spill that into new and hopefully properly designed part of new code.
Yes, I agree. That's why I was thinking that
translate_pid()is a good candidate to provide that decoupling.
Then again: how do you propose fetching process metadata? If you adopt a stance that nothing can use procfs and simultaneously adopt a stance that we don't want to duplicate all the decades of metadata interfaces in /proc/pid (which are useful, not "crap"), then the overall result is that we just won't make any progress at all. There's nothing wrong with taking a dependency on procfs: procfs is how we talk about processes. It's completely unreasonable to say "no, you can't use the old thing" and also "no, we can't add a new thing that would duplicate the old thing".
Quoted 24 lines · Daniel Colascione
Quoted 14 lines · Christian Brauner
Quoted 12 lines · Alexey Dobriyan
Quoted 10 lines · Daniel Colascione
Quoted 6 lines · Alexey Dobriyan
Quoted 3 lines
What would be your opinion to having a
/proc/<pid>/handle
file instead of having a dirfd.This is even worse than depending on
PROC_FS. Just for the dependency pidfd code should be backed out immediately. Forget about /proc.We already have pidfds, and we've had them since /proc was added ages ago.
Quoted 8 lines
Quoted 5 lines
New pidfd code (or whatever the name) should NOT depend on /proc and should not interact with VFS at all at any point (other than probably being a descriptor on a fake filesystem). The reason is that /proc is full of crap and you don't want to spill that into new and hopefully properly designed part of new code.
Yes, I agree. That's why I was thinking that
translate_pid()is a good candidate to provide that decoupling.
Quoted 9 lines
Then again: how do you propose fetching process metadata? If you adopt a stance that nothing can use procfs and simultaneously adopt a stance that we don't want to duplicate all the decades of metadata interfaces in
/proc/pid(which are useful, not "crap"), then the overall result is that we just won't make any progress at all. There's nothing wrong with taking a dependency on procfs: procfs is how we talk about processes. It's completely unreasonable to say "no, you can't use the old thing" and also "no, we can't add a new thing that would duplicate the old thing".
This style or arguing won't get us any further. Please, send in the code that you think is right and you want to get reviewed. If you can get the Acks from the people you need, good.
Quoted 2 lines · Alexey Dobriyan
pidfd code should be backed out immediately. Forget about /proc.
Seems like Torvalds just merges this sort of "stuff" without reading it now, or there's something that auto accepted pull request to RC tree?
Quoted 8 lines
The pull request you sent on Tue, 5 Mar 2019 18:13:01 +0100:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.gittags/pidfd-v5.1-rc1has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/a9dce6679d736cb3d612af39bab9f31f8db66f9bThank you!
Quoted 7 lines · Michael Tirado
Quoted 2 lines · Alexey Dobriyan
pidfd code should be backed out immediately. Forget about /proc.
Seems like Torvalds just merges this sort of "stuff" without reading it now, or there's something that auto accepted pull request to RC tree?
There is no auto-accept.
But there also didn't seem to be any valid arguments against it, and the android people had arguments for it.
Arguing against it based on "I don't like /proc" is pointless. The fact is, /proc is our system interface for a lot of things.
Arguing against it based on "I worry about the _other_ non-signal-sending things that could be done with this" is also pointless. What other things? The only thing that got merged was the signalling.
Now, arguing that signalling should use the open-time credentials might make sense, but this isn't read/write. You can't fool some suid program to do magic randon system calls for you, and if you can, then arguing about pidfd is kind of pointless.
So the model of using a file descriptor instead of a 'pid' for signal handling is actually very unix-like. Maybe that's how pid's should have worked to begin with. Remember that whole "everything is a file" thing?
Now, the fact that fork() and clone() return a pid obviously means that pidfd isn't the primary model (not to decades of just history), but that doesn't make pidfd wrong.
And namespace issues etc are all also kind of irrelevant. If you open random files in /proc and randomly do pidfd_send_signal() on those, you get random results. If that worries you, then DON'T DO THAT THEN, for chrissake! That's not a sane model to begin with, but it's not the usage model for this, so it's another completely specious argument.
So yes, I thought about the pidfd pull (which was why it happened at the very end of the merge window), and I found the arguments against it bad.
Linus
Quoted 6 lines · Michael Tirado
Quoted 2 lines · Alexey Dobriyan
pidfd code should be backed out immediately. Forget about /proc.
Seems like Torvalds just merges this sort of "stuff" without reading it now, or there's something that auto accepted pull request to RC tree?
I don't mind controversy around patchsets but I'd appreciate it that when they are started the Cc is not modified and main people who maintain the code that is critized are removed. I'd like to be able to respond without other people having to notify me that there's a discussion going on I should be involved in.
Christian
Quoted 9 lines
Quoted 9 lines
The pull request you sent on Tue, 5 Mar 2019 18:13:01 +0100:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.gittags/pidfd-v5.1-rc1has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/a9dce6679d736cb3d612af39bab9f31f8db66f9bThank you!
Quoted 7 lines · Linus Torvalds
Quoted 5 lines · Michael Tirado
Quoted 2 lines · Alexey Dobriyan
pidfd code should be backed out immediately. Forget about /proc.
Quoted 8 lines
Quoted 2 lines
Seems like Torvalds just merges this sort of "stuff" without reading it now, or there's something that auto accepted pull request to RC tree?
There is no auto-accept.
But there also didn't seem to be any valid arguments against it, and the android people had arguments for it.
Isn't Google working on their own C++ kernel now, I bet they would want to make a smooth transition to that at some point? Hopefully they don't screw up Linux in the process.
Quoted 3 lines
Arguing against it based on "I don't like /proc" is pointless. The fact is, /proc is our system interface for a lot of things.
The argument was valid to me, at least the design is not set in stone just yet and there is still hope. I have an option in my namespace sandbox called "noproc", it works for many things, but if devs start relying on /proc ALWAYS being available I begin to have issues. You are all aware of the horrors of /proc, I hope. I don't want /proc so deeply entrenched in the ecosystem that I can no longer use "noproc". These sort of bold new core features need to be designed with extreme caution and awareness of the full spectra of affects. Just because something like procfs exists and can be used doesn't mean it is wise to go all-in.
Quoted 5 lines
Arguing against it based on "I worry about the _other_ non-signal-sending things that could be done with this" is also pointless. What other things? The only thing that got merged was the signalling.
There have been "future changes" hinted through the patches lifecycle, it leads me to believe it's a gateway patch, and the pid wrapping is a minor bugfix bridge to some other undisclosed features. How could anyone know the design is right without knowing what these changes might be?
pidctl/translate_pid?
I am against any new systemcall that crosses namespaces by design to accomplish something that is already plummable. Seems like they want to use pidfd's as some sort of token to perform these cross namespace operations, can't wait to see how devs end up abusing this one.
Quoted 5 lines
So the model of using a file descriptor instead of a 'pid' for signal handling is actually very unix-like. Maybe that's how pid's should have worked to begin with. Remember that whole "everything is a file" thing?
Perhaps it could be called an improvement if yall get it right because AFAIK the only way to handle wrapping today is to directly clone the PID you're worried about and deal with it immediately when the process exits before wrap can happen. But I really wonder why PID wrapping matters SO much, I bet some people are doing dangerously stupid things like using PID as a credential even though everyone knows it wraps.
Maybe this can make signalling less racey somehow?
At the very least you could learn the process has exited instead of blindly acting on a potentially recycled number. I recognize the value in that specifically.
However, using pidfd as a token to do cross-namespace activities that are already plummable is just plain weird to me, but maybe I'm too used to doing things "the hard way".
Quoted 14 lines · Linus Torvalds
Quoted 7 lines · Michael Tirado
Quoted 2 lines · Alexey Dobriyan
pidfd code should be backed out immediately. Forget about /proc.
Seems like Torvalds just merges this sort of "stuff" without reading it now, or there's something that auto accepted pull request to RC tree?
There is no auto-accept.
But there also didn't seem to be any valid arguments against it, and the android people had arguments for it.
Quoted 7 lines
Arguing against it based on "I don't like /proc" is pointless. The fact is, /proc is our system interface for a lot of things.
Arguing against it based on "I worry about the _other_ non-signal-sending things that could be done with this" is also pointless. What other things? The only thing that got merged was the signalling.
To back Linus defense up with a glimpse into the future.
We will not be to rely on dirfds from proc to do general process management. That is even in the commit message for the pidfd_send_signal syscall, that we intend to decouple this from procfs, i.e. decouple process management from process metadata reading.
We have an ongoing discussion and what a lot of people agree upon is that pidfds will be anon inode file descriptors that stash a reference to struct pid in their private_data member. They can be pollable if ever need be and they are just conceptually cleaner and way simpler and mirror what will happen in the new mount api as well.
The idea is to translate these pidfds e.g. via a simple ioctl() interface that takes a pidfd and gives back - with standard permissions applied as are today - a corresponding /proc/<pid> fd that can be used to read metadata of a process (see the suggestion by Andy and Jann [1]). The advantage is that this means that pidfd_clone() or something similar can simply return a pidfd and does not need to care about what procfs the process is supposed to be located in/reference and is in general way safer.
But there is absolutely nothing wrong with allowing users to use /proc/<pid> to signal processes. One of the reasons why I did this is that it is so intuitive to users that non-kernel people have requested this be possible over and over.
As mentioned in the orignal patchset the future was always to decouple this from procfs (see the references in there) and this is what the new pidctl() syscall is for that transparently translates between the pid-based api and the pidfd-based api.
[1]: https://lore.kernel.org/lkml/CAG48ez3VMjLJBC_F3BxC2sc2s-28NdsrUduR=jX66XH0w2O-Qg@mail.gmail.com/
Quoted 26 lines
Now, arguing that signalling should use the open-time credentials might make sense, but this isn't read/write. You can't fool some suid program to do magic randon system calls for you, and if you can, then arguing about pidfd is kind of pointless.
So the model of using a file descriptor instead of a 'pid' for signal handling is actually very unix-like. Maybe that's how pid's should have worked to begin with. Remember that whole "everything is a file" thing?
Now, the fact that
fork()andclone()return a pid obviously means that pidfd isn't the primary model (not to decades of just history), but that doesn't make pidfd wrong.And namespace issues etc are all also kind of irrelevant. If you open random files in /proc and randomly do
pidfd_send_signal()on those, you get random results. If that worries you, then DON'T DO THAT THEN, for chrissake! That's not a sane model to begin with, but it's not the usage model for this, so it's another completely specious argument.So yes, I thought about the pidfd pull (which was why it happened at the very end of the merge window), and I found the arguments against it bad.
Linus