-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Clear ambient inherited #14133
Clear ambient inherited #14133
Conversation
cc @anitazha |
|
What happens when the following is specified?
Also, I think DBus API needs to be updated. |
|
hmm, is this really desirable this way? why not drop all ambient caps by default, and then allow AmbientCapabilities= as a method of passing them along? |
0139ed9
to
63c52dd
Compare
@poettering Yeah, I definitely agree. Having to specify dropping caps would be an opt in security feature, which is not good. Fixed and force pushed. cc @yuwata |
src/basic/capability-util.c
Outdated
@@ -138,6 +138,42 @@ int capability_ambient_set_apply(uint64_t set, bool also_inherit) { | |||
return 0; | |||
} | |||
|
|||
int capability_ambient_set_clear(uint64_t set) { |
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.
hmm, iiuc the parameter specifies the ones to keep, right? hence call it "keep" or so, to make this clearer?
src/basic/capability-util.c
Outdated
return -errno; | ||
|
||
return 0; | ||
} |
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.
shouldn't this be done in capability_ambient_set_apply()? i.e. that the function is changed to drop all ambient caps not specified and set all ambient caps specified? that would be much shorter and simpler and still do what you need, no?
Modify the functions capability_update_inherited_set() and capability_ambient_set_apply() to drop capabilities not explicitly requested by the user.
63c52dd
to
1439864
Compare
@poettering Changes made. |
looks great! one more tiny fix |
1439864
to
0430df3
Compare
@poettering Fixed and force pushed (also added the assert_se to the other call to cap_get_proc from the existing test) |
Change test_set_ambient_caps() to test_apply_ambient_caps(), since the function capability_ambient_set_apply() not only sets ambient capabilities, but clears inherited capabilities that are not explicitly requested by the caller.
The function capability_ambient_set_apply() now drops capabilities not in the capability_ambient_set(), so it is necessary to call it when the ambient set is empty. Fixes systemd#13163
0430df3
to
943800f
Compare
thanks! lgtm, but let's merge that after the 244 release |
systemd#14133 made capability_ambient_set_apply() acquire capabilities that were explicitly asked for and drop all others. This change means the function is called even with an empty capability set, opening up a code path for users without ambient capabilities to call this function. This function will error with EINVAL out on kernels < 4.3 because PR_CAP_AMBIENT is not understood. This turns capability_ambient_set_apply() into a noop for kernels < 4.3 Fixes systemd#15225
#14133 made capability_ambient_set_apply() acquire capabilities that were explicitly asked for and drop all others. This change means the function is called even with an empty capability set, opening up a code path for users without ambient capabilities to call this function. This function will error with EINVAL out on kernels < 4.3 because PR_CAP_AMBIENT is not understood. This turns capability_ambient_set_apply() into a noop for kernels < 4.3 Fixes #15225
systemd/systemd#14133 made capability_ambient_set_apply() acquire capabilities that were explicitly asked for and drop all others. This change means the function is called even with an empty capability set, opening up a code path for users without ambient capabilities to call this function. This function will error with EINVAL out on kernels < 4.3 because PR_CAP_AMBIENT is not understood. This turns capability_ambient_set_apply() into a noop for kernels < 4.3 Fixes systemd/systemd#15225 (cherry picked from commit 7ea4392)
systemd/systemd#14133 made capability_ambient_set_apply() acquire capabilities that were explicitly asked for and drop all others. This change means the function is called even with an empty capability set, opening up a code path for users without ambient capabilities to call this function. This function will error with EINVAL out on kernels < 4.3 because PR_CAP_AMBIENT is not understood. This turns capability_ambient_set_apply() into a noop for kernels < 4.3 Fixes systemd/systemd#15225
No description provided.