PR_CAPBSET_DROP requires CAP_SETPCAP. Without that requirement, a user could run a set-uid root program with a capability removed that the program relies on. A program that does not notice that it failed to drop its privileges would then carry on with them. In a cell no program gains anything from its file, so there is no such program to trick. A task that wants to give less to the programs it starts should not need a capability for that. This matters in practice. systemd removes every capability from the bounding set of a service that the unit does not list, and fails the service if it cannot. In a cell that has CAP_KILL but not CAP_SETPCAP, journald does not start. Let a task of a cell drop capabilities from its bounding set without CAP_SETPCAP. Signed-off-by: Josef Bacik --- security/commoncap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/security/commoncap.c b/security/commoncap.c index 02e25ab18f56..1e0ef7465766 100644 --- a/security/commoncap.c +++ b/security/commoncap.c @@ -1281,7 +1281,12 @@ static int cap_prctl_drop(unsigned long cap) { struct cred *new; - if (!ns_capable(current_user_ns(), CAP_SETPCAP)) + /* + * It takes a capability lest a program that gains from its file runs with + * less than it counts on. In a cell no program gains anything from a file. + */ + if (!ns_capable(current_user_ns(), CAP_SETPCAP) && + !userns_is_cell(current_user_ns())) return -EPERM; if (!cap_valid(cap)) return -EINVAL; -- 2.55.0