aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel/kspd.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/kernel/kspd.c')
-rw-r--r--arch/mips/kernel/kspd.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/arch/mips/kernel/kspd.c b/arch/mips/kernel/kspd.c
index f2397f00db43..ad4e017ed2f3 100644
--- a/arch/mips/kernel/kspd.c
+++ b/arch/mips/kernel/kspd.c
@@ -172,13 +172,20 @@ static unsigned int translate_open_flags(int flags)
172} 172}
173 173
174 174
175static void sp_setfsuidgid( uid_t uid, gid_t gid) 175static int sp_setfsuidgid(uid_t uid, gid_t gid)
176{ 176{
177 current->cred->fsuid = uid; 177 struct cred *new;
178 current->cred->fsgid = gid;
179 178
180 key_fsuid_changed(current); 179 new = prepare_creds();
181 key_fsgid_changed(current); 180 if (!new)
181 return -ENOMEM;
182
183 new->fsuid = uid;
184 new->fsgid = gid;
185
186 commit_creds(new);
187
188 return 0;
182} 189}
183 190
184/* 191/*
@@ -196,7 +203,7 @@ void sp_work_handle_request(void)
196 mm_segment_t old_fs; 203 mm_segment_t old_fs;
197 struct timeval tv; 204 struct timeval tv;
198 struct timezone tz; 205 struct timezone tz;
199 int cmd; 206 int err, cmd;
200 207
201 char *vcwd; 208 char *vcwd;
202 int size; 209 int size;
@@ -225,8 +232,11 @@ void sp_work_handle_request(void)
225 /* Run the syscall at the privilege of the user who loaded the 232 /* Run the syscall at the privilege of the user who loaded the
226 SP program */ 233 SP program */
227 234
228 if (vpe_getuid(tclimit)) 235 if (vpe_getuid(tclimit)) {
229 sp_setfsuidgid(vpe_getuid(tclimit), vpe_getgid(tclimit)); 236 err = sp_setfsuidgid(vpe_getuid(tclimit), vpe_getgid(tclimit));
237 if (!err)
238 pr_err("Change of creds failed\n");
239 }
230 240
231 switch (sc.cmd) { 241 switch (sc.cmd) {
232 /* needs the flags argument translating from SDE kit to 242 /* needs the flags argument translating from SDE kit to
@@ -283,8 +293,11 @@ void sp_work_handle_request(void)
283 break; 293 break;
284 } /* switch */ 294 } /* switch */
285 295
286 if (vpe_getuid(tclimit)) 296 if (vpe_getuid(tclimit)) {
287 sp_setfsuidgid( 0, 0); 297 err = sp_setfsuidgid(0, 0);
298 if (!err)
299 pr_err("restoring old creds failed\n");
300 }
288 301
289 old_fs = get_fs(); 302 old_fs = get_fs();
290 set_fs(KERNEL_DS); 303 set_fs(KERNEL_DS);