-
Notifications
You must be signed in to change notification settings - Fork 567
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
Consider nosound and novideo when keeping groups & misc refactors #4632
Consider nosound and novideo when keeping groups & misc refactors #4632
Conversation
Move the logic from clean_supplementary_groups into the following new functions: * find_group * copy_group_ifcont These will be reused later. Misc: The latter function's signature is based on getgrouplist(2), which is used on clean_supplementary_groups.
Check if new_groups already is full before trying to add to it.
Even when `nogroups` is not used, avoid keeping the audio and video groups when `nosound` and `novideo` are used, respectively. Based on @rusty-snake's suggestion: netblue30#4603 (comment) Relates to netblue30#4603.
As noted in #4603 (comment), dropping |
6ba28f6
to
ea564eb
Compare
From https://github.com/netblue30/firejail/runs/3979333974?check_suite_focus=true:
Force-pushed to fix the above. @rusty-snake commented on Oct 22:
I don't use nvidia and that path is also owned by the "video" group on my And this PR only changes the handling of the "video" group, not the "render" But from #3644, I now see that this could be an issue on e.g.: I'll add some more checks for that. |
I think I got it. But are you sure that After re-reading #3644 and the related code, if firejail detects nvidia, then |
About nVidia IDK nothing (except that the driver situation is a shit). I've some intel graphics
As you can see |
@rusty-snake commented on Oct 22:
Then why did you say that "dropping I mentioned Relevant code:
Misc: This PR is basically part 1 of trying to fix #4603 (i.e.: that
It's basically the same thing in here (AMD).
I don't know exactly what each device file does, but maybe they can be used for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine with me.
I don't have the whole thing reloaded into my brain, but I tried the reproducer from #3644 and variants:
So: notwithstanding any auto-detection-induced behavior changes that firejail might be doing, nogroups is enough to cause failure, novideo works. |
Hello, thanks for re-testing! Considering the above, it seems that unless The udev rules don't seem to do anything special for nvidia GPUs either: $ pacman -Q udev
eudev 249.5-1
$ grep '"video"' /usr/lib/udev/rules.d/*
/usr/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="video4linux", GROUP="video"
/usr/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="graphics", GROUP="video"
/usr/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="drm", KERNEL!="renderD*", GROUP="video"
/usr/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="dvb", GROUP="video"
/usr/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="media", GROUP="video"
/usr/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="cec", GROUP="video"
/usr/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="firewire", TEST=="units", ENV{IEEE1394_UNIT_FUNCTION_VIDEO}=="1", GROUP="video"
$ grep '"render"' /usr/lib/udev/rules.d/*
/usr/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="drm", KERNEL=="renderD*", GROUP="render", MODE="0666"
/usr/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="kfd", GROUP="render", MODE="0666"
$ grep -i nvidia /usr/lib/udev/rules.d/*
/usr/lib/udev/rules.d/51-android.rules:# Nvidia
/usr/lib/udev/rules.d/51-android.rules:ATTR{idVendor}!="0955", GOTO="not_Nvidia"
/usr/lib/udev/rules.d/51-android.rules:LABEL="not_Nvidia"
/usr/lib/udev/rules.d/70-steam-input.rules:# NVIDIA Shield Portable (2013 - NVIDIA_Controller_v01.01 - In-Home Streaming only)
/usr/lib/udev/rules.d/70-steam-input.rules:# NVIDIA Shield Controller (2015 - NVIDIA_Controller_v01.03 over USB hidraw)
/usr/lib/udev/rules.d/70-steam-input.rules:# NVIDIA Shield Controller (2017 - NVIDIA_Controller_v01.04 over bluetooth hidraw) @rusty-snake What do you think? |
I still don't understand what all this has to do with nVidia. |
@rusty-snake commented on Nov 9:
It's because of this code on src/firejail/profile.c: else if (strcmp(ptr, "nogroups") == 0) {
// nvidia cards require video group; disable nogroups
if (access("/dev/nvidiactl", R_OK) == 0 && arg_no3d == 0) {
fwarning("Warning: NVIDIA card detected, nogroups command disabled\n");
arg_nogroups = 0;
}
else
arg_nogroups = 1;
return 0;
} It's a workaround for nvidia that mentions "video group" and checks for (As the one making the changes, in my mind it seemed obvious, but I should See the following commits:
You even suggested the latter one apparently: Related issues:
On the latter issue, it appears that either the "video" or "render" group (or After reading some more of #3644, it looks like this PR is probably the |
Sorry, I was getting ahead of myself. I mean drop the workaround once we split I keep forgetting that this PR only does organizing and some hardening and that |
Merged! |
Currently, on systems that use seat managers that do not implement seat-based ACLs (such as seatd), sound is broken whenever `nogroups` is used. This happens because without ACLs, access to the audio devices in /dev is controlled by the standard group permissions and the "audio" group is always dropped when `nogroups` is used. This patch makes the "audio" and "video" groups be dropped if and only if `noaudio` and `novideo` are in effect, respectively (and independently of `nogroups`). See netblue30#4603 and the linked issues/discussions for details. Note: This is a continuation of commit ea564eb ("Consider nosound and novideo when keeping groups") / PR netblue30#4632. Relates to netblue30#2042 and netblue30#4531.
Mappings of command -> group that this commit adds: * no3d -> render * noprinters -> lp * nodvd -> cdrom (Debian[1] and Gentoo[2]), optical (Arch[3]) * noinput -> input Mappings that were considered but that are not added: * notv -> ? (unknown group) * nou2f -> ? (devices are apparently owned by root; see netblue30#4603) Based on @rusty-snake's suggestion: netblue30#4603 (comment) See the previous commit ("Keep audio and video groups regardless of nogroups") for details. Relates to netblue30#2042 and netblue30#4632. [1] https://wiki.debian.org/SystemGroups [2] https://api.gentoo.org/uid-gid.txt [3] https://wiki.archlinux.org/title/Users_and_groups
Remove workaround from commit 623e682 ("temporary fix for nvidia/nogroups/noroot issue (netblue30#3644, netblue30#841)", 2020-10-02) and from commit cb460c3 ("more nvidia (netblue30#3644)", 2020-10-03). The handling of the "render" and "video" groups is separate from `nogroups` now, so disabling `nogroups` on nvidia shouldn't be necessary anymore. See the previous 2 commits for details. See also the discussion on PR netblue30#4632.
`nogroups` should not have been causing issues with rendering on nvidia since commit 623e682 ("temporary fix for nvidia/nogroups/noroot issue (netblue30#3644, netblue30#841)", 2020-10-02) and commit cb460c3 ("more nvidia (netblue30#3644)", 2020-10-03), which had made it a no-op on nvidia. And the handling of the "render" and "video" groups are independent to the handling of `nogroups` now; see the previous 3 commits. Commits which introduced the comments on each profile: * kodi.profile: commit ce462b6 ("fix netblue30#3501", 2020-07-16) * mpsyt.profile: commit e17b48f ("new profile mpsyt.profile", 2018-11-28) * mpv.profile: commit cc7c489 ("Document netblue30#1945", 2018-07-25) * steam.profile: commit d6f8169 ("steam fixes; netblue30#841, netblue30#3267", 2020-03-15) Commands used to find the comments: git grep -i nvidia -- etc/profile-* | grep -v private-etc Relates to netblue30#4632.
Even when
nogroups
is not used, avoid keeping the audio and videogroups when
nosound
andnovideo
are used, respectively.Based on @rusty-snake's suggestion:
#4603 (comment)
Relates to #4603.
Note: I haven't tested this.