mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-31 04:01:48 -04:00
net: memcontrol: defer call to mem_cgroup_sk_alloc()
Instead of calling mem_cgroup_sk_alloc() from BH context,
it is better to call it from inet_csk_accept() in process context.
Not only this removes code in mem_cgroup_sk_alloc(), but it also
fixes a bug since listener might have been dismantled and css_get()
might cause a use-after-free.
Fixes: e994b2f0fb ("tcp: do not lock listener to process SYN packets")
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]>
This commit is contained in:
parent
529a86e063
commit
9f1c2674b3
3 changed files with 5 additions and 16 deletions
|
|
@ -5828,21 +5828,6 @@ void mem_cgroup_sk_alloc(struct sock *sk)
|
|||
if (!mem_cgroup_sockets_enabled)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Socket cloning can throw us here with sk_memcg already
|
||||
* filled. It won't however, necessarily happen from
|
||||
* process context. So the test for root memcg given
|
||||
* the current task's memcg won't help us in this case.
|
||||
*
|
||||
* Respecting the original socket's memcg is a better
|
||||
* decision in this case.
|
||||
*/
|
||||
if (sk->sk_memcg) {
|
||||
BUG_ON(mem_cgroup_is_root(sk->sk_memcg));
|
||||
css_get(&sk->sk_memcg->css);
|
||||
return;
|
||||
}
|
||||
|
||||
rcu_read_lock();
|
||||
memcg = mem_cgroup_from_task(current);
|
||||
if (memcg == root_mem_cgroup)
|
||||
|
|
|
|||
Loading…
Reference in a new issue