Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

exec: delay address limit change until point of no return

Unconditionally changing the address limit to USER_DS and not restoring
it to its old value in the error path is wrong because it prevents us
using kernel memory on repeated calls to this function. This, in fact,
breaks the fallback of hard coded paths to the init program from being
ever successful if the first candidate fails to load.

With this patch applied switching to USER_DS is delayed until the point
of no return is reached which makes it possible to have a multi-arch
rootfs with one arch specific init binary for each of the (hard coded)
probed paths.

Since the address limit is already set to USER_DS when start_thread()
will be invoked, this redundancy can be safely removed.

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Mathias Krause and committed by
Linus Torvalds
dac853ae 06e86849

+1 -6
-1
arch/x86/kernel/process_32.c
··· 245 245 { 246 246 set_user_gs(regs, 0); 247 247 regs->fs = 0; 248 - set_fs(USER_DS); 249 248 regs->ds = __USER_DS; 250 249 regs->es = __USER_DS; 251 250 regs->ss = __USER_DS;
-1
arch/x86/kernel/process_64.c
··· 338 338 regs->cs = _cs; 339 339 regs->ss = _ss; 340 340 regs->flags = X86_EFLAGS_IF; 341 - set_fs(USER_DS); 342 341 /* 343 342 * Free the old FP and other extended state 344 343 */
+1 -4
fs/exec.c
··· 1093 1093 1094 1094 bprm->mm = NULL; /* We're using it now */ 1095 1095 1096 + set_fs(USER_DS); 1096 1097 current->flags &= ~(PF_RANDOMIZE | PF_KTHREAD); 1097 1098 flush_thread(); 1098 1099 current->personality &= ~bprm->per_clear; ··· 1357 1356 retval = security_bprm_check(bprm); 1358 1357 if (retval) 1359 1358 return retval; 1360 - 1361 - /* kernel module loader fixup */ 1362 - /* so we don't try to load run modprobe in kernel space. */ 1363 - set_fs(USER_DS); 1364 1359 1365 1360 retval = audit_bprm(bprm); 1366 1361 if (retval)