Skip to content

Commit

Permalink
Merge tag 'selinux-pr-20170831' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/pcmoore/selinux

Pull selinux updates from Paul Moore:
 "A relatively quiet period for SELinux, 11 patches with only two/three
  having any substantive changes.

  These noteworthy changes include another tweak to the NNP/nosuid
  handling, per-file labeling for cgroups, and an object class fix for
  AF_UNIX/SOCK_RAW sockets; the rest of the changes are minor tweaks or
  administrative updates (Stephen's email update explains the file
  explosion in the diffstat).

  Everything passes the selinux-testsuite"

[ Also a couple of small patches from the security tree from Tetsuo
  Handa for Tomoyo and LSM cleanup. The separation of security policy
  updates wasn't all that clean - Linus ]

* tag 'selinux-pr-20170831' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
  selinux: constify nf_hook_ops
  selinux: allow per-file labeling for cgroupfs
  lsm_audit: update my email address
  selinux: update my email address
  MAINTAINERS: update the NetLabel and Labeled Networking information
  selinux: use GFP_NOWAIT in the AVC kmem_caches
  selinux: Generalize support for NNP/nosuid SELinux domain transitions
  selinux: genheaders should fail if too many permissions are defined
  selinux: update the selinux info in MAINTAINERS
  credits: update Paul Moore's info
  selinux: Assign proper class to PF_UNIX/SOCK_RAW sockets
  tomoyo: Update URLs in Documentation/admin-guide/LSM/tomoyo.rst
  LSM: Remove security_task_create() hook.
  • Loading branch information
torvalds committed Sep 12, 2017
2 parents 680352b + 0c3014f commit 7f85565
Show file tree
Hide file tree
Showing 36 changed files with 117 additions and 104 deletions.
8 changes: 3 additions & 5 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -2606,11 +2606,9 @@ E: [email protected]
D: bug fixes, documentation, minor hackery

N: Paul Moore
E: [email protected]
D: NetLabel author
S: Hewlett-Packard
S: 110 Spit Brook Road
S: Nashua, NH 03062
E: [email protected]
W: http://www.paul-moore.com
D: NetLabel, SELinux, audit

N: James Morris
E: [email protected]
Expand Down
24 changes: 12 additions & 12 deletions Documentation/admin-guide/LSM/tomoyo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ TOMOYO is a name-based MAC extension (LSM module) for the Linux kernel.

LiveCD-based tutorials are available at

http://tomoyo.sourceforge.jp/1.7/1st-step/ubuntu10.04-live/
http://tomoyo.sourceforge.jp/1.7/1st-step/centos5-live/
http://tomoyo.sourceforge.jp/1.8/ubuntu12.04-live.html
http://tomoyo.sourceforge.jp/1.8/centos6-live.html

Though these tutorials use non-LSM version of TOMOYO, they are useful for you
to know what TOMOYO is.
Expand All @@ -21,35 +21,35 @@ How to enable TOMOYO?
Build the kernel with ``CONFIG_SECURITY_TOMOYO=y`` and pass ``security=tomoyo`` on
kernel's command line.

Please see http://tomoyo.sourceforge.jp/2.3/ for details.
Please see http://tomoyo.osdn.jp/2.5/ for details.

Where is documentation?
=======================

User <-> Kernel interface documentation is available at
http://tomoyo.sourceforge.jp/2.3/policy-reference.html .
http://tomoyo.osdn.jp/2.5/policy-specification/index.html .

Materials we prepared for seminars and symposiums are available at
http://sourceforge.jp/projects/tomoyo/docs/?category_id=532&language_id=1 .
http://osdn.jp/projects/tomoyo/docs/?category_id=532&language_id=1 .
Below lists are chosen from three aspects.

What is TOMOYO?
TOMOYO Linux Overview
http://sourceforge.jp/projects/tomoyo/docs/lca2009-takeda.pdf
http://osdn.jp/projects/tomoyo/docs/lca2009-takeda.pdf
TOMOYO Linux: pragmatic and manageable security for Linux
http://sourceforge.jp/projects/tomoyo/docs/freedomhectaipei-tomoyo.pdf
http://osdn.jp/projects/tomoyo/docs/freedomhectaipei-tomoyo.pdf
TOMOYO Linux: A Practical Method to Understand and Protect Your Own Linux Box
http://sourceforge.jp/projects/tomoyo/docs/PacSec2007-en-no-demo.pdf
http://osdn.jp/projects/tomoyo/docs/PacSec2007-en-no-demo.pdf

What can TOMOYO do?
Deep inside TOMOYO Linux
http://sourceforge.jp/projects/tomoyo/docs/lca2009-kumaneko.pdf
http://osdn.jp/projects/tomoyo/docs/lca2009-kumaneko.pdf
The role of "pathname based access control" in security.
http://sourceforge.jp/projects/tomoyo/docs/lfj2008-bof.pdf
http://osdn.jp/projects/tomoyo/docs/lfj2008-bof.pdf

History of TOMOYO?
Realities of Mainlining
http://sourceforge.jp/projects/tomoyo/docs/lfj2008.pdf
http://osdn.jp/projects/tomoyo/docs/lfj2008.pdf

What is future plan?
====================
Expand All @@ -60,6 +60,6 @@ multiple LSM modules at the same time. We feel sorry that you have to give up
SELinux/SMACK/AppArmor etc. when you want to use TOMOYO.

We hope that LSM becomes stackable in future. Meanwhile, you can use non-LSM
version of TOMOYO, available at http://tomoyo.sourceforge.jp/1.7/ .
version of TOMOYO, available at http://tomoyo.osdn.jp/1.8/ .
LSM version of TOMOYO is a subset of non-LSM version of TOMOYO. We are planning
to port non-LSM version's functionalities to LSM versions.
29 changes: 17 additions & 12 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -9298,15 +9298,6 @@ F: net/*/netfilter/
F: net/netfilter/
F: net/bridge/br_netfilter*.c

NETLABEL
M: Paul Moore <[email protected]>
W: http://netlabel.sf.net
L: [email protected]
S: Maintained
F: Documentation/netlabel/
F: include/net/netlabel.h
F: net/netlabel/

NETROM NETWORK LAYER
M: Ralf Baechle <[email protected]>
L: [email protected]
Expand Down Expand Up @@ -9434,10 +9425,23 @@ F: net/ipv6/
F: include/net/ip*
F: arch/x86/net/*

NETWORKING [LABELED] (NetLabel, CIPSO, Labeled IPsec, SECMARK)
NETWORKING [LABELED] (NetLabel, Labeled IPsec, SECMARK)
M: Paul Moore <[email protected]>
W: https://github.com/netlabel
L: [email protected]
L: [email protected]
S: Maintained
F: Documentation/netlabel/
F: include/net/calipso.h
F: include/net/cipso_ipv4.h
F: include/net/netlabel.h
F: include/uapi/linux/netfilter/xt_SECMARK.h
F: include/uapi/linux/netfilter/xt_CONNSECMARK.h
F: net/netlabel/
F: net/ipv4/cipso_ipv4.c
F: net/ipv6/calipso.c
F: net/netfilter/xt_CONNSECMARK.c
F: net/netfilter/xt_SECMARK.c

NETWORKING [TLS]
M: Ilya Lesokhin <[email protected]>
Expand Down Expand Up @@ -12023,8 +12027,9 @@ M: Paul Moore <[email protected]>
M: Stephen Smalley <[email protected]>
M: Eric Paris <[email protected]>
L: [email protected] (moderated for non-subscribers)
W: http://selinuxproject.org
T: git git://git.infradead.org/users/pcmoore/selinux
W: https://selinuxproject.org
W: https://github.com/SELinuxProject
T: git git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux.git
S: Supported
F: include/linux/selinux*
F: security/selinux/
Expand Down
2 changes: 1 addition & 1 deletion include/linux/lsm_audit.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* Author : Etienne BASSET <[email protected]>
*
* All credits to : Stephen Smalley, <sds@epoch.ncsc.mil>
* All credits to : Stephen Smalley, <sds@tycho.nsa.gov>
* All BUGS to : Etienne BASSET <[email protected]>
*/
#ifndef _LSM_COMMON_LOGGING_
Expand Down
7 changes: 0 additions & 7 deletions include/linux/lsm_hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,6 @@
*
* Security hooks for task operations.
*
* @task_create:
* Check permission before creating a child process. See the clone(2)
* manual page for definitions of the @clone_flags.
* @clone_flags contains the flags indicating what should be shared.
* Return 0 if permission is granted.
* @task_alloc:
* @task task being allocated.
* @clone_flags contains the flags indicating what should be shared.
Expand Down Expand Up @@ -1505,7 +1500,6 @@ union security_list_options {
int (*file_receive)(struct file *file);
int (*file_open)(struct file *file, const struct cred *cred);

int (*task_create)(unsigned long clone_flags);
int (*task_alloc)(struct task_struct *task, unsigned long clone_flags);
void (*task_free)(struct task_struct *task);
int (*cred_alloc_blank)(struct cred *cred, gfp_t gfp);
Expand Down Expand Up @@ -1779,7 +1773,6 @@ struct security_hook_heads {
struct list_head file_send_sigiotask;
struct list_head file_receive;
struct list_head file_open;
struct list_head task_create;
struct list_head task_alloc;
struct list_head task_free;
struct list_head cred_alloc_blank;
Expand Down
6 changes: 0 additions & 6 deletions include/linux/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ int security_file_send_sigiotask(struct task_struct *tsk,
struct fown_struct *fown, int sig);
int security_file_receive(struct file *file);
int security_file_open(struct file *file, const struct cred *cred);
int security_task_create(unsigned long clone_flags);
int security_task_alloc(struct task_struct *task, unsigned long clone_flags);
void security_task_free(struct task_struct *task);
int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
Expand Down Expand Up @@ -880,11 +879,6 @@ static inline int security_file_open(struct file *file,
return 0;
}

static inline int security_task_create(unsigned long clone_flags)
{
return 0;
}

static inline int security_task_alloc(struct task_struct *task,
unsigned long clone_flags)
{
Expand Down
4 changes: 0 additions & 4 deletions kernel/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -1569,10 +1569,6 @@ static __latent_entropy struct task_struct *copy_process(
return ERR_PTR(-EINVAL);
}

retval = security_task_create(clone_flags);
if (retval)
goto fork_out;

retval = -ENOMEM;
p = dup_task_struct(current, node);
if (!p)
Expand Down
7 changes: 6 additions & 1 deletion scripts/selinux/genheaders/genheaders.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,16 @@ int main(int argc, char *argv[])
for (i = 0; secclass_map[i].name; i++) {
struct security_class_mapping *map = &secclass_map[i];
for (j = 0; map->perms[j]; j++) {
if (j >= 32) {
fprintf(stderr, "Too many permissions to fit into an access vector at (%s, %s).\n",
map->name, map->perms[j]);
exit(5);
}
fprintf(fout, "#define %s__%s", map->name,
map->perms[j]);
for (k = 0; k < max(1, 40 - strlen(map->name) - strlen(map->perms[j])); k++)
fprintf(fout, " ");
fprintf(fout, "0x%08xUL\n", (1<<j));
fprintf(fout, "0x%08xU\n", (1<<j));
}
}

Expand Down
2 changes: 1 addition & 1 deletion security/lsm_audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* common LSM auditing functions
*
* Based on code written for SELinux by :
* Stephen Smalley, <sds@epoch.ncsc.mil>
* Stephen Smalley, <sds@tycho.nsa.gov>
* James Morris <[email protected]>
* Author : Etienne Basset, <[email protected]>
*
Expand Down
5 changes: 0 additions & 5 deletions security/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -974,11 +974,6 @@ int security_file_open(struct file *file, const struct cred *cred)
return fsnotify_perm(file, MAY_OPEN);
}

int security_task_create(unsigned long clone_flags)
{
return call_int_hook(task_create, 0, clone_flags);
}

int security_task_alloc(struct task_struct *task, unsigned long clone_flags)
{
return call_int_hook(task_alloc, 0, task, clone_flags);
Expand Down
16 changes: 7 additions & 9 deletions security/selinux/avc.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Implementation of the kernel access vector cache (AVC).
*
* Authors: Stephen Smalley, <sds@epoch.ncsc.mil>
* Authors: Stephen Smalley, <sds@tycho.nsa.gov>
* James Morris <[email protected]>
*
* Update: KaiGai, Kohei <[email protected]>
Expand Down Expand Up @@ -346,27 +346,26 @@ static struct avc_xperms_decision_node
struct avc_xperms_decision_node *xpd_node;
struct extended_perms_decision *xpd;

xpd_node = kmem_cache_zalloc(avc_xperms_decision_cachep,
GFP_ATOMIC | __GFP_NOMEMALLOC);
xpd_node = kmem_cache_zalloc(avc_xperms_decision_cachep, GFP_NOWAIT);
if (!xpd_node)
return NULL;

xpd = &xpd_node->xpd;
if (which & XPERMS_ALLOWED) {
xpd->allowed = kmem_cache_zalloc(avc_xperms_data_cachep,
GFP_ATOMIC | __GFP_NOMEMALLOC);
GFP_NOWAIT);
if (!xpd->allowed)
goto error;
}
if (which & XPERMS_AUDITALLOW) {
xpd->auditallow = kmem_cache_zalloc(avc_xperms_data_cachep,
GFP_ATOMIC | __GFP_NOMEMALLOC);
GFP_NOWAIT);
if (!xpd->auditallow)
goto error;
}
if (which & XPERMS_DONTAUDIT) {
xpd->dontaudit = kmem_cache_zalloc(avc_xperms_data_cachep,
GFP_ATOMIC | __GFP_NOMEMALLOC);
GFP_NOWAIT);
if (!xpd->dontaudit)
goto error;
}
Expand Down Expand Up @@ -394,8 +393,7 @@ static struct avc_xperms_node *avc_xperms_alloc(void)
{
struct avc_xperms_node *xp_node;

xp_node = kmem_cache_zalloc(avc_xperms_cachep,
GFP_ATOMIC|__GFP_NOMEMALLOC);
xp_node = kmem_cache_zalloc(avc_xperms_cachep, GFP_NOWAIT);
if (!xp_node)
return xp_node;
INIT_LIST_HEAD(&xp_node->xpd_head);
Expand Down Expand Up @@ -548,7 +546,7 @@ static struct avc_node *avc_alloc_node(void)
{
struct avc_node *node;

node = kmem_cache_zalloc(avc_node_cachep, GFP_ATOMIC|__GFP_NOMEMALLOC);
node = kmem_cache_zalloc(avc_node_cachep, GFP_NOWAIT);
if (!node)
goto out;

Expand Down
54 changes: 37 additions & 17 deletions security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* This file contains the SELinux hook function implementations.
*
* Authors: Stephen Smalley, <sds@epoch.ncsc.mil>
* Authors: Stephen Smalley, <sds@tycho.nsa.gov>
* Chris Vance, <[email protected]>
* Wayne Salamon, <[email protected]>
* James Morris <[email protected]>
Expand Down Expand Up @@ -815,7 +815,9 @@ static int selinux_set_mnt_opts(struct super_block *sb,
if (!strcmp(sb->s_type->name, "debugfs") ||
!strcmp(sb->s_type->name, "tracefs") ||
!strcmp(sb->s_type->name, "sysfs") ||
!strcmp(sb->s_type->name, "pstore"))
!strcmp(sb->s_type->name, "pstore") ||
!strcmp(sb->s_type->name, "cgroup") ||
!strcmp(sb->s_type->name, "cgroup2"))
sbsec->flags |= SE_SBGENFS;

if (!sbsec->behavior) {
Expand Down Expand Up @@ -1303,6 +1305,7 @@ static inline u16 socket_type_to_security_class(int family, int type, int protoc
case SOCK_SEQPACKET:
return SECCLASS_UNIX_STREAM_SOCKET;
case SOCK_DGRAM:
case SOCK_RAW:
return SECCLASS_UNIX_DGRAM_SOCKET;
}
break;
Expand Down Expand Up @@ -2317,6 +2320,7 @@ static int check_nnp_nosuid(const struct linux_binprm *bprm,
int nnp = (bprm->unsafe & LSM_UNSAFE_NO_NEW_PRIVS);
int nosuid = !mnt_may_suid(bprm->file->f_path.mnt);
int rc;
u32 av;

if (!nnp && !nosuid)
return 0; /* neither NNP nor nosuid */
Expand All @@ -2325,24 +2329,40 @@ static int check_nnp_nosuid(const struct linux_binprm *bprm,
return 0; /* No change in credentials */

/*
* The only transitions we permit under NNP or nosuid
* are transitions to bounded SIDs, i.e. SIDs that are
* guaranteed to only be allowed a subset of the permissions
* of the current SID.
* If the policy enables the nnp_nosuid_transition policy capability,
* then we permit transitions under NNP or nosuid if the
* policy allows the corresponding permission between
* the old and new contexts.
*/
rc = security_bounded_transition(old_tsec->sid, new_tsec->sid);
if (rc) {
/*
* On failure, preserve the errno values for NNP vs nosuid.
* NNP: Operation not permitted for caller.
* nosuid: Permission denied to file.
*/
if (selinux_policycap_nnp_nosuid_transition) {
av = 0;
if (nnp)
return -EPERM;
else
return -EACCES;
av |= PROCESS2__NNP_TRANSITION;
if (nosuid)
av |= PROCESS2__NOSUID_TRANSITION;
rc = avc_has_perm(old_tsec->sid, new_tsec->sid,
SECCLASS_PROCESS2, av, NULL);
if (!rc)
return 0;
}
return 0;

/*
* We also permit NNP or nosuid transitions to bounded SIDs,
* i.e. SIDs that are guaranteed to only be allowed a subset
* of the permissions of the current SID.
*/
rc = security_bounded_transition(old_tsec->sid, new_tsec->sid);
if (!rc)
return 0;

/*
* On failure, preserve the errno values for NNP vs nosuid.
* NNP: Operation not permitted for caller.
* nosuid: Permission denied to file.
*/
if (nnp)
return -EPERM;
return -EACCES;
}

static int selinux_bprm_set_creds(struct linux_binprm *bprm)
Expand Down
2 changes: 1 addition & 1 deletion security/selinux/include/avc.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Access vector cache interface for object managers.
*
* Author : Stephen Smalley, <sds@epoch.ncsc.mil>
* Author : Stephen Smalley, <sds@tycho.nsa.gov>
*/
#ifndef _SELINUX_AVC_H_
#define _SELINUX_AVC_H_
Expand Down
Loading

0 comments on commit 7f85565

Please sign in to comment.