aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
Diffstat (limited to 'security')
-rw-r--r--security/selinux/hooks.c45
1 files changed, 17 insertions, 28 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 2d94a406574e..01f52424cfe5 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -279,32 +279,6 @@ static void superblock_free_security(struct super_block *sb)
279 kfree(sbsec); 279 kfree(sbsec);
280} 280}
281 281
282static int sk_alloc_security(struct sock *sk, int family, gfp_t priority)
283{
284 struct sk_security_struct *sksec;
285
286 sksec = kzalloc(sizeof(*sksec), priority);
287 if (!sksec)
288 return -ENOMEM;
289
290 sksec->peer_sid = SECINITSID_UNLABELED;
291 sksec->sid = SECINITSID_UNLABELED;
292 sk->sk_security = sksec;
293
294 selinux_netlbl_sk_security_reset(sksec);
295
296 return 0;
297}
298
299static void sk_free_security(struct sock *sk)
300{
301 struct sk_security_struct *sksec = sk->sk_security;
302
303 sk->sk_security = NULL;
304 selinux_netlbl_sk_security_free(sksec);
305 kfree(sksec);
306}
307
308/* The security server must be initialized before 282/* The security server must be initialized before
309 any labeling or access decisions can be provided. */ 283 any labeling or access decisions can be provided. */
310extern int ss_initialized; 284extern int ss_initialized;
@@ -4224,12 +4198,27 @@ out:
4224 4198
4225static int selinux_sk_alloc_security(struct sock *sk, int family, gfp_t priority) 4199static int selinux_sk_alloc_security(struct sock *sk, int family, gfp_t priority)
4226{ 4200{
4227 return sk_alloc_security(sk, family, priority); 4201 struct sk_security_struct *sksec;
4202
4203 sksec = kzalloc(sizeof(*sksec), priority);
4204 if (!sksec)
4205 return -ENOMEM;
4206
4207 sksec->peer_sid = SECINITSID_UNLABELED;
4208 sksec->sid = SECINITSID_UNLABELED;
4209 selinux_netlbl_sk_security_reset(sksec);
4210 sk->sk_security = sksec;
4211
4212 return 0;
4228} 4213}
4229 4214
4230static void selinux_sk_free_security(struct sock *sk) 4215static void selinux_sk_free_security(struct sock *sk)
4231{ 4216{
4232 sk_free_security(sk); 4217 struct sk_security_struct *sksec = sk->sk_security;
4218
4219 sk->sk_security = NULL;
4220 selinux_netlbl_sk_security_free(sksec);
4221 kfree(sksec);
4233} 4222}
4234 4223
4235static void selinux_sk_clone_security(const struct sock *sk, struct sock *newsk) 4224static void selinux_sk_clone_security(const struct sock *sk, struct sock *newsk)