From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [PATCH net] sctp: count sk_wmem_alloc by skb truesize in sctp_packet_transmit Date: Mon, 19 Nov 2018 12:39:55 -0800 (PST) Message-ID: <20181119.123955.865697238943438515.davem@davemloft.net> References: Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, linux-sctp@vger.kernel.org, marcelo.leitner@gmail.com, nhorman@tuxdriver.com To: lucien.xin@gmail.com Return-path: Received: from shards.monkeyblade.net ([23.128.96.9]:50218 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728938AbeKTHFR (ORCPT ); Tue, 20 Nov 2018 02:05:17 -0500 In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: From: Xin Long Date: Sun, 18 Nov 2018 15:07:38 +0800 > 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 cd305c74b0f8 ("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: cac2661c53f3 ("esp4: Avoid skb_cow_data whenever possible") > Reported-by: Xiumei Mu > Signed-off-by: Xin Long Applied and queued up for -stable.