From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [bpf PATCH 1/3] bpf: sockmap, fix scatterlist update on error path in send with apply Date: Wed, 02 May 2018 14:51:35 -0400 (EDT) Message-ID: <20180502.145135.1718538578227838037.davem@davemloft.net> References: <20180502173954.17875.19624.stgit@john-Precision-Tower-5810> <20180502174727.17875.95306.stgit@john-Precision-Tower-5810> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: borkmann@iogearbox.net, ast@kernel.org, netdev@vger.kernel.org To: john.fastabend@gmail.com Return-path: Received: from shards.monkeyblade.net ([184.105.139.130]:36098 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750970AbeEBSvj (ORCPT ); Wed, 2 May 2018 14:51:39 -0400 In-Reply-To: <20180502174727.17875.95306.stgit@john-Precision-Tower-5810> Sender: netdev-owner@vger.kernel.org List-ID: From: John Fastabend Date: Wed, 02 May 2018 10:47:27 -0700 > When the call to do_tcp_sendpage() fails to send the complete block > requested we either retry if only a partial send was completed or > abort if we receive a error less than or equal to zero. Before > returning though we must update the scatterlist length/offset to > account for any partial send completed. > > Before this patch we did this at the end of the retry loop, but > this was buggy when used while applying a verdict to fewer bytes > than in the scatterlist. When the scatterlist length was being set > we forgot to account for the apply logic reducing the size variable. > So the result was we chopped off some bytes in the scatterlist without > doing proper cleanup on them. This results in a WARNING when the > sock is tore down because the bytes have previously been charged to > the socket but are never uncharged. > > The simple fix is to simply do the accounting inside the retry loop > subtracting from the absolute scatterlist values rather than trying > to accumulate the totals and subtract at the end. > > Reported-by: Alexei Starovoitov > Signed-off-by: John Fastabend Acked-by: David S. Miller