Skip to content

Commit 55b22a6

Browse files
committed
virtiofsd: Check capability calls
Check the capability calls worked. Signed-off-by: Dr. David Alan Gilbert <[email protected]> Reviewed-by: Stefan Hajnoczi <[email protected]> Acked-by: Vivek Goyal <[email protected]> Message-Id: <[email protected]> Signed-off-by: Dr. David Alan Gilbert <[email protected]>
1 parent b1288df commit 55b22a6

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

tools/virtiofsd/passthrough_ll.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2589,7 +2589,7 @@ static void setup_capabilities(void)
25892589
*/
25902590
capng_setpid(syscall(SYS_gettid));
25912591
capng_clear(CAPNG_SELECT_BOTH);
2592-
capng_updatev(CAPNG_ADD, CAPNG_PERMITTED | CAPNG_EFFECTIVE,
2592+
if (capng_updatev(CAPNG_ADD, CAPNG_PERMITTED | CAPNG_EFFECTIVE,
25932593
CAP_CHOWN,
25942594
CAP_DAC_OVERRIDE,
25952595
CAP_DAC_READ_SEARCH,
@@ -2599,11 +2599,21 @@ static void setup_capabilities(void)
25992599
CAP_SETUID,
26002600
CAP_MKNOD,
26012601
CAP_SETFCAP,
2602-
-1);
2602+
-1)) {
2603+
fuse_log(FUSE_LOG_ERR, "%s: capng_updatev failed\n", __func__);
2604+
exit(1);
2605+
}
26032606

2604-
capng_apply(CAPNG_SELECT_BOTH);
2607+
if (capng_apply(CAPNG_SELECT_BOTH)) {
2608+
fuse_log(FUSE_LOG_ERR, "%s: capng_apply failed\n", __func__);
2609+
exit(1);
2610+
}
26052611

26062612
cap.saved = capng_save_state();
2613+
if (!cap.saved) {
2614+
fuse_log(FUSE_LOG_ERR, "%s: capng_save_state failed\n", __func__);
2615+
exit(1);
2616+
}
26072617
pthread_mutex_unlock(&cap.mutex);
26082618
}
26092619

0 commit comments

Comments
 (0)