* [net-next RFC v2 1/9] net: Make cgroup sk data present when calling security_sk_(alloc/free)
@ 2016-08-29 11:45 Sargun Dhillon
0 siblings, 0 replies; only message in thread
From: Sargun Dhillon @ 2016-08-29 11:45 UTC (permalink / raw)
To: netdev; +Cc: cgroups, linux-security-module, daniel, ast
This patch changes the order of allocations / calls to allocate the
sock_cgroup_data before calling security_sk_alloc. In addition, this
patch also reorders the deallocation when calling security_sk_free
so that LSMs can examine the cgroup that a particular sk belongs to.
Signed-off-by: Sarguun Dhillon <sargun@sargun.me>
---
net/core/sock.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/core/sock.c b/net/core/sock.c
index 51a7304..3f12f4d 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1333,6 +1333,7 @@ static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,
if (sk != NULL) {
kmemcheck_annotate_bitfield(sk, flags);
+ cgroup_sk_alloc(&sk->sk_cgrp_data);
if (security_sk_alloc(sk, family, priority))
goto out_free;
@@ -1340,7 +1341,6 @@ static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,
if (!try_module_get(prot->owner))
goto out_free_sec;
sk_tx_queue_clear(sk);
- cgroup_sk_alloc(&sk->sk_cgrp_data);
}
return sk;
@@ -1348,6 +1348,7 @@ static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,
out_free_sec:
security_sk_free(sk);
out_free:
+ cgroup_sk_free(&sk->sk_cgrp_data);
if (slab != NULL)
kmem_cache_free(slab, sk);
else
@@ -1363,8 +1364,8 @@ static void sk_prot_free(struct proto *prot, struct sock *sk)
owner = prot->owner;
slab = prot->slab;
- cgroup_sk_free(&sk->sk_cgrp_data);
security_sk_free(sk);
+ cgroup_sk_free(&sk->sk_cgrp_data);
if (slab != NULL)
kmem_cache_free(slab, sk);
else
--
2.7.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-08-29 11:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-29 11:45 [net-next RFC v2 1/9] net: Make cgroup sk data present when calling security_sk_(alloc/free) Sargun Dhillon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).