-
Notifications
You must be signed in to change notification settings - Fork 257
Adding checks for fd omission #964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e740ca3 to
706f73a
Compare
|
On Fri, Mar 08, 2024 at 05:18:22PM -0800, Skyler Ferrante wrote:
@skyler-ferrante commented on this pull request.
> (Alternatively, you might unconditionally close devnull.)
I think this is dangerous, since devnull is guaranteed to be equal to the fd we are checking. If stdin (0) is not open and we open(/dev/null) devnull should be equal to 0. The dup2 isn't actually necessary, its just a good idea to do, since a system might not hand out new fds starting at the lowest available.
Ahh, sorry, I forgot! You're right.
> Mind that the if is there because a leak for fd 0 1 or 2 is not really a leak, since those fds we actually want them open.
It should only be a leak if the system doesn't give new fds starting at the lowest option available since we start at 0 and go to 3. But yeah, it's still probably a good idea to check.
Hmmm, I don't mind removing the check. Or maybe we should abort if it
is true, because it should never be.
…
|
Adding function check_fds to new file fd.c. The function check_fds should be called in every setuid/setgid program. Co-developed-by: Alejandro Colomar <alx@kernel.org>
|
@hallyn , I'd merge this, but the master branch doesn't yet contain the 4.15.0 release tag (and thus still has the 4.14.0 version in configure.ac). Would you please fast-forward master before merging this? |
It doesn't? I did push it, and used it for making the release: https://github.com/shadow-maint/shadow/releases/tag/4.15.0 What's missing? |
|
Anyway +1 from me, I was about to merge when I noticed your comment. |
I think the branch protection might have caused your push to (partially?) fail? Now I see you've merged&pushed another branch: The tag was correctly pushed, but the branch wasn't fast-forwarded to the tag. |
Adding function check_fds to new file fd.c. The function check_fds should be called in every setuid/setgid program. Co-developed-by: Alejandro Colomar <alx@kernel.org> Cherry-picked-from: d2f2c18 ("Adding checks for fd omission") Link: <#964> Link: <https://inbox.sourceware.org/libc-alpha/ZeyujhVRsDTUNUtw@debian/T/> [alx: It seems we shouldn't need this, as libc does it for us. But it ] [ shouldn't hurt either. Let's be paranoic. ] Cc: <Guillem Jover <guillem@hadrons.org> Cc: "Serge E. Hallyn" <serge@hallyn.com> Cc: "Skyler Ferrante (RIT Student)" <sjf5462@rit.edu> Cc: Iker Pedrosa <ipedrosa@redhat.com> Cc: Christian Brauner <christian@brauner.io> Cc: Rich Felker <dalias@libc.org> Cc: Andreas Schwab <schwab@linux-m68k.org> Cc: Thorsten Glaser <tg@mirbsd.de> Cc: NRK <nrk@disroot.org> Cc: Florian Weimer <fweimer@redhat.com> Cc: enh <enh@google.com> Cc: Laurent Bercot <ska-dietlibc@skarnet.org> Cc: Gabriel Ravier <gabravier@gmail.com> Cc: Zack Weinberg <zack@owlfolio.org> Signed-off-by: Alejandro Colomar <alx@kernel.org>
Adding function check_fds to new file fd.c. The function check_fds should be called in every setuid/setgid program. Co-developed-by: Alejandro Colomar <alx@kernel.org> Cherry-picked-from: d2f2c18 ("Adding checks for fd omission") Link: <#964> Link: <https://inbox.sourceware.org/libc-alpha/ZeyujhVRsDTUNUtw@debian/T/> [alx: It seems we shouldn't need this, as libc does it for us. But it ] [ shouldn't hurt either. Let's be paranoic. ] Cc: <Guillem Jover <guillem@hadrons.org> Cc: "Serge E. Hallyn" <serge@hallyn.com> Cc: "Skyler Ferrante (RIT Student)" <sjf5462@rit.edu> Cc: Iker Pedrosa <ipedrosa@redhat.com> Cc: Christian Brauner <christian@brauner.io> Cc: Rich Felker <dalias@libc.org> Cc: Andreas Schwab <schwab@linux-m68k.org> Cc: Thorsten Glaser <tg@mirbsd.de> Cc: NRK <nrk@disroot.org> Cc: Florian Weimer <fweimer@redhat.com> Cc: enh <enh@google.com> Cc: Laurent Bercot <ska-dietlibc@skarnet.org> Cc: Gabriel Ravier <gabravier@gmail.com> Cc: Zack Weinberg <zack@owlfolio.org> Signed-off-by: Alejandro Colomar <alx@kernel.org>
Adding function check_fds to new file fd.c. The function check_fds should be called in every setuid/setgid program. I also added sanitize_env to every setuid/setgid program.