From: Kees Cook <keescook@chromium.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Kees Cook <keescook@chromium.org>,
David Howells <dhowells@redhat.com>,
John Johansen <john.johansen@canonical.com>,
Paul Moore <paul@paul-moore.com>,
Stephen Smalley <sds@tycho.nsa.gov>,
Casey Schaufler <casey@schaufler-ca.com>,
James Morris <james.l.morris@oracle.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
"Serge E. Hallyn" <serge@hallyn.com>,
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
Andy Lutomirski <luto@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-fsdevel@vger.kernel.org,
linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v4 01/15] exec: Rename bprm->cred_prepared to called_set_creds
Date: Mon, 31 Jul 2017 16:51:19 -0700 [thread overview]
Message-ID: <1501545093-56634-2-git-send-email-keescook@chromium.org> (raw)
In-Reply-To: <1501545093-56634-1-git-send-email-keescook@chromium.org>
The cred_prepared bprm flag has a misleading name. It has nothing to do
with the bprm_prepare_cred hook, and actually tracks if bprm_set_creds has
been called. Rename this flag and improve its comment.
Cc: David Howells <dhowells@redhat.com>
Cc: John Johansen <john.johansen@canonical.com>
Cc: Paul Moore <paul@paul-moore.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Casey Schaufler <casey@schaufler-ca.com>
Cc: James Morris <james.l.morris@oracle.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: John Johansen <john.johansen@canonical.com>
Acked-by: James Morris <james.l.morris@oracle.com>
Acked-by: Paul Moore <paul@paul-moore.com>
Acked-by: Serge Hallyn <serge@hallyn.com>
---
fs/binfmt_flat.c | 2 +-
fs/exec.c | 2 +-
include/linux/binfmts.h | 8 ++++++--
security/apparmor/domain.c | 2 +-
security/selinux/hooks.c | 2 +-
security/smack/smack_lsm.c | 2 +-
security/tomoyo/tomoyo.c | 2 +-
7 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index 2edcefc0a294..a722530cc468 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -885,7 +885,7 @@ static int load_flat_shared_library(int id, struct lib_info *libs)
* as we're past the point of no return and are dealing with shared
* libraries.
*/
- bprm.cred_prepared = 1;
+ bprm.called_set_creds = 1;
res = prepare_binprm(&bprm);
diff --git a/fs/exec.c b/fs/exec.c
index 72934df68471..cedae1620d2f 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1527,7 +1527,7 @@ int prepare_binprm(struct linux_binprm *bprm)
retval = security_bprm_set_creds(bprm);
if (retval)
return retval;
- bprm->cred_prepared = 1;
+ bprm->called_set_creds = 1;
memset(bprm->buf, 0, BINPRM_BUF_SIZE);
return kernel_read(bprm->file, 0, bprm->buf, BINPRM_BUF_SIZE);
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
index 05488da3aee9..3cd98e8bc9dc 100644
--- a/include/linux/binfmts.h
+++ b/include/linux/binfmts.h
@@ -25,8 +25,12 @@ struct linux_binprm {
struct mm_struct *mm;
unsigned long p; /* current top of mem */
unsigned int
- cred_prepared:1,/* true if creds already prepared (multiple
- * preps happen for interpreters) */
+ /*
+ * True after the bprm_set_creds hook has been called once
+ * (multiple calls can be made via prepare_binprm() for
+ * binfmt_script/misc).
+ */
+ called_set_creds:1,
cap_effective:1;/* true if has elevated effective capabilities,
* false if not; except for init which inherits
* its parent's caps anyway */
diff --git a/security/apparmor/domain.c b/security/apparmor/domain.c
index 001e133a3c8c..878407e023e3 100644
--- a/security/apparmor/domain.c
+++ b/security/apparmor/domain.c
@@ -350,7 +350,7 @@ int apparmor_bprm_set_creds(struct linux_binprm *bprm)
const char *name = NULL, *info = NULL;
int error = 0;
- if (bprm->cred_prepared)
+ if (bprm->called_set_creds)
return 0;
ctx = cred_ctx(bprm->cred);
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index e67a526d1f30..5d4051541518 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -2328,7 +2328,7 @@ static int selinux_bprm_set_creds(struct linux_binprm *bprm)
/* SELinux context only depends on initial program or script and not
* the script interpreter */
- if (bprm->cred_prepared)
+ if (bprm->called_set_creds)
return 0;
old_tsec = current_security();
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 658f5d8c7e76..7d4b2e221124 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -917,7 +917,7 @@ static int smack_bprm_set_creds(struct linux_binprm *bprm)
struct superblock_smack *sbsp;
int rc;
- if (bprm->cred_prepared)
+ if (bprm->called_set_creds)
return 0;
isp = inode->i_security;
diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
index 130b4fa4f65f..d25b705360e0 100644
--- a/security/tomoyo/tomoyo.c
+++ b/security/tomoyo/tomoyo.c
@@ -76,7 +76,7 @@ static int tomoyo_bprm_set_creds(struct linux_binprm *bprm)
* Do only if this function is called for the first time of an execve
* operation.
*/
- if (bprm->cred_prepared)
+ if (bprm->called_set_creds)
return 0;
#ifndef CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER
/*
--
2.7.4
next prev parent reply other threads:[~2017-07-31 23:51 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-31 23:51 [PATCH v4 00/15] exec: Use sane stack rlimit under secureexec Kees Cook
2017-07-31 23:51 ` Kees Cook [this message]
2017-07-31 23:51 ` [PATCH v4 02/15] exec: Correct comments about "point of no return" Kees Cook
2017-07-31 23:51 ` [PATCH v4 03/15] binfmt: Introduce secureexec flag Kees Cook
2017-08-01 0:23 ` Kees Cook
2017-08-01 0:44 ` James Morris
2017-07-31 23:51 ` [PATCH v4 04/15] apparmor: Refactor to remove bprm_secureexec hook Kees Cook
2017-07-31 23:51 ` [PATCH v4 05/15] selinux: " Kees Cook
2017-08-01 0:45 ` James Morris
2017-08-01 13:24 ` Andy Lutomirski
2017-07-31 23:51 ` [PATCH v4 06/15] smack: " Kees Cook
2017-08-01 0:46 ` James Morris
2017-08-01 15:24 ` Casey Schaufler
2017-07-31 23:51 ` [PATCH v4 07/15] commoncap: " Kees Cook
2017-07-31 23:51 ` [PATCH v4 08/15] commoncap: Move cap_elevated calculation into bprm_set_creds Kees Cook
2017-08-01 13:46 ` Andy Lutomirski
2017-07-31 23:51 ` [PATCH v4 09/15] LSM: drop bprm_secureexec hook Kees Cook
2017-07-31 23:51 ` [PATCH v4 10/15] exec: Use secureexec for setting dumpability Kees Cook
2017-08-01 0:48 ` James Morris
2017-07-31 23:51 ` [PATCH v4 11/15] exec: Use secureexec for clearing pdeath_signal Kees Cook
2017-08-01 0:50 ` James Morris
2017-07-31 23:51 ` [PATCH v4 12/15] smack: Remove redundant pdeath_signal clearing Kees Cook
2017-08-01 0:50 ` James Morris
2017-08-01 15:24 ` Casey Schaufler
2017-07-31 23:51 ` [PATCH v4 13/15] exec: Consolidate dumpability logic Kees Cook
2017-07-31 23:51 ` [PATCH v4 14/15] exec: Use sane stack rlimit under secureexec Kees Cook
2017-07-31 23:51 ` [PATCH v4 15/15] exec: Consolidate pdeath_signal clearing Kees Cook
2017-08-01 0:52 ` James Morris
2017-08-01 0:34 ` [PATCH v4 00/15] exec: Use sane stack rlimit under secureexec Kees Cook
2017-08-01 0:54 ` James Morris
2017-08-01 3:03 ` Kees Cook
2017-08-01 5:11 ` Linus Torvalds
2017-08-01 5:14 ` Linus Torvalds
2017-08-01 15:04 ` Kees Cook
2017-08-01 20:19 ` Linus Torvalds
2017-08-01 21:04 ` Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1501545093-56634-2-git-send-email-keescook@chromium.org \
--to=keescook@chromium.org \
--cc=akpm@linux-foundation.org \
--cc=casey@schaufler-ca.com \
--cc=dhowells@redhat.com \
--cc=ebiederm@xmission.com \
--cc=james.l.morris@oracle.com \
--cc=john.johansen@canonical.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=luto@kernel.org \
--cc=paul@paul-moore.com \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=sds@tycho.nsa.gov \
--cc=serge@hallyn.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).