diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-09-23 14:21:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-09-23 14:21:04 -0400 |
commit | 5825a95fe92566ada2292a65de030850b5cff1da (patch) | |
tree | 8e210a297844f6e07e0acb6ee793036a2c692976 /security/selinux/netif.c | |
parent | 3c6a6910a81eae3566bb5fef6ea0f624382595e6 (diff) | |
parent | 15322a0d90b6fd62ae8f22e5b87f735c3fdfeff7 (diff) |
Merge tag 'selinux-pr-20190917' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux
Pull selinux updates from Paul Moore:
- Add LSM hooks, and SELinux access control hooks, for dnotify,
fanotify, and inotify watches. This has been discussed with both the
LSM and fs/notify folks and everybody is good with these new hooks.
- The LSM stacking changes missed a few calls to current_security() in
the SELinux code; we fix those and remove current_security() for
good.
- Improve our network object labeling cache so that we always return
the object's label, even when under memory pressure. Previously we
would return an error if we couldn't allocate a new cache entry, now
we always return the label even if we can't create a new cache entry
for it.
- Convert the sidtab atomic_t counter to a normal u32 with
READ/WRITE_ONCE() and memory barrier protection.
- A few patches to policydb.c to clean things up (remove forward
declarations, long lines, bad variable names, etc)
* tag 'selinux-pr-20190917' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
lsm: remove current_security()
selinux: fix residual uses of current_security() for the SELinux blob
selinux: avoid atomic_t usage in sidtab
fanotify, inotify, dnotify, security: add security hook for fs notifications
selinux: always return a secid from the network caches if we find one
selinux: policydb - rename type_val_to_struct_array
selinux: policydb - fix some checkpatch.pl warnings
selinux: shuffle around policydb.c to get rid of forward declarations
Diffstat (limited to 'security/selinux/netif.c')
-rw-r--r-- | security/selinux/netif.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/security/selinux/netif.c b/security/selinux/netif.c index 9cb83eeee1d9..e40fecd73752 100644 --- a/security/selinux/netif.c +++ b/security/selinux/netif.c | |||
@@ -132,9 +132,9 @@ static void sel_netif_destroy(struct sel_netif *netif) | |||
132 | */ | 132 | */ |
133 | static int sel_netif_sid_slow(struct net *ns, int ifindex, u32 *sid) | 133 | static int sel_netif_sid_slow(struct net *ns, int ifindex, u32 *sid) |
134 | { | 134 | { |
135 | int ret; | 135 | int ret = 0; |
136 | struct sel_netif *netif; | 136 | struct sel_netif *netif; |
137 | struct sel_netif *new = NULL; | 137 | struct sel_netif *new; |
138 | struct net_device *dev; | 138 | struct net_device *dev; |
139 | 139 | ||
140 | /* NOTE: we always use init's network namespace since we don't | 140 | /* NOTE: we always use init's network namespace since we don't |
@@ -151,32 +151,27 @@ static int sel_netif_sid_slow(struct net *ns, int ifindex, u32 *sid) | |||
151 | netif = sel_netif_find(ns, ifindex); | 151 | netif = sel_netif_find(ns, ifindex); |
152 | if (netif != NULL) { | 152 | if (netif != NULL) { |
153 | *sid = netif->nsec.sid; | 153 | *sid = netif->nsec.sid; |
154 | ret = 0; | ||
155 | goto out; | 154 | goto out; |
156 | } | 155 | } |
157 | new = kzalloc(sizeof(*new), GFP_ATOMIC); | 156 | |
158 | if (new == NULL) { | 157 | ret = security_netif_sid(&selinux_state, dev->name, sid); |
159 | ret = -ENOMEM; | ||
160 | goto out; | ||
161 | } | ||
162 | ret = security_netif_sid(&selinux_state, dev->name, &new->nsec.sid); | ||
163 | if (ret != 0) | ||
164 | goto out; | ||
165 | new->nsec.ns = ns; | ||
166 | new->nsec.ifindex = ifindex; | ||
167 | ret = sel_netif_insert(new); | ||
168 | if (ret != 0) | 158 | if (ret != 0) |
169 | goto out; | 159 | goto out; |
170 | *sid = new->nsec.sid; | 160 | new = kzalloc(sizeof(*new), GFP_ATOMIC); |
161 | if (new) { | ||
162 | new->nsec.ns = ns; | ||
163 | new->nsec.ifindex = ifindex; | ||
164 | new->nsec.sid = *sid; | ||
165 | if (sel_netif_insert(new)) | ||
166 | kfree(new); | ||
167 | } | ||
171 | 168 | ||
172 | out: | 169 | out: |
173 | spin_unlock_bh(&sel_netif_lock); | 170 | spin_unlock_bh(&sel_netif_lock); |
174 | dev_put(dev); | 171 | dev_put(dev); |
175 | if (unlikely(ret)) { | 172 | if (unlikely(ret)) |
176 | pr_warn("SELinux: failure in %s(), unable to determine network interface label (%d)\n", | 173 | pr_warn("SELinux: failure in %s(), unable to determine network interface label (%d)\n", |
177 | __func__, ifindex); | 174 | __func__, ifindex); |
178 | kfree(new); | ||
179 | } | ||
180 | return ret; | 175 | return ret; |
181 | } | 176 | } |
182 | 177 | ||