Skip to content

Commit

Permalink
Merge branch 'rds-tcp-sock_graft-leak'
Browse files Browse the repository at this point in the history
Sowmini Varadhan says:

====================
rds-tcp: sock_graft() leak

Following up on the discussion at
  https://www.spinics.net/lists/netdev/msg442859.html
- make rds_tcp_accept_one() call sock_create_lite()
- add a WARN_ON() to sock_graft()

Tested by running an infinite while() loop that does
(module-load; rds-stress; module-unload) and monitors
TCP slabinfo while the test is running.
====================

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Jul 8, 2017
2 parents 9dc351d + 0ffdaf5 commit 5dc314f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/net/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -1697,6 +1697,7 @@ static inline void sock_orphan(struct sock *sk)

static inline void sock_graft(struct sock *sk, struct socket *parent)
{
WARN_ON(parent->sk);
write_lock_bh(&sk->sk_callback_lock);
sk->sk_wq = parent->wq;
parent->sk = sk;
Expand Down
2 changes: 1 addition & 1 deletion net/rds/tcp_listen.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ int rds_tcp_accept_one(struct socket *sock)
if (!sock) /* module unload or netns delete in progress */
return -ENETUNREACH;

ret = sock_create_kern(sock_net(sock->sk), sock->sk->sk_family,
ret = sock_create_lite(sock->sk->sk_family,
sock->sk->sk_type, sock->sk->sk_protocol,
&new_sock);
if (ret)
Expand Down

0 comments on commit 5dc314f

Please sign in to comment.