[PATCH 04/11] exec: Move uid/gid handling from creds_from_file into bprm_fill_uid

2020-05-28 Thread Eric W. Biederman
of the bugs I have tried to make more apparent but left in tact when moving the code into bprm_fill_uid. Ref: ee67ae7ef6ff ("commoncap: Move cap_elevated calculation into bprm_set_creds") Fixes: 58319057b784 ("capabilities: ambient capabilities") Signed-off-by: "Eric W. B

[PATCH 03/11] exec: Compute file based creds only once

2020-05-28 Thread Eric W. Biederman
ties, and add a small comment about what cap_bprm_creds_from_file does. Signed-off-by: "Eric W. Biederman" --- fs/binfmt_misc.c | 2 +- fs/exec.c | 65 +-- include/linux/binfmts.h | 12 ++- include/linux/lsm_hoo

[PATCH 02/11] exec: Introduce active_per_clear the per file version of per_clear

2020-05-28 Thread Eric W. Biederman
ATCH] NX: clean up legacy binary support") Signed-off-by: "Eric W. Biederman" --- fs/exec.c | 7 --- include/linux/binfmts.h | 3 +++ include/linux/lsm_hooks.h | 2 +- security/commoncap.c | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git

[PATCH 01/11] exec: Reduce bprm->per_clear to a single bit

2020-05-28 Thread Eric W. Biederman
The bprm->per_clear field only takes the values 0 and PER_CLEAR_ON_SETID. Reduce the field to a signle bit to make it clear that the only question is should the dangerous personality bits be cleared or not. Update the documentation of the security lsm hooks. Signed-off-by: "Eric W. B

[PATCH 0/11] exec: cred calculation simplifications

2020-05-28 Thread Eric W. Biederman
be changed when ptraced, instead of attempting to rollback the credential change. Folks please give this code a review and let me know if you see anything. Eric W. Biederman (11): exec: Reduce bprm->per_clear to a single bit exec: Introduce active_per_clear the per file versio

Re: [PATCH] binfmt_elf_fdpic: fix execfd build regression

2020-05-27 Thread Eric W. Biederman
Arnd Bergmann writes: > The change to bprm->have_execfd was incomplete, leading > to a build failure: > > fs/binfmt_elf_fdpic.c: In function 'create_elf_fdpic_tables': > fs/binfmt_elf_fdpic.c:591:27: error: 'BINPRM_FLAGS_EXECFD' undeclared > > Change the last user of BINPRM_FLAGS_EXECFD in a corr

Re: [PATCH] proc/base: Skip assignment to len when there is no error on d_path in do_proc_readlink.

2020-05-27 Thread Eric W. Biederman
Alexey Dobriyan writes: > On Wed, May 27, 2020 at 09:41:53AM -0500, Eric W. Biederman wrote: >> Kaitao Cheng writes: >> >> > we don't need {len = PTR_ERR(pathname)} when IS_ERR(pathname) is false, >> > it's better to move it into if(IS_ERR(pathname)){

Re: [PATCH] proc/base: Skip assignment to len when there is no error on d_path in do_proc_readlink.

2020-05-27 Thread Eric W. Biederman
Kaitao Cheng writes: > we don't need {len = PTR_ERR(pathname)} when IS_ERR(pathname) is false, > it's better to move it into if(IS_ERR(pathname)){}. Please look at the generated code. I believe you will find that your change will generate worse assembly. Eric > Signed-off-by: Kaitao Cheng >

Re: [GIT PULL] Please pull exec fix for v5.7

2020-05-26 Thread Eric W. Biederman
Linus Torvalds writes: > On Tue, May 26, 2020 at 11:42 AM Eric W. Biederman > wrote: >> >> While working on my exec cleanups I found a bug in exec that winds >> up miscomputing the ambient credentials during exec. Andy appears >> as to credentials are comput

[GIT PULL] Please pull exec fix for v5.7

2020-05-26 Thread Eric W. Biederman
Which is fixed with this trivial change. Eric From: "Eric W. Biederman" Date: Mon, 25 May 2020 12:56:15 -0500 Subject: [PATCH] exec: Always set cap_ambient in cap_bprm_set_creds An invariant of cap_bprm_set_creds is that every field in the new cred structure that cap_bprm_set_creds m

Re: [PATCH] capabilities: Introduce CAP_RESTORE

2020-05-26 Thread Eric W. Biederman
Adrian Reber writes: > On Fri, May 22, 2020 at 09:40:37AM -0700, Casey Schaufler wrote: >> What are the other blockers? Are you going to suggest additional new >> capabilities to clear them? > > As mentioned somewhere else access to /proc//map_files/ would be > helpful. Right now I am testing wi

Re: [PATCH v2 7/8] exec: Generic execfd support

2020-05-22 Thread Eric W. Biederman
Rob Landley writes: > On 5/21/20 10:28 PM, Eric W. Biederman wrote: >> >> Rob Landley writes: >> >>> On 5/20/20 11:05 AM, Eric W. Biederman wrote: >> >>>> The file descriptor is stored in mm->exe_file. >>>> Probably the

Re: [PATCH v2 7/8] exec: Generic execfd support

2020-05-21 Thread Eric W. Biederman
Rob Landley writes: > On 5/20/20 11:05 AM, Eric W. Biederman wrote: > Toybox would _like_ proc mounted, but can't assume it. I'm writing a new > bash-compatible shell with nommu support, which means in order to do subshell > and background tasks if (!CONFIG_FORK) I need

Re: [PATCH v2 0/8] exec: Control flow simplifications

2020-05-21 Thread Eric W. Biederman
Kees Cook writes: > On Wed, May 20, 2020 at 05:12:10PM -0500, Eric W. Biederman wrote: >> >> I have pushed this out to: >> >> git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git >> exec-next >> >> I have collected up the

Re: [PATCH v2 0/8] exec: Control flow simplifications

2020-05-20 Thread Eric W. Biederman
Acked-by: Linus Torvalds +Reviewed-by: Kees Cook Signed-off-by: "Eric W. Biederman" ## kernel/cred.c ## 2: d3b3594be22f ! 2: b8bff599261c exec: Factor security_bprm_creds_for_exec out of security_bprm_set_creds @@ Commit message A

Re: [PATCH] selftests/exec: Add binfmt_script regression test

2020-05-20 Thread Eric W. Biederman
Kees Cook writes: > While working on commit b5372fe5dc84 ("exec: load_script: Do not exec > truncated interpreter path"), I wrote a series of test scripts to verify > corner cases. However, soon after, commit 6eb3c3d0a52d ("exec: increase > BINPRM_BUF_SIZE to 256") landed, resulting in the tests

Re: [PATCH v2 3/8] exec: Convert security_bprm_set_creds into security_bprm_repopulate_creds

2020-05-20 Thread Eric W. Biederman
Kees Cook writes: > On Tue, May 19, 2020 at 02:03:23PM -0500, Eric W. Biederman wrote: >> Kees Cook writes: >> >> > On Mon, May 18, 2020 at 07:31:14PM -0500, Eric W. Biederman wrote: >> >> [...] >> >> diff --git a/include/linux/binfmts.h b/

Re: [PATCH v2 7/8] exec: Generic execfd support

2020-05-20 Thread Eric W. Biederman
Rob Landley writes: > On 5/18/20 7:33 PM, Eric W. Biederman wrote: >> >> Most of the support for passing the file descriptor of an executable >> to an interpreter already lives in the generic code and in binfmt_elf. >> Rework the fields in binfmt_elf that deal with ex

Re: [PATCH v2 0/8] exec: Control flow simplifications

2020-05-20 Thread Eric W. Biederman
Kees Cook writes: > On Mon, May 18, 2020 at 07:29:00PM -0500, Eric W. Biederman wrote: >> arch/alpha/kernel/binfmt_loader.c | 11 + >> fs/binfmt_elf.c| 4 +- >> fs/binfmt_elf_fdpic.c | 4 +- >> fs/binfmt_em86.c

Re: [PATCH v2 3/8] exec: Convert security_bprm_set_creds into security_bprm_repopulate_creds

2020-05-20 Thread Eric W. Biederman
James Morris writes: > On Mon, 18 May 2020, Eric W. Biederman wrote: > >> diff --git a/fs/exec.c b/fs/exec.c >> index 9e70da47f8d9..8e3b93d51d31 100644 >> --- a/fs/exec.c >> +++ b/fs/exec.c >> @@ -1366,7 +1366,7 @@ int begin_new_exec(struct linux_binprm *

Re: [PATCH v2 7/8] exec: Generic execfd support

2020-05-19 Thread Eric W. Biederman
Linus Torvalds writes: > On Tue, May 19, 2020 at 12:46 PM Kees Cook wrote: >> >> Though frankly, I wonder if interp_flags could just be removed in favor >> of two new bit members, especially since interp_data is gone: > > Yeah, I think that might be a good cleanup - but please keep it as a > sep

Re: [PATCH v2 6/8] exec/binfmt_script: Don't modify bprm->buf and then return -ENOEXEC

2020-05-19 Thread Eric W. Biederman
Kees Cook writes: > On Mon, May 18, 2020 at 07:33:21PM -0500, Eric W. Biederman wrote: >> >> When replacing loops with next_non_spacetab and next_terminator care >> has been take that the logic of the parsing code (short of replacing >> characters by '\0')

Re: [PATCH v2 4/8] exec: Allow load_misc_binary to call prepare_binfmt unconditionally

2020-05-19 Thread Eric W. Biederman
Kees Cook writes: > On Mon, May 18, 2020 at 07:31:51PM -0500, Eric W. Biederman wrote: >> >> Add a flag preserve_creds that binfmt_misc can set to prevent >> credentials from being updated. This allows binfmt_misc to always >> call prepare_binfmt. Allowing the cred

Re: [PATCH v2 3/8] exec: Convert security_bprm_set_creds into security_bprm_repopulate_creds

2020-05-19 Thread Eric W. Biederman
Kees Cook writes: > On Mon, May 18, 2020 at 07:31:14PM -0500, Eric W. Biederman wrote: >> >> Rename bprm->cap_elevated to bprm->active_secureexec and initialize it >> in prepare_binprm instead of in cap_bprm_set_creds. Initializing >> bprm->active_secureex

Re: [PATCH v2 1/8] exec: Teach prepare_exec_creds how exec treats uids & gids

2020-05-19 Thread Eric W. Biederman
Linus Torvalds writes: > On Tue, May 19, 2020 at 11:03 AM Kees Cook wrote: >> >> One question, though: why add this, since the repeat calling of the caps >> LSM hook will do this? > > I assume it's for the "preserve_creds" case where we don't even end up > setting creds at all. > > Yeah, at some

Re: [PATCH 0/4] Relocate execve() sanity checks

2020-05-19 Thread Eric W. Biederman
Kees Cook writes: > On Tue, May 19, 2020 at 12:41:27PM -0500, Eric W. Biederman wrote: >> Kees Cook writes: >> > and given the LSM hooks, I think the noexec check is too late as well. >> > (This is especially true for the coming O_MAYEXEC series, which will >&

Re: [PATCH 0/4] Relocate execve() sanity checks

2020-05-19 Thread Eric W. Biederman
Kees Cook writes: > On Tue, May 19, 2020 at 10:06:32AM -0500, Eric W. Biederman wrote: >> Kees Cook writes: >> >> > Hi, >> > >> > While looking at the code paths for the proposed O_MAYEXEC flag, I saw >> > some things that looked like they sh

Re: [PATCH 0/4] Relocate execve() sanity checks

2020-05-19 Thread Eric W. Biederman
Kees Cook writes: > Hi, > > While looking at the code paths for the proposed O_MAYEXEC flag, I saw > some things that looked like they should be fixed up. > > exec: Change uselib(2) IS_SREG() failure to EACCES > This just regularizes the return code on uselib(2). > > exec: Relocate S_IS

Re: [PATCH 1/4] exec: Change uselib(2) IS_SREG() failure to EACCES

2020-05-19 Thread Eric W. Biederman
Christian Brauner writes: > On Tue, May 19, 2020 at 07:28:46AM -0500, Eric W. Biederman wrote: >> Andreas Schwab writes: >> >> > On Mai 19 2020, Eric W. Biederman wrote: >> > >> >> I am wondering if there are source trees for libc4 or libc5 around

Re: [PATCH 1/4] exec: Change uselib(2) IS_SREG() failure to EACCES

2020-05-19 Thread Eric W. Biederman
Andreas Schwab writes: > On Mai 19 2020, Eric W. Biederman wrote: > >> I am wondering if there are source trees for libc4 or libc5 around >> anywhere that we can look at to see how usage of uselib evolved. > > libc5 is available from archive.debian.org. > > ht

Re: [PATCH 1/4] exec: Change uselib(2) IS_SREG() failure to EACCES

2020-05-19 Thread Eric W. Biederman
Andreas Schwab writes: > On Mai 18 2020, Eric W. Biederman wrote: > >> If it was only libc4 and libc5 that used the uselib system call then it >> can probably be removed after enough time. > > Only libc4 used it, libc5 was already ELF. binfmt_elf.c supports uselib. In a

[PATCH v2 8/8] exec: Remove recursion from search_binary_handler

2020-05-18 Thread Eric W. Biederman
to see if bprm->executable is being reassigned. In search_binary_handler remove the test for !bprm->file. With all reassignments of bprm->file moved to exec_binprm bprm->file can never be NULL in search_binary_handler. Signed-off-by: "Eric W. Biederman" --- arch/

[PATCH v2 7/8] exec: Generic execfd support

2020-05-18 Thread Eric W. Biederman
his case exists and that no nesting of bprm->file is currently supported. In binfmt_misc the movement of fd_install into generic code means that it's special error exit path is no longer needed. Signed-off-by: "Eric W. Biederman" --- fs/binfmt_elf.c | 4 ++-- fs

[PATCH v2 6/8] exec/binfmt_script: Don't modify bprm->buf and then return -ENOEXEC

2020-05-18 Thread Eric W. Biederman
take that the logic of the parsing code (short of replacing characters by '\0') remains the same. Signed-off-by: "Eric W. Biederman" --- fs/binfmt_script.c | 80 ++ 1 file changed, 38 insertions(+), 42 deletions(-) diff --git a/fs/b

[PATCH v2 4/8] exec: Allow load_misc_binary to call prepare_binfmt unconditionally

2020-05-18 Thread Eric W. Biederman
) Signed-off-by: "Eric W. Biederman" --- fs/binfmt_misc.c| 15 +++ fs/exec.c | 19 --- include/linux/binfmts.h | 2 ++ 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index cdb45829

[PATCH v2 5/8] exec: Move the call of prepare_binprm into search_binary_handler

2020-05-18 Thread Eric W. Biederman
The code in prepare_binary_handler needs to be run every time search_binary_handler is called so move the call into search_binary_handler itself to make the code simpler and easier to understand. Signed-off-by: "Eric W. Biederman" --- arch/alpha/kernel/binfmt_loader.c | 3 --- fs/b

[PATCH v2 3/8] exec: Convert security_bprm_set_creds into security_bprm_repopulate_creds

2020-05-18 Thread Eric W. Biederman
alizing bprm->active_secureexec. Signed-off-by: "Eric W. Biederman" --- fs/exec.c | 8 include/linux/binfmts.h | 4 ++-- include/linux/lsm_hook_defs.h | 2 +- include/linux/lsm_hooks.h | 4 ++-- include/linux/security.h | 8 security

[PATCH v2 1/8] exec: Teach prepare_exec_creds how exec treats uids & gids

2020-05-18 Thread Eric W. Biederman
nge of domains. Signed-off-by: "Eric W. Biederman" --- kernel/cred.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/cred.c b/kernel/cred.c index 71a792616917..421b1149c651 100644 --- a/kernel/cred.c +++ b/kernel/cred.c @@ -315,6 +315,9 @@ struct cred *prepare_ex

[PATCH v2 2/8] exec: Factor security_bprm_creds_for_exec out of security_bprm_set_creds

2020-05-18 Thread Eric W. Biederman
o reflect this change. Signed-off-by: "Eric W. Biederman" --- fs/exec.c | 6 +++- include/linux/binfmts.h| 18 +++ include/linux/lsm_hook_defs.h | 1 + include/linux/lsm_hooks.h | 50 +-

[PATCH v2 0/8] exec: Control flow simplifications

2020-05-18 Thread Eric W. Biederman
that the search_binary_handler loop could not continue. So I added a change to remove that naughtiness. Eric W. Biederman (8): exec: Teach prepare_exec_creds how exec treats uids & gids exec: Factor security_bprm_creds_for_exec out of security_bprm_set_creds e

Re: [PATCH 1/4] exec: Change uselib(2) IS_SREG() failure to EACCES

2020-05-18 Thread Eric W. Biederman
Christian Brauner writes: > On Mon, May 18, 2020 at 04:43:20PM +0200, Jann Horn wrote: >> On Mon, May 18, 2020 at 3:03 PM Christian Brauner >> wrote: >> > Also - gulp (puts on flame proof suit) - may I suggest we check if there >> > are any distros out there that still set CONFIG_USELIB=y >> >>

Re: [PATCH] seccomp: Add group_leader pid to seccomp_notif

2020-05-18 Thread Eric W. Biederman
Sargun Dhillon writes: > This includes the thread group leader ID in the seccomp_notif. This is > immediately useful for opening up a pidfd for the group leader, as > pidfds only work on group leaders. The code looks fine (except for the name of the test), but can you please talk and think about

Re: [PATCH v2] proc: proc_pid_ns takes super_block as an argument

2020-05-18 Thread Eric W. Biederman
Alexey Gladkov writes: > On Mon, May 18, 2020 at 07:08:57AM -0500, Eric W. Biederman wrote: >> Alexey Gladkov writes: >> >> > The proc_pid_ns() can be used for both inode and dentry. To avoid making >> > two identical functions, change the argument type of

Re: [PATCH v2] proc: proc_pid_ns takes super_block as an argument

2020-05-18 Thread Eric W. Biederman
Alexey Gladkov writes: > The proc_pid_ns() can be used for both inode and dentry. To avoid making > two identical functions, change the argument type of the proc_pid_ns(). > > Link: > https://lore.kernel.org/lkml/c3461e26-1407-2262-c709-dac0df3da...@i-love.sakura.ne.jp/ > Reported-by: syzbot+c1a

[GIT PULL] Please pull exec fix for v5.7

2020-05-17 Thread Eric W. Biederman
l bprm->file. I have been careful and tested and verify this fix works. Eric --- >From f87d1c9559164294040e58f5e3b74a162bf7c6e8 Mon Sep 17 00:00:00 2001 From: "Eric W. Biederman" Date: Sat, 16 May 2020 16:29:20 -0500 Subject: [PATCH] exec: Move would_dump into flush_old_exec I

Re: linux-next boot error: general protection fault in tomoyo_get_local_path

2020-05-15 Thread Eric W. Biederman
Al Viro writes: > On Sat, May 16, 2020 at 12:36:28AM +0900, Tetsuo Handa wrote: >> On 2020/05/16 0:18, Tetsuo Handa wrote: >> > This is >> > >> > if (sb->s_magic == PROC_SUPER_MAGIC && *pos == '/') { >> > char *ep; >> > const pid_t pid = (pid_t) simple_str

Re: linux-next boot error: general protection fault in tomoyo_get_local_path

2020-05-15 Thread Eric W. Biederman
Tetsuo Handa writes: > This is > > if (sb->s_magic == PROC_SUPER_MAGIC && *pos == '/') { > char *ep; > const pid_t pid = (pid_t) simple_strtoul(pos + 1, &ep, 10); > struct pid_namespace *proc_pidns = > proc_pid_ns(d_inode(dentry)); // <= he

Re: [PATCH 3/5] exec: Remove recursion from search_binary_handler

2020-05-14 Thread Eric W. Biederman
Casey Schaufler writes: > On 5/14/2020 7:56 AM, Eric W. Biederman wrote: >> Kees Cook writes: >> >>> On Tue, May 12, 2020 at 04:47:14PM -0700, Kees Cook wrote: >>>> And now I wonder if qemu actually uses the resulting AT_EXECFD ... >>> It does, thoug

Re: [PATCH 3/5] exec: Remove recursion from search_binary_handler

2020-05-14 Thread Eric W. Biederman
Linus Torvalds writes: > On Tue, May 12, 2020 at 11:46 AM Eric W. Biederman > wrote: >> >> I am still thinking about this one, but here is where I am at. At a >> practical level passing the file descriptor of the script to interpreter >> seems like something w

Re: [PATCH 3/5] exec: Remove recursion from search_binary_handler

2020-05-14 Thread Eric W. Biederman
Kees Cook writes: > On Tue, May 12, 2020 at 04:47:14PM -0700, Kees Cook wrote: >> And now I wonder if qemu actually uses the resulting AT_EXECFD ... > > It does, though I'm not sure if this is to support crossing mount points, > dropping privileges, or something else, since it does fall back to j

Re: [PATCH 3/5] exec: Remove recursion from search_binary_handler

2020-05-13 Thread Eric W. Biederman
Rob Landley writes: > On 5/11/20 9:33 AM, Eric W. Biederman wrote: >> What I do see is that interp_data is just a parameter that is smuggled >> into the call of search binary handler. And the next binary handler >> needs to be binfmt_elf for it to make much sense, as on

Re: [PATCH 2/3] security: add symbol namespace for reading file data

2020-05-13 Thread Eric W. Biederman
Luis Chamberlain writes: > Certain symbols are not meant to be used by everybody, the security > helpers for reading files directly is one such case. Use a symbol > namespace for them. > > This will prevent abuse of use of these symbols in places they were > not inteded to be used, and provides a

Re: linux-next: manual merge of the vfs tree with the parisc-hd tree

2020-05-13 Thread Eric W. Biederman
Luis Chamberlain writes: > On Wed, May 13, 2020 at 08:42:30AM -0500, Eric W. Biederman wrote: >> Luis Chamberlain writes: >> >> > On Tue, May 12, 2020 at 12:40:55PM -0500, Eric W. Biederman wrote: >> >> Luis Chamberlain writes: >> >> >>

Re: linux-next: manual merge of the vfs tree with the parisc-hd tree

2020-05-13 Thread Eric W. Biederman
Luis Chamberlain writes: > On Tue, May 12, 2020 at 12:40:55PM -0500, Eric W. Biederman wrote: >> Luis Chamberlain writes: >> >> > On Tue, May 12, 2020 at 06:52:35AM -0500, Eric W. Biederman wrote: >> >> Luis Chamberlain writes: >> >>

Re: [PATCH 3/5] exec: Remove recursion from search_binary_handler

2020-05-12 Thread Eric W. Biederman
Kees Cook writes: > On Tue, May 12, 2020 at 01:42:53PM -0500, Eric W. Biederman wrote: >> Kees Cook writes: >> > Should binfmt_misc do the install, or can the consuming binfmt do it? >> > i.e. when binfmt_elf sees bprm->execfd, does it perform the install &

Re: [PATCH 3/5] exec: Remove recursion from search_binary_handler

2020-05-12 Thread Eric W. Biederman
Kees Cook writes: > On Mon, May 11, 2020 at 09:33:21AM -0500, Eric W. Biederman wrote: >> Linus Torvalds writes: >> >> > On Sat, May 9, 2020 at 9:30 PM Tetsuo Handa >> > wrote: >> >> >> >> Wouldn't this change cause >>

Re: linux-next: manual merge of the vfs tree with the parisc-hd tree

2020-05-12 Thread Eric W. Biederman
Luis Chamberlain writes: > On Tue, May 12, 2020 at 06:52:35AM -0500, Eric W. Biederman wrote: >> Luis Chamberlain writes: >> >> > +static struct ctl_table fs_base_table[] = { >> > + { >> > + .procname = "fs", >> &

Re: linux-next: manual merge of the vfs tree with the parisc-hd tree

2020-05-12 Thread Eric W. Biederman
Luis Chamberlain writes: > On Mon, May 11, 2020 at 09:55:16AM +0800, Xiaoming Ni wrote: >> On 2020/5/11 9:11, Stephen Rothwell wrote: >> > Hi all, >> > >> > Today's linux-next merge of the vfs tree got a conflict in: >> > >> >kernel/sysctl.c >> > >> > between commit: >> > >> >b6522fa4

Re: [PATCH 2/5] exec: Directly call security_bprm_set_creds from __do_execve_file

2020-05-11 Thread Eric W. Biederman
Kees Cook writes: > On Sat, May 09, 2020 at 02:41:17PM -0500, Eric W. Biederman wrote: >> >> Now that security_bprm_set_creds is no longer responsible for calling >> cap_bprm_set_creds, security_bprm_set_creds only does something for >> the primary file that

Re: [PATCH 3/5] exec: Remove recursion from search_binary_handler

2020-05-11 Thread Eric W. Biederman
Linus Torvalds writes: > On Sat, May 9, 2020 at 9:30 PM Tetsuo Handa > wrote: >> >> Wouldn't this change cause >> >> if (fd_binary > 0) >> ksys_close(fd_binary); >> bprm->interp_flags = 0; >> bprm->interp_data = 0; >> >> not to be called when "Search for t

Re: [PATCH 2/5] exec: Directly call security_bprm_set_creds from __do_execve_file

2020-05-09 Thread Eric W. Biederman
Linus Torvalds writes: > On Sat, May 9, 2020 at 12:44 PM Eric W. Biederman > wrote: >> >> Now that security_bprm_set_creds is no longer responsible for calling >> cap_bprm_set_creds, security_bprm_set_creds only does something for >> the primary file t

Re: [PATCH 3/6] exec: Stop open coding mutex_lock_killable of cred_guard_mutex

2020-05-09 Thread Eric W. Biederman
Linus Torvalds writes: > On Fri, May 8, 2020 at 11:48 AM Eric W. Biederman > wrote: >> >> >> Oleg modified the code that did >> "mutex_lock_interruptible(¤t->cred_guard_mutex)" to return >> -ERESTARTNOINTR instead of -EINTR, so that usersp

[PATCH 5/5] exec: Move the call of prepare_binprm into search_binary_handler

2020-05-09 Thread Eric W. Biederman
The code in prepare_binary_handler needs to be run every time search_binary_handler is called so move the call into search_binary_handler itself to make the code simpler and easier to understand. Signed-off-by: "Eric W. Biederman" --- arch/alpha/kernel/binfmt_loader.c | 3 --- fs/b

[PATCH 4/5] exec: Allow load_misc_binary to call prepare_binfmt unconditionally

2020-05-09 Thread Eric W. Biederman
ter's credentials") Signed-off-by: "Eric W. Biederman" --- fs/binfmt_misc.c| 15 +++ fs/exec.c | 14 +- include/linux/binfmts.h | 2 ++ 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/fs/binfmt_misc.c b/fs/binfmt_

[PATCH 3/5] exec: Remove recursion from search_binary_handler

2020-05-09 Thread Eric W. Biederman
-off-by: "Eric W. Biederman" --- arch/alpha/kernel/binfmt_loader.c | 2 +- fs/binfmt_em86.c | 2 +- fs/binfmt_misc.c | 5 + fs/binfmt_script.c| 2 +- fs/exec.c | 20 +--- include/linux

[PATCH 2/5] exec: Directly call security_bprm_set_creds from __do_execve_file

2020-05-09 Thread Eric W. Biederman
prepare_binprm so that it is only called once, and remove the now unnecessary called_set_creds field of struct binprm. Signed-off-by: "Eric W. Biederman" --- fs/exec.c | 11 +-- include/linux/binfmts.h| 6 -- security/apparmor/domain.c | 3 --- securi

[PATCH 1/5] exec: Call cap_bprm_set_creds directly from prepare_binprm

2020-05-09 Thread Eric W. Biederman
script. The function cap_bprm_set_creds is also special in that it is called even when CONFIG_SECURITY is unset. So calling cap_bprm_set_creds separately to make these two cases explicit, and allow future changes to take advantages of these differences to simplify the code. Signed-off-by: "E

[PATCH 0/5] exec: Control flow simplifications

2020-05-09 Thread Eric W. Biederman
in my changes is cap_bprm_set_creds propbably needs a new name as I have taken it out of security_bprm_set_creds but my imagination failed to come up with anything better. Eric W. Biederman (5): exec: Call cap_bprm_set_creds directly from prepare_binprm exec: Directly call

Re: [PATCH 4/6] exec: Run sync_mm_rss before taking exec_update_mutex

2020-05-09 Thread Eric W. Biederman
Kees Cook writes: > $ git grep exec_mm_release > fs/exec.c: exec_mm_release(tsk, old_mm); > include/linux/sched/mm.h:extern void exec_mm_release(struct task_struct *, > struct mm_struct *); > kernel/fork.c:void exec_mm_release(struct task_struct *tsk, struct mm_struct > *mm) > > kernel/for

Re: [PATCH 5/6] exec: Move handling of the point of no return to the top level

2020-05-09 Thread Eric W. Biederman
Kees Cook writes: > On Fri, May 08, 2020 at 01:47:10PM -0500, Eric W. Biederman wrote: >> >> Move the handing of the point of no return from search_binary_handler >> into __do_execve_file so that it is easier to find, and to keep >> things robust in the face of change

[PATCH 6/6] exec: Set the point of no return sooner

2020-05-08 Thread Eric W. Biederman
nding fatal signal pending past the point of no return. Further the only error returns from de_thread and exec_mmap that can occur result in fatal signals being pending. Signed-off-by: "Eric W. Biederman" --- fs/exec.c | 12 +--- 1 file changed, 5 insertions(+), 7 deletions(-

[PATCH 5/6] exec: Move handling of the point of no return to the top level

2020-05-08 Thread Eric W. Biederman
documenting what the code is doing where it forces SIGSEGV if the code is past the point of no return. Signed-off-by: "Eric W. Biederman" --- fs/exec.c | 21 - 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 15682a1dfee9..443eb960f

[PATCH 4/6] exec: Run sync_mm_rss before taking exec_update_mutex

2020-05-08 Thread Eric W. Biederman
Like exec_mm_release sync_mm_rss is about flushing out the state of the old_mm, which does not need to happen under exec_update_mutex. Make this explicit by moving sync_mm_rss outside of exec_update_mutex. Signed-off-by: "Eric W. Biederman" --- fs/exec.c | 3 ++- 1 file changed, 2

[PATCH 3/6] exec: Stop open coding mutex_lock_killable of cred_guard_mutex

2020-05-08 Thread Eric W. Biederman
ut it does it a little more cleanly. Switch the code to mutex_lock_killable so that it is clearer what the code is doing. Ref: ad776537cc6b ("Add mutex_lock_killable") Ref: 793285fcafce ("cred_guard_mutex: do not return -EINTR to user-space") Signed-off-by: "Eric W

[PATCH 2/6] exec: Fix spelling of search_binary_handler in a comment

2020-05-08 Thread Eric W. Biederman
Signed-off-by: "Eric W. Biederman" --- fs/exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/exec.c b/fs/exec.c index d4387bc92292..82106241ed53 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1296,7 +1296,7 @@ void __set_task_comm(struct task_struct *tsk,

[PATCH 1/6] exec: Move the comment from above de_thread to above unshare_sighand

2020-05-08 Thread Eric W. Biederman
The comment describes work that now happens in unshare_sighand so move the comment where it makes sense. Signed-off-by: "Eric W. Biederman" --- fs/exec.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 3cc40048cc65..d4

[PATCH 0/6] exec: Trivial cleanups for exec

2020-05-08 Thread Eric W. Biederman
k there is anything controversial in there but if you see something please let me know. Eric W. Biederman (6): exec: Move the comment from above de_thread to above unshare_sighand exec: Fix spelling of search_binary_handler in a comment exec: Stop open coding mutex_lock_k

Re: [PATCH 6/7] exec: Move most of setup_new_exec into flush_old_exec

2020-05-07 Thread Eric W. Biederman
Kees Cook writes: > On Tue, May 05, 2020 at 02:45:33PM -0500, Eric W. Biederman wrote: >> >> The current idiom for the callers is: >> >> flush_old_exec(bprm); >> set_personality(...); >> setup_new_exec(bprm); >> >> In 2010 Linus split flush

Re: [PATCH 6/7] exec: Move most of setup_new_exec into flush_old_exec

2020-05-07 Thread Eric W. Biederman
Kees Cook writes: > On Wed, May 06, 2020 at 09:57:10AM -0500, Eric W. Biederman wrote: >> Kees Cook writes: >> >> > On Tue, May 05, 2020 at 02:45:33PM -0500, Eric W. Biederman wrote: >> >> >> >> The current idiom for the callers is: >>

Re: remove set_fs calls from the coredump code v6

2020-05-06 Thread Eric W. Biederman
Christoph Hellwig writes: > On Tue, May 05, 2020 at 03:28:50PM -0500, Eric W. Biederman wrote: >> We probably can. After introducing a kernel_compat_siginfo that is >> the size that userspace actually would need. >> >> It isn't something I want to mess with u

Re: [PATCH 6/7] exec: Move most of setup_new_exec into flush_old_exec

2020-05-06 Thread Eric W. Biederman
Kees Cook writes: > On Tue, May 05, 2020 at 02:45:33PM -0500, Eric W. Biederman wrote: >> >> The current idiom for the callers is: >> >> flush_old_exec(bprm); >> set_personality(...); >> setup_new_exec(bprm); >> >> In 2010 Linus split flush

Re: [PATCH 1/7] binfmt: Move install_exec_creds after setup_new_exec to match binfmt_elf

2020-05-06 Thread Eric W. Biederman
Greg Ungerer writes: > One small nit: Good point. > On 6/5/20 5:41 am, Eric W. Biederman wrote: >> In 2016 Linus moved install_exec_creds immediately after >> setup_new_exec, in binfmt_elf as a cleanup and as part of closing a >> potential information leak. >> &

Re: remove set_fs calls from the coredump code v6

2020-05-05 Thread Eric W. Biederman
Linus Torvalds writes: > On Tue, May 5, 2020 at 3:13 AM Christoph Hellwig wrote: >> >> this series gets rid of playing with the address limit in the exec and >> coredump code. Most of this was fairly trivial, the biggest changes are >> those to the spufs coredump code. > > Ack, nice, and looks

[PATCH 7/7] exec: Rename flush_old_exec begin_new_exec

2020-05-05 Thread Eric W. Biederman
more accurately reflect what this function does. Signed-off-by: "Eric W. Biederman" --- Documentation/trace/ftrace.rst | 2 +- arch/x86/ia32/ia32_aout.c | 2 +- fs/binfmt_aout.c | 2 +- fs/binfmt_elf.c| 2 +- fs/binfmt_elf_fdpic.c | 2 +- fs/bin

[PATCH 6/7] exec: Move most of setup_new_exec into flush_old_exec

2020-05-05 Thread Eric W. Biederman
code that doesn't depend upon the personality from setup_new_exec into flush_old_exec. This is to facilitate future changes by having as much code together in one function as possible. Ref: 221af7f87b97 ("Split 'flush_old_exec' into two functions") Signed-off-by: "Eric

[PATCH 5/7] exec: In setup_new_exec cache current in the local variable me

2020-05-05 Thread Eric W. Biederman
and shorter assembly. Signed-off-by: "Eric W. Biederman" --- fs/exec.c | 23 --- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 93e40f865523..8c3abafb9bb1 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1391,6 +1391,7 @@ EXP

[PATCH 4/7] exec: Merge install_exec_creds into setup_new_exec

2020-05-05 Thread Eric W. Biederman
The two functions are now always called one right after the other so merge them together to make future maintenance easier. Signed-off-by: "Eric W. Biederman" --- arch/x86/ia32/ia32_aout.c | 1 - fs/binfmt_aout.c | 1 - fs/binfmt_elf.c | 1 - fs/binfmt_e

[PATCH 3/7] exec: Rename the flag called_exec_mmap point_of_no_return

2020-05-05 Thread Eric W. Biederman
Update the comments and make the code easier to understand by renaming this flag. Signed-off-by: "Eric W. Biederman" --- fs/exec.c | 12 ++-- include/linux/binfmts.h | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/exec.c b/fs/ex

[PATCH 2/7] exec: Make unlocking exec_update_mutex explict

2020-05-05 Thread Eric W. Biederman
from free_bprm. Signed-off-by: "Eric W. Biederman" --- fs/exec.c | 6 +++--- include/linux/binfmts.h | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 06b4c550af5d..6bd82a007bfc 100644 --- a/fs/exec.c +++ b/fs/exec.c

[PATCH 1/7] binfmt: Move install_exec_creds after setup_new_exec to match binfmt_elf

2020-05-05 Thread Eric W. Biederman
reason about and easier to maintain. The binfmt_flagt bits were tested by Greg Ungerer Ref: 9f834ec18def ("binfmt_elf: switch to new creds when switching to new mm") Signed-off-by: "Eric W. Biederman" --- arch/x86/ia32/ia32_aout.c | 3 +-- fs/binfmt_aout.c | 2 +- f

exec: Promised cleanups after introducing exec_update_mutex

2020-05-05 Thread Eric W. Biederman
: begin_new_exec(); /* set the personality */ setup_new_exec(); The intent is to make the code easier to follow and easier to change. Eric W. Biederman (7): binfmt: Move install_exec_creds after setup_new_exec to match binfmt_elf exec: Make unlocking exec_update_mutex explict

Re: [RFC][PATCH] kexec: Teach indirect pages how to live in high memory

2020-05-05 Thread Eric W. Biederman
Hari Bathini writes: > On 05/05/20 3:29 am, Eric W. Biederman wrote: >> >> Recently a patch was proposed to kimage_alloc_page to slightly alter >> the logic of how pages allocated with incompatible flags were >> detected. The logic was being altered because t

[RFC][PATCH] kexec: Teach indirect pages how to live in high memory

2020-05-04 Thread Eric W. Biederman
, and handling of pages with different gfp flags has been removed. Signed-off-by: "Eric W. Biederman" --- I have not done more than compile test this but I think this will remove that tricky case in the kexec highmem support. Any comments? Does anyone have a 32bit highmem system where the

Re: [PATCH v3 2/3] nsproxy: attach to namespaces via pidfds

2020-05-04 Thread Eric W. Biederman
Christian Brauner writes: > On Mon, May 04, 2020 at 11:25:07AM -0500, Eric W. Biederman wrote: >> >> I am not thrilled about treating nstype as a flags fields when it is not >> currently. It was my hope when I designed the interface that not >> treating nstype as

Re: [PATCH v3 2/3] nsproxy: attach to namespaces via pidfds

2020-05-04 Thread Eric W. Biederman
I am not thrilled about treating nstype as a flags fields when it is not currently. It was my hope when I designed the interface that not treating nstype as a flags field would save us from the problem of bits running out. That aside. It would be very good if the default version of setting eve

Re: [PATCH v3 1/3] nsproxy: add struct nsset

2020-05-04 Thread Eric W. Biederman
don't verify the kind of file descriptor passed. Quite frankly doing nstype & CLONE_XYZ is wrong. It always needs to be nstype == CLONE_XYZ. Maybe we change that in a later patch but here where you are just upgrading the infrastructure semantics changes are not ok. Eric > Cc: Eric W.

Re: [PATCH v2 03/10] kexec: separate PageHighMem() and PageHighMemZone() use case

2020-05-04 Thread Eric W. Biederman
I have added in the kexec mailling list. Looking at the patch we are discussing it appears that the kexec code could be doing much better in highmem situations today but is not. Joonsoo Kim writes: > 2020년 5월 1일 (금) 오후 11:06, Eric W. Biederman 님이 작성: >> >> js1...@g

Re: [PATCH v2 1/4] capability: add ns_capable_cred()

2020-05-02 Thread Eric W. Biederman
Christian Brauner writes: > On Sat, May 02, 2020 at 07:35:53AM -0500, Eric W. Biederman wrote: >> Christian Brauner writes: >> >> > On Thu, Apr 30, 2020 at 01:09:30PM -0500, Eric W. Biederman wrote: >> >> Christian Brauner writes: >> >> >&

Re: [PATCH v2 1/4] capability: add ns_capable_cred()

2020-05-02 Thread Eric W. Biederman
Christian Brauner writes: > On Thu, Apr 30, 2020 at 01:09:30PM -0500, Eric W. Biederman wrote: >> Christian Brauner writes: >> >> > Add a simple capability helper which makes it possible to determine >> > whether a set of creds is ns capable wrt to the passed

Re: [PATCH v2 03/10] kexec: separate PageHighMem() and PageHighMemZone() use case

2020-05-01 Thread Eric W. Biederman
ld be really helpful is if there was a straight forward way to allocate memory whose physical address fits in the native word size. All I know for certain about this patch is that it takes a piece of code that looked like it made sense, and transfroms it into something I can not easily verify, and

<    1   2   3   4   5   6   7   8   9   10   >