statd: drop all capabilities from the bounding set as well
Subsystems (2)
RFC PATCH 1/1 statd: drop all capabilities from the bounding set as well
statd drops all capabilities except for CAP_NET_BIND when it starts. It's possible though that if it ever had a compromise that an attacker would be able to invoke a setuid process (or something with file capabilities) in order to reinstate some caps.
In order to prevent that, have statd also prune the bounding set to nothing prior to dropping capabilities.
Cc Chuck Lever <[email protected]>
Signed-off-by Jeff Layton <[email protected]>
--- support/nsm/file.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
support/nsm/file.c +12 -0
@@ -342,8 +342,20 @@ static _Boolnsm_clear_capabilities (void) {#ifdef HAVE_SYS_CAPABILITY_H +int ret; +unsigned long i;cap_t caps; +/* prune the bounding set to nothing */ +for (i =0 ; i <=CAP_LAST_CAP ; ++i) { + ret =prctl (PR_CAPBSET_DROP , i); +if (ret) { +xlog (L_ERROR ,"Unable to prune capability %lu from " +"bounding set: %m" , i); +return false; + } + } + caps =cap_from_text ("cap_net_bind_service=ep" );if (caps ==NULL ) {xlog (L_ERROR ,"Failed to allocate capability: %m" );
Signature · 1 line
1.7.7.6