eudev-project / eudev

Repository for eudev development
GNU General Public License v2.0
527 stars 144 forks source link

udevd fails to start when started without stdin/out/err fds #185

Closed yshui closed 1 year ago

yshui commented 4 years ago

No sure if this should be considered a bug or not.

If udevd is started without any fd, some of the fd created during setup will occupy fd 0, 1, 2. And they will be overridden by:

https://github.com/gentoo/eudev/blob/79f7650b59c4f9261b5e9e76e3c57cfc90b2dc6b/src/udev/udevd.c#L1293-L1295

cause udevd to loss those essential fds and fail.

yshui commented 4 years ago

my suggestion would be to do the /dev/null redirections earlier

Whissi commented 3 years ago

This somehow reminds me of https://bugs.gentoo.org/547916.

kaniini commented 3 years ago

I have a patch for this pending, but want to wait until next release cycle.

ArsenArsen commented 3 years ago

iirc, some libcs correct this automatically on startup (musl I think is the most prominent one here).

there is a forgotten patch of mine that I submitted to glibc, that never got merged, if need be, I could bring it up again: https://sourceware.org/pipermail/libc-alpha/2020-August/117083.html

adding this to the list of bugs found due to weird [012] FDs would probably help too

bbonev commented 3 years ago

My opinion is that fixing that at *libc level is conceptually wrong - applications should be able to freely decide how to handle their descriptors. What does POSIX say about that?

@kaniini Please add you patch as a PR - I do not expect that to be too complex

ArsenArsen commented 3 years ago

the thread contains discussion about standards, my take is that it's a dangerous potential (and very real) footgun; glibc already exhibits this behavior for SUID binaries, and as said, musl does too for all binaries

bbonev commented 1 year ago

@kaniini Please share your patch

PS. I already proposed a fix in #266