Commit b4c8c5ae authored by Pavel Emelyanov's avatar Pavel Emelyanov

security: Also save gid of user requesting for C/R

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 6bf63b3f
...@@ -87,7 +87,7 @@ static int setup_dump_from_req(int sk, CriuOpts *req) ...@@ -87,7 +87,7 @@ static int setup_dump_from_req(int sk, CriuOpts *req)
return -1; return -1;
} }
restrict_uid(ids.uid); restrict_uid(ids.uid, ids.gid);
if (fstat(sk, &st)) { if (fstat(sk, &st)) {
pr_perror("Can't get socket stat"); pr_perror("Can't get socket stat");
......
...@@ -72,7 +72,7 @@ int main(int argc, char *argv[]) ...@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
BUILD_BUG_ON(PAGE_SIZE != PAGE_IMAGE_SIZE); BUILD_BUG_ON(PAGE_SIZE != PAGE_IMAGE_SIZE);
cr_pb_init(); cr_pb_init();
restrict_uid(getuid()); restrict_uid(getuid(), getgid());
if (argc < 2) if (argc < 2)
goto usage; goto usage;
......
...@@ -208,7 +208,7 @@ static inline bool pid_rst_prio(unsigned pid_a, unsigned pid_b) ...@@ -208,7 +208,7 @@ static inline bool pid_rst_prio(unsigned pid_a, unsigned pid_b)
return pid_a < pid_b; return pid_a < pid_b;
} }
void restrict_uid(unsigned int uid); void restrict_uid(unsigned int uid, unsigned int gid);
struct proc_status_creds; struct proc_status_creds;
bool may_dump(struct proc_status_creds *); bool may_dump(struct proc_status_creds *);
struct _CredsEntry; struct _CredsEntry;
......
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
#include "proc_parse.h" #include "proc_parse.h"
#include "log.h" #include "log.h"
static unsigned int cr_uid; /* UID which user can C/R */ /*
* UID and GID of user requesting for C/R
*/
static unsigned int cr_uid, cr_gid;
/* /*
* Setup what user is requesting for dump (via rpc or using * Setup what user is requesting for dump (via rpc or using
...@@ -12,10 +15,11 @@ static unsigned int cr_uid; /* UID which user can C/R */ ...@@ -12,10 +15,11 @@ static unsigned int cr_uid; /* UID which user can C/R */
* access to. (Or implement some trickier security policy). * access to. (Or implement some trickier security policy).
*/ */
void restrict_uid(unsigned int uid) void restrict_uid(unsigned int uid, unsigned int gid)
{ {
pr_info("Restrict C/R with %u uid\n", uid); pr_info("Restrict C/R with %u:%u uid\n", uid, gid);
cr_uid = uid; cr_uid = uid;
cr_gid = gid;
} }
static bool check_uid(unsigned int uid) static bool check_uid(unsigned int uid)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment