]> git.baikalelectronics.ru Git - kernel.git/commit
sctp: count sk_wmem_alloc by skb truesize in sctp_packet_transmit
authorXin Long <lucien.xin@gmail.com>
Sun, 18 Nov 2018 07:07:38 +0000 (15:07 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 19 Nov 2018 20:39:05 +0000 (12:39 -0800)
commitd04f493925417d9a6f750143106c8831efc33052
treece9c31025aa5c8c06708ac3c527a1a8ea4ff4d0a
parent4a12e3c743aefebcef7704507d77fa7ae9404780
sctp: count sk_wmem_alloc by skb truesize in sctp_packet_transmit

Now sctp increases sk_wmem_alloc by 1 when doing set_owner_w for the
skb allocked in sctp_packet_transmit and decreases by 1 when freeing
this skb.

But when this skb goes through networking stack, some subcomponents
might change skb->truesize and add the same amount on sk_wmem_alloc.
However sctp doesn't know the amount to decrease by, it would cause
a leak on sk->sk_wmem_alloc and the sock can never be freed.

Xiumei found this issue when it hit esp_output_head() by using sctp
over ipsec, where skb->truesize is added and so is sk->sk_wmem_alloc.

Since sctp has used sk_wmem_queued to count for writable space since
Commit cb47704ae9e7 ("sctp: use sk_wmem_queued to check for writable
space"), it's ok to fix it by counting sk_wmem_alloc by skb truesize
in sctp_packet_transmit.

Fixes: 656a76ddd6dc ("esp4: Avoid skb_cow_data whenever possible")
Reported-by: Xiumei Mu <xmu@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/output.c