Skip to content

Commit 7dd257d

Browse files
committed
Merge tag 'execve-v6.1-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull execve fixes from Kees Cook: - Fix an ancient signal action copy race (Bernd Edlinger) - Fix a memory leak in ELF loader, when under memory pressure (Li Zetao) * tag 'execve-v6.1-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: fs/binfmt_elf: Fix memory leak in load_elf_binary() exec: Copy oldsighand->action under spin-lock
2 parents 2eb72d8 + 594d2a1 commit 7dd257d

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

fs/binfmt_elf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
911911
interp_elf_ex = kmalloc(sizeof(*interp_elf_ex), GFP_KERNEL);
912912
if (!interp_elf_ex) {
913913
retval = -ENOMEM;
914-
goto out_free_ph;
914+
goto out_free_file;
915915
}
916916

917917
/* Get the exec headers */
@@ -1354,6 +1354,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
13541354
out_free_dentry:
13551355
kfree(interp_elf_ex);
13561356
kfree(interp_elf_phdata);
1357+
out_free_file:
13571358
allow_write_access(interpreter);
13581359
if (interpreter)
13591360
fput(interpreter);

fs/exec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,11 +1197,11 @@ static int unshare_sighand(struct task_struct *me)
11971197
return -ENOMEM;
11981198

11991199
refcount_set(&newsighand->count, 1);
1200-
memcpy(newsighand->action, oldsighand->action,
1201-
sizeof(newsighand->action));
12021200

12031201
write_lock_irq(&tasklist_lock);
12041202
spin_lock(&oldsighand->siglock);
1203+
memcpy(newsighand->action, oldsighand->action,
1204+
sizeof(newsighand->action));
12051205
rcu_assign_pointer(me->sighand, newsighand);
12061206
spin_unlock(&oldsighand->siglock);
12071207
write_unlock_irq(&tasklist_lock);

0 commit comments

Comments
 (0)