From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Abeni Subject: Re: [PATCH net] kcm: fix races on sk_receive_queue Date: Fri, 08 Jun 2018 18:25:58 +0200 Message-ID: <31934bf4ccf0f28c74266f9da72b9f2da21a7eff.camel@redhat.com> References: <628e0398546aefabd68669450621909d269e1ba8.1528289745.git.pabeni@redhat.com> <20180608.105311.1644703021787191738.davem@davemloft.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, tom@quantonium.net, ktkhai@virtuozzo.com To: David Miller Return-path: Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40010 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751141AbeFHQ0B (ORCPT ); Fri, 8 Jun 2018 12:26:01 -0400 In-Reply-To: <20180608.105311.1644703021787191738.davem@davemloft.net> Sender: netdev-owner@vger.kernel.org List-ID: On Fri, 2018-06-08 at 10:53 -0400, David Miller wrote: > From: Paolo Abeni > Date: Wed, 6 Jun 2018 15:16:29 +0200 > > > @@ -1126,7 +1132,7 @@ static int kcm_recvmsg(struct socket *sock, struct msghdr *msg, > > > > lock_sock(sk); > > > > - skb = kcm_wait_data(sk, flags, timeo, &err); > > + skb = kcm_wait_data(sk, flags, peek, timeo, &err); > > if (!skb) > > goto out; > > > > Because kcm_wait_data() potentially unlinks now, you will have to kfree the > SKB in the error paths, for example if skb_copy_datagram_msg() fails. > > Otherwise we have an SKB leak. Right. But now I fear the fix should be different: if we drop the skb on skb_copy_datagram_msg() error, that will cause a behavior change. I need to think more for a proper fix. Thank you for the feedback. Paolo