-
-
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
Handle new capabilities gracefully #16420
Conversation
We would refuse to print capabilities which were didn't have a name for. The kernel adds new capabilities from time to time, most recently cap_bpf. 'systmectl show -p CapabilityBoundingSet ...' would fail with "Failed to parse bus message: Invalid argument" because capability_set_to_string_alloc() would fail with -EINVAL. So let's print such capabilities in hexadecimal: CapabilityBoundingSet=cap_chown cap_dac_override cap_dac_read_search cap_fowner cap_fsetid cap_kill cap_setgid cap_setuid cap_setpcap cap_linux_immutable cap_net_bind_service cap_net_broadcast cap_net_admin cap_net_raw cap_ipc_lock cap_ipc_owner 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1a ... For symmetry, also allow capabilities that we don't know to be specified. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1853736.
| if (!p) | ||
| return -EINVAL; | ||
| if (!p) { | ||
| xsprintf(buf, "0x%lx", i); |
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.
i is an int, hence just use %x rather than %lxhere?
| @@ -36,7 +37,7 @@ int capability_from_name(const char *name) { | |||
| /* Try to parse numeric capability */ | |||
| r = safe_atoi(name, &i); | |||
| if (r >= 0) { | |||
| if (i >= 0 && (size_t) i < ELEMENTSOF(capability_names)) | |||
| if (i >= 0 &&) | |||
| return i; | |||
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, given that we store caps masks in a 64 bit unsigned integer we should refuse caps > 63 here
|
Oh, I pushed the branch to the main repo by mistake. I'll open a new pull request with the latest version. |
No description provided.