Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 166621
b: refs/heads/master
c: c0648e0
h: refs/heads/master
i:
  166619: 40129a1
v: v3
  • Loading branch information
Ralf Baechle committed Sep 30, 2009
1 parent eaa4b87 commit 9c94548
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b7a05871aac3a75a48faebcde92d881f9625c066
refs/heads/master: c0648e02db689b03564882044f32bc6c6e70c229
33 changes: 23 additions & 10 deletions trunk/arch/mips/kernel/kspd.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,20 @@ static unsigned int translate_open_flags(int flags)
}


static void sp_setfsuidgid( uid_t uid, gid_t gid)
static int sp_setfsuidgid(uid_t uid, gid_t gid)
{
current->cred->fsuid = uid;
current->cred->fsgid = gid;
struct cred *new;

key_fsuid_changed(current);
key_fsgid_changed(current);
new = prepare_creds();
if (!new)
return -ENOMEM;

new->fsuid = uid;
new->fsgid = gid;

commit_creds(new);

return 0;
}

/*
Expand All @@ -196,7 +203,7 @@ void sp_work_handle_request(void)
mm_segment_t old_fs;
struct timeval tv;
struct timezone tz;
int cmd;
int err, cmd;

char *vcwd;
int size;
Expand Down Expand Up @@ -225,8 +232,11 @@ void sp_work_handle_request(void)
/* Run the syscall at the privilege of the user who loaded the
SP program */

if (vpe_getuid(tclimit))
sp_setfsuidgid(vpe_getuid(tclimit), vpe_getgid(tclimit));
if (vpe_getuid(tclimit)) {
err = sp_setfsuidgid(vpe_getuid(tclimit), vpe_getgid(tclimit));
if (!err)
pr_err("Change of creds failed\n");
}

switch (sc.cmd) {
/* needs the flags argument translating from SDE kit to
Expand Down Expand Up @@ -283,8 +293,11 @@ void sp_work_handle_request(void)
break;
} /* switch */

if (vpe_getuid(tclimit))
sp_setfsuidgid( 0, 0);
if (vpe_getuid(tclimit)) {
err = sp_setfsuidgid(0, 0);
if (!err)
pr_err("restoring old creds failed\n");
}

old_fs = get_fs();
set_fs(KERNEL_DS);
Expand Down

0 comments on commit 9c94548

Please sign in to comment.