From: John Fastabend Subject: Re: [PATCH bpf 2/2] bpf, sockmap: fix psock refcount leak in bpf_tcp_recvmsg Date: Fri, 24 Aug 2018 17:29:51 -0700 Message-ID: <5677fb82-f248-894a-5214-466b725710bd@gmail.com> References: <20180824200851.12308-1-daniel@iogearbox.net> <20180824200851.12308-3-daniel@iogearbox.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org To: Daniel Borkmann , alexei.starovoitov@gmail.com Return-path: Received: from mail-io0-f196.google.com ([209.85.223.196]:35113 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725936AbeHYEG4 (ORCPT ); Sat, 25 Aug 2018 00:06:56 -0400 Received: by mail-io0-f196.google.com with SMTP id w11-v6so8532765iob.2 for ; Fri, 24 Aug 2018 17:30:01 -0700 (PDT) In-Reply-To: <20180824200851.12308-3-daniel@iogearbox.net> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 08/24/2018 01:08 PM, Daniel Borkmann wrote: > In bpf_tcp_recvmsg() we first took a reference on the psock, however > once we find that there are skbs in the normal socket's receive queue > we return with processing them through tcp_recvmsg(). Problem is that > we leak the taken reference on the psock in that path. Given we don't > really do anything with the psock at this point, move the skb_queue_empty() > test before we fetch the psock to fix this case. > > Fixes: 8934ce2fd081 ("bpf: sockmap redirect ingress support") > Signed-off-by: Daniel Borkmann > --- Oops. Thanks for catching this, all of our use cases and tests to this point either always did redirect or normal receive and I missed the mixed case. I'll write a tests for bpf-next to also ensure we catch anything else. Thanks. Acked-by: John Fastabend