Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752651AbdLAHKS (ORCPT ); Fri, 1 Dec 2017 02:10:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43020 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751955AbdLAHKQ (ORCPT ); Fri, 1 Dec 2017 02:10:16 -0500 Subject: Re: [PATCH 3/3] tap: free skb if flags error To: wexu@redhat.com, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: mst@redhat.com, mjrosato@linux.vnet.ibm.com References: <1512107669-27572-1-git-send-email-wexu@redhat.com> <1512107669-27572-4-git-send-email-wexu@redhat.com> From: Jason Wang Message-ID: <91944888-b8be-7b4e-4a26-1d8c9738e5d6@redhat.com> Date: Fri, 1 Dec 2017 15:10:08 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <1512107669-27572-4-git-send-email-wexu@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 01 Dec 2017 07:10:16 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1229 Lines: 40 On 2017年12月01日 13:54, wexu@redhat.com wrote: > From: Wei Xu > > tap_recvmsg() supports accepting skb by msg_control after > commit 3b4ba04acca8 ("tap: support receiving skb from msg_control"), > the skb if presented should be freed within the function, otherwise > it would be leaked. > > Signed-off-by: Wei Xu > Reported-by: Matthew Rosato > --- > drivers/net/tap.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/tap.c b/drivers/net/tap.c > index e9489b8..1c66b75 100644 > --- a/drivers/net/tap.c > +++ b/drivers/net/tap.c > @@ -1154,9 +1154,13 @@ static int tap_recvmsg(struct socket *sock, struct msghdr *m, > size_t total_len, int flags) > { > struct tap_queue *q = container_of(sock, struct tap_queue, sock); > + struct sk_buff *skb = m->msg_control; > int ret; > - if (flags & ~(MSG_DONTWAIT|MSG_TRUNC)) > + if (flags & ~(MSG_DONTWAIT|MSG_TRUNC)) { > + if (skb) > + kfree_skb(skb); > return -EINVAL; > + } > ret = tap_do_read(q, &m->msg_iter, flags & MSG_DONTWAIT, > m->msg_control); Need to deal with iov_iterator_count() == 0. Thanks > if (ret > total_len) {