From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Ricardo Leitner Date: Mon, 26 Nov 2018 12:04:18 +0000 Subject: Re: [PATCH net] sctp: increase sk_wmem_alloc when head->truesize is increased Message-Id: <20181126120418.GH3601@localhost.localdomain> List-Id: References: <4989c666f6077526983b02615cad001748d2e658.1543215164.git.lucien.xin@gmail.com> In-Reply-To: <4989c666f6077526983b02615cad001748d2e658.1543215164.git.lucien.xin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Xin Long Cc: network dev , linux-sctp@vger.kernel.org, davem@davemloft.net, Neil Horman On Mon, Nov 26, 2018 at 02:52:44PM +0800, Xin Long wrote: > I changed to count sk_wmem_alloc by skb truesize instead of 1 to > fix the sk_wmem_alloc leak caused by later truesize's change in > xfrm in Commit 02968ccf0125 ("sctp: count sk_wmem_alloc by skb > truesize in sctp_packet_transmit"). > > But I should have also increased sk_wmem_alloc when head->truesize > is increased in sctp_packet_gso_append() as xfrm does. Otherwise, > sctp gso packet will cause sk_wmem_alloc underflow. > > Fixes: 02968ccf0125 ("sctp: count sk_wmem_alloc by skb truesize in sctp_packet_transmit") > Signed-off-by: Xin Long Acked-by: Marcelo Ricardo Leitner > --- > net/sctp/output.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/net/sctp/output.c b/net/sctp/output.c > index b0e74a3..025f48e 100644 > --- a/net/sctp/output.c > +++ b/net/sctp/output.c > @@ -410,6 +410,7 @@ static void sctp_packet_gso_append(struct sk_buff *head, struct sk_buff *skb) > head->truesize += skb->truesize; > head->data_len += skb->len; > head->len += skb->len; > + refcount_add(skb->truesize, &head->sk->sk_wmem_alloc); > > __skb_header_release(skb); > } > -- > 2.1.0 > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Ricardo Leitner Subject: Re: [PATCH net] sctp: increase sk_wmem_alloc when head->truesize is increased Date: Mon, 26 Nov 2018 10:04:18 -0200 Message-ID: <20181126120418.GH3601@localhost.localdomain> References: <4989c666f6077526983b02615cad001748d2e658.1543215164.git.lucien.xin@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: network dev , linux-sctp@vger.kernel.org, davem@davemloft.net, Neil Horman To: Xin Long Return-path: Received: from mail-qt1-f196.google.com ([209.85.160.196]:41358 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726199AbeKZW6T (ORCPT ); Mon, 26 Nov 2018 17:58:19 -0500 Content-Disposition: inline In-Reply-To: <4989c666f6077526983b02615cad001748d2e658.1543215164.git.lucien.xin@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: On Mon, Nov 26, 2018 at 02:52:44PM +0800, Xin Long wrote: > I changed to count sk_wmem_alloc by skb truesize instead of 1 to > fix the sk_wmem_alloc leak caused by later truesize's change in > xfrm in Commit 02968ccf0125 ("sctp: count sk_wmem_alloc by skb > truesize in sctp_packet_transmit"). > > But I should have also increased sk_wmem_alloc when head->truesize > is increased in sctp_packet_gso_append() as xfrm does. Otherwise, > sctp gso packet will cause sk_wmem_alloc underflow. > > Fixes: 02968ccf0125 ("sctp: count sk_wmem_alloc by skb truesize in sctp_packet_transmit") > Signed-off-by: Xin Long Acked-by: Marcelo Ricardo Leitner > --- > net/sctp/output.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/net/sctp/output.c b/net/sctp/output.c > index b0e74a3..025f48e 100644 > --- a/net/sctp/output.c > +++ b/net/sctp/output.c > @@ -410,6 +410,7 @@ static void sctp_packet_gso_append(struct sk_buff *head, struct sk_buff *skb) > head->truesize += skb->truesize; > head->data_len += skb->len; > head->len += skb->len; > + refcount_add(skb->truesize, &head->sk->sk_wmem_alloc); > > __skb_header_release(skb); > } > -- > 2.1.0 >