netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] sctp: fix refcount bug in sctp_wfree
@ 2020-03-17 15:55 Qiujun Huang
  2020-03-17 17:30 ` Marcelo Ricardo Leitner
  0 siblings, 1 reply; 7+ messages in thread
From: Qiujun Huang @ 2020-03-17 15:55 UTC (permalink / raw)
  To: marcelo.leitner, davem
  Cc: vyasevich, nhorman, kuba, linux-sctp, netdev, linux-kernel,
	anenbupt, Qiujun Huang

Do accounting for skb's real sk.
In some case skb->sk != asoc->base.sk:

migrate routing        sctp_check_transmitted routing
------------                    ---------------
lock_sock_nested();
                               mv the transmitted skb to
                               the it's local tlist

sctp_for_each_tx_datachunk(
sctp_clear_owner_w);
sctp_assoc_migrate();
sctp_for_each_tx_datachunk(
sctp_set_owner_w);

                               put the skb back to the
                               assoc lists
----------------------------------------------------

The skbs which held bysctp_check_transmitted were not changed
to newsk. They were not dealt with by sctp_for_each_tx_datachunk
(sctp_clear_owner_w/sctp_set_owner_w).

It looks only trouble here so handling it in sctp_wfree is enough.

Reported-and-tested-by: syzbot+cea71eec5d6de256d54d@syzkaller.appspotmail.com
Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
---
 net/sctp/socket.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 1b56fc440606..5f5c28b30e25 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -9080,7 +9080,7 @@ static void sctp_wfree(struct sk_buff *skb)
 {
 	struct sctp_chunk *chunk = skb_shinfo(skb)->destructor_arg;
 	struct sctp_association *asoc = chunk->asoc;
-	struct sock *sk = asoc->base.sk;
+	struct sock *sk = skb->sk;
 
 	sk_mem_uncharge(sk, skb->truesize);
 	sk->sk_wmem_queued -= skb->truesize + sizeof(struct sctp_chunk);
@@ -9109,7 +9109,7 @@ static void sctp_wfree(struct sk_buff *skb)
 	}
 
 	sock_wfree(skb);
-	sctp_wake_up_waiters(sk, asoc);
+	sctp_wake_up_waiters(asoc->base.sk, asoc);
 
 	sctp_association_put(asoc);
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-03-18  4:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-17 15:55 [PATCH v2] sctp: fix refcount bug in sctp_wfree Qiujun Huang
2020-03-17 17:30 ` Marcelo Ricardo Leitner
2020-03-18  2:45   ` Qiujun Huang
2020-03-18  3:55     ` Marcelo Ricardo Leitner
2020-03-18  4:07       ` Qiujun Huang
2020-03-18  4:09         ` Qiujun Huang
2020-03-18  4:22         ` Qiujun Huang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).