Permalink
Browse files

Fix possible race on dumpable flag (issue 105)

To ensure diod can always dump core, we added code to user.c to set
the dumpable flag after altering capabilities, fsuid, fsgid, or groups.
However, we only do this if the dumpable flag tested true before the
change.  This may be racy if another thread is executing the same code
and has cleared the dumpable flag before the test.
  • Loading branch information...
1 parent 2143163 commit 5d5a96190c4c787ec6a0dc8083c634965dd54848 @garlick garlick committed May 14, 2012
Showing with 1 addition and 2 deletions.
  1. +1 −2 libnpfs/user.c
View
3 libnpfs/user.c
@@ -578,7 +578,6 @@ np_setfsid (Npreq *req, Npuser *u, u32 gid_override)
int i, n, ret = -1;
u32 gid;
uid_t authuid;
- int dumpable = prctl (PR_GET_DUMPABLE, 0, 0, 0, 0);
int dumpclrd = 0;
if (np_conn_get_authuser(req->conn, &authuid) < 0)
@@ -681,7 +680,7 @@ np_setfsid (Npreq *req, Npuser *u, u32 gid_override)
#endif
ret = 0;
done:
- if (dumpable && dumpclrd && prctl (PR_SET_DUMPABLE, 1, 0, 0, 0) < 0)
+ if (dumpclrd && prctl (PR_SET_DUMPABLE, 1, 0, 0, 0) < 0)
np_logerr (srv, "prctl PR_SET_DUMPABLE failed");
return ret;
}

0 comments on commit 5d5a961

Please sign in to comment.