Skip to content

Commit 2af6228

Browse files
committed
LSM: drop bprm_secureexec hook
This removes the bprm_secureexec hook since the logic has been folded into the bprm_set_creds hook for all LSMs now. Cc: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: John Johansen <john.johansen@canonical.com> Acked-by: James Morris <james.l.morris@oracle.com> Acked-by: Serge Hallyn <serge@hallyn.com>
1 parent ee67ae7 commit 2af6228

File tree

4 files changed

+5
-22
lines changed

4 files changed

+5
-22
lines changed

fs/exec.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,8 +1343,6 @@ EXPORT_SYMBOL(would_dump);
13431343

13441344
void setup_new_exec(struct linux_binprm * bprm)
13451345
{
1346-
bprm->secureexec |= security_bprm_secureexec(bprm);
1347-
13481346
/*
13491347
* Once here, prepare_binrpm() will not be called any more, so
13501348
* the final state of setuid/setgid/fscaps can be merged into the

include/linux/lsm_hooks.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@
4343
* interpreters. The hook can tell whether it has already been called by
4444
* checking to see if @bprm->security is non-NULL. If so, then the hook
4545
* may decide either to retain the security information saved earlier or
46-
* to replace it.
46+
* to replace it. The hook must set @bprm->secureexec to 1 if a "secure
47+
* exec" has happened as a result of this hook call. The flag is used to
48+
* indicate the need for a sanitized execution environment, and is also
49+
* passed in the ELF auxiliary table on the initial stack to indicate
50+
* whether libc should enable secure mode.
4751
* @bprm contains the linux_binprm structure.
4852
* Return 0 if the hook is successful and permission is granted.
4953
* @bprm_check_security:
@@ -71,12 +75,6 @@
7175
* linux_binprm structure. This hook is a good place to perform state
7276
* changes on the process such as clearing out non-inheritable signal
7377
* state. This is called immediately after commit_creds().
74-
* @bprm_secureexec:
75-
* Return a boolean value (0 or 1) indicating whether a "secure exec"
76-
* is required. The flag is passed in the auxiliary table
77-
* on the initial stack to the ELF interpreter to indicate whether libc
78-
* should enable secure mode.
79-
* @bprm contains the linux_binprm structure.
8078
*
8179
* Security hooks for filesystem operations.
8280
*
@@ -1388,7 +1386,6 @@ union security_list_options {
13881386

13891387
int (*bprm_set_creds)(struct linux_binprm *bprm);
13901388
int (*bprm_check_security)(struct linux_binprm *bprm);
1391-
int (*bprm_secureexec)(struct linux_binprm *bprm);
13921389
void (*bprm_committing_creds)(struct linux_binprm *bprm);
13931390
void (*bprm_committed_creds)(struct linux_binprm *bprm);
13941391

@@ -1710,7 +1707,6 @@ struct security_hook_heads {
17101707
struct list_head vm_enough_memory;
17111708
struct list_head bprm_set_creds;
17121709
struct list_head bprm_check_security;
1713-
struct list_head bprm_secureexec;
17141710
struct list_head bprm_committing_creds;
17151711
struct list_head bprm_committed_creds;
17161712
struct list_head sb_alloc_security;

include/linux/security.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ int security_bprm_set_creds(struct linux_binprm *bprm);
231231
int security_bprm_check(struct linux_binprm *bprm);
232232
void security_bprm_committing_creds(struct linux_binprm *bprm);
233233
void security_bprm_committed_creds(struct linux_binprm *bprm);
234-
int security_bprm_secureexec(struct linux_binprm *bprm);
235234
int security_sb_alloc(struct super_block *sb);
236235
void security_sb_free(struct super_block *sb);
237236
int security_sb_copy_data(char *orig, char *copy);
@@ -540,11 +539,6 @@ static inline void security_bprm_committed_creds(struct linux_binprm *bprm)
540539
{
541540
}
542541

543-
static inline int security_bprm_secureexec(struct linux_binprm *bprm)
544-
{
545-
return 0;
546-
}
547-
548542
static inline int security_sb_alloc(struct super_block *sb)
549543
{
550544
return 0;

security/security.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,6 @@ void security_bprm_committed_creds(struct linux_binprm *bprm)
351351
call_void_hook(bprm_committed_creds, bprm);
352352
}
353353

354-
int security_bprm_secureexec(struct linux_binprm *bprm)
355-
{
356-
return call_int_hook(bprm_secureexec, 0, bprm);
357-
}
358-
359354
int security_sb_alloc(struct super_block *sb)
360355
{
361356
return call_int_hook(sb_alloc_security, 0, sb);

0 commit comments

Comments
 (0)