summaryrefslogtreecommitdiffstats
path: root/security/selinux/netif.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/selinux/netif.c')
-rw-r--r--security/selinux/netif.c31
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 */
133static int sel_netif_sid_slow(struct net *ns, int ifindex, u32 *sid) 133static 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
172out: 169out:
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