mirror of
https://github.com/torvalds/linux.git
synced 2026-06-06 13:37:36 +02:00
sock: fix /proc/net/sockstat underflow in sk_clone_lock()
[ Upstream commit938cca9e41] sk_clone_lock() needs to call sock_inuse_add(1) before entering the sk_free_unlock_clone() error path, for __sk_free() from sk_free() from sk_free_unlock_clone() calls sock_inuse_add(-1). Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Fixes:648845ab7e("sock: Move the socket inuse to namespace.") Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
4da14ddad1
commit
437e21e2c9
|
|
@ -1896,8 +1896,10 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
|
||||||
newsk->sk_prot_creator = prot;
|
newsk->sk_prot_creator = prot;
|
||||||
|
|
||||||
/* SANITY */
|
/* SANITY */
|
||||||
if (likely(newsk->sk_net_refcnt))
|
if (likely(newsk->sk_net_refcnt)) {
|
||||||
get_net(sock_net(newsk));
|
get_net(sock_net(newsk));
|
||||||
|
sock_inuse_add(sock_net(newsk), 1);
|
||||||
|
}
|
||||||
sk_node_init(&newsk->sk_node);
|
sk_node_init(&newsk->sk_node);
|
||||||
sock_lock_init(newsk);
|
sock_lock_init(newsk);
|
||||||
bh_lock_sock(newsk);
|
bh_lock_sock(newsk);
|
||||||
|
|
@ -1968,8 +1970,6 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
|
||||||
newsk->sk_err_soft = 0;
|
newsk->sk_err_soft = 0;
|
||||||
newsk->sk_priority = 0;
|
newsk->sk_priority = 0;
|
||||||
newsk->sk_incoming_cpu = raw_smp_processor_id();
|
newsk->sk_incoming_cpu = raw_smp_processor_id();
|
||||||
if (likely(newsk->sk_net_refcnt))
|
|
||||||
sock_inuse_add(sock_net(newsk), 1);
|
|
||||||
|
|
||||||
/* Before updating sk_refcnt, we must commit prior changes to memory
|
/* Before updating sk_refcnt, we must commit prior changes to memory
|
||||||
* (Documentation/RCU/rculist_nulls.rst for details)
|
* (Documentation/RCU/rculist_nulls.rst for details)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user