Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5366280imu; Wed, 26 Dec 2018 01:18:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN4WnEt1aIzn8SoPOHGMtHLBwka0uDTtf8k9A+7xTLyMAvgXkmuxlcRgk1c+RSd38D9nuQO9 X-Received: by 2002:a63:e21:: with SMTP id d33mr18251002pgl.272.1545815923854; Wed, 26 Dec 2018 01:18:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545815923; cv=none; d=google.com; s=arc-20160816; b=xQPdbMGyJ3QlLf008+f4UT9a78aPxDFO9xBpUyvQHGS/0yFKH+xjmv+hKECyzECMqM i9LY96amwQs54igXXuGCbqXMbX80QW0RJBRexQG/kL0sNlvwIELIuXholHkxYNp81Xrs CNQB9+iTRw6OA2Rr6yhTOWXhS3xfjtZtQ0dJtVHNxrdP4BEejmZkbgkpi4t/Q8if3CrT txN8qrUOKz4uzemeHxcFeb99XHEgE3XP7m105e+LUPdUdrArWQXwhwsH/SlJQkPOgcTZ YbcpCyk9jejk+BiadKwZAN2gP6154kkycxAd6u12tFYq4IR2NlJ/8EM12QpVZUFkJHac rSFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=zp03sCqZwjNBplenMxyl0CclBC9bgvZW6y0XtbcwOnI=; b=VpxOVd7n9icBG4DAPV+DC3iYU9ioYH8BUphMoxyNDJy6TRW2mpPs2jNPGomFX0VC2W D/+fLQf+mYDjZK/0dLYxkjdtwKFc7dgWqOA8+Cl1sjKRdmb0ll5iCdFWgN2vEWhWqWHg Y/bBCKYJBgaJmbhRHEo9AT2dAmC6JZRbZY5z/OsaW9+XRvrFCfZl4hym4lSxptHEvWVE 6aafyheix9MNzbaYRo5rFYNMCgHJJgjNg6TgHrvATB1gyiuHGgmzyOCdZitpNeTf37a4 7IPtXIw3qeoNnceRfiJZOLAc2M6keSaTIx8hCXFRJxOS9D+DPyT2m6UkMGMVjhDA9ocI jMBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a1si31643140pgk.495.2018.12.26.01.18.29; Wed, 26 Dec 2018 01:18:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726434AbeLZJQi (ORCPT + 99 others); Wed, 26 Dec 2018 04:16:38 -0500 Received: from relay.sw.ru ([185.231.240.75]:56970 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726013AbeLZJQi (ORCPT ); Wed, 26 Dec 2018 04:16:38 -0500 Received: from [172.16.25.169] by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1gc5Ig-0003Jm-BO; Wed, 26 Dec 2018 12:16:26 +0300 Subject: Re: [PATCH] ipset: fix a missing check of nla_parse To: Kangjie Lu Cc: pakki001@umn.edu, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" , Stefano Brivio , Andrey Ryabinin , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20181226035002.73614-1-kjlu@umn.edu> From: Kirill Tkhai Message-ID: Date: Wed, 26 Dec 2018 12:16:25 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: <20181226035002.73614-1-kjlu@umn.edu> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26.12.2018 06:50, Kangjie Lu wrote: > When nla_parse fails, we should not use the results (the first > argument). The fix checks if it fails, and if so, returns its error code > upstream. > > Signed-off-by: Kangjie Lu > --- > net/netfilter/ipset/ip_set_core.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c > index 1577f2f76060..4dc8057cff02 100644 > --- a/net/netfilter/ipset/ip_set_core.c > +++ b/net/netfilter/ipset/ip_set_core.c > @@ -1531,8 +1531,10 @@ call_ad(struct sock *ctnl, struct sk_buff *skb, struct ip_set *set, > memcpy(&errmsg->msg, nlh, nlh->nlmsg_len); > cmdattr = (void *)&errmsg->msg + min_len; > > - nla_parse(cda, IPSET_ATTR_CMD_MAX, cmdattr, > + ret = nla_parse(cda, IPSET_ATTR_CMD_MAX, cmdattr, > nlh->nlmsg_len - min_len, ip_set_adt_policy, NULL); > + if (ret) > + return ret; In this function above nlmsg_new() allocates skb2, but I don't see, where you free it here. > > errline = nla_data(cda[IPSET_ATTR_LINENO]); > >