Skip to content

Commit 75cb070

Browse files
edumazetdavem330
authored andcommitted
Revert "net: defer call to cgroup_sk_alloc()"
This reverts commit fbb1fb4. This was not the proper fix, lets cleanly revert it, so that following patch can be carried to stable versions. sock_cgroup_ptr() callers do not expect a NULL return value. Signed-off-by: Eric Dumazet <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Tejun Heo <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent befc7a3 commit 75cb070

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

kernel/cgroup/cgroup.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5709,6 +5709,17 @@ void cgroup_sk_alloc(struct sock_cgroup_data *skcd)
57095709
if (cgroup_sk_alloc_disabled)
57105710
return;
57115711

5712+
/* Socket clone path */
5713+
if (skcd->val) {
5714+
/*
5715+
* We might be cloning a socket which is left in an empty
5716+
* cgroup and the cgroup might have already been rmdir'd.
5717+
* Don't use cgroup_get_live().
5718+
*/
5719+
cgroup_get(sock_cgroup_ptr(skcd));
5720+
return;
5721+
}
5722+
57125723
rcu_read_lock();
57135724

57145725
while (true) {

net/core/sock.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1680,7 +1680,6 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
16801680

16811681
/* sk->sk_memcg will be populated at accept() time */
16821682
newsk->sk_memcg = NULL;
1683-
memset(&newsk->sk_cgrp_data, 0, sizeof(newsk->sk_cgrp_data));
16841683

16851684
atomic_set(&newsk->sk_drops, 0);
16861685
newsk->sk_send_head = NULL;
@@ -1719,6 +1718,8 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
17191718
newsk->sk_incoming_cpu = raw_smp_processor_id();
17201719
atomic64_set(&newsk->sk_cookie, 0);
17211720

1721+
cgroup_sk_alloc(&newsk->sk_cgrp_data);
1722+
17221723
/*
17231724
* Before updating sk_refcnt, we must commit prior changes to memory
17241725
* (Documentation/RCU/rculist_nulls.txt for details)

net/ipv4/inet_connection_sock.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
#include <net/tcp.h>
2727
#include <net/sock_reuseport.h>
2828
#include <net/addrconf.h>
29-
#include <net/cls_cgroup.h>
30-
#include <net/netprio_cgroup.h>
3129

3230
#ifdef INET_CSK_DEBUG
3331
const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
@@ -478,9 +476,6 @@ struct sock *inet_csk_accept(struct sock *sk, int flags, int *err, bool kern)
478476
spin_unlock_bh(&queue->fastopenq.lock);
479477
}
480478
mem_cgroup_sk_alloc(newsk);
481-
cgroup_sk_alloc(&newsk->sk_cgrp_data);
482-
sock_update_classid(&newsk->sk_cgrp_data);
483-
sock_update_netprioidx(&newsk->sk_cgrp_data);
484479
out:
485480
release_sock(sk);
486481
if (req)

0 commit comments

Comments
 (0)