cgroup: duplicate cgroup reference when cloning sockets

When a socket is cloned, the associated sock_cgroup_data is duplicated
but not its reference on the cgroup.  As a result, the cgroup reference
count will underflow when both sockets are destroyed later on.

Fixes: bd1060a1d671 ("sock, cgroup: add sock->sk_cgroup")
Signed-off-by: Johannes Weiner <>
Acked-by: Tejun Heo <>
Cc: Michal Hocko <>
Cc: Vladimir Davydov <>
Cc: <>	[4.5+]
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
2 files changed