Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1682861imu; Thu, 10 Jan 2019 00:55:34 -0800 (PST) X-Google-Smtp-Source: ALg8bN6VioO0vh1oUoJnkA39af50+h2CH2CbjVFL9Oj5SssKFiqRrxJslwSX/MMkL5v9uuhCQZIE X-Received: by 2002:a62:2b8b:: with SMTP id r133mr9350671pfr.246.1547110534275; Thu, 10 Jan 2019 00:55:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547110534; cv=none; d=google.com; s=arc-20160816; b=Ab6yDlSvmNiyfV4IpiveFJPgTYEXxs2BZAtBhg+PQTEbkhDZwRizPk1FBzKcF7TsOu 9qkFJ1Sw0O/1lvQuGLMIytt71oyAlJcjKAJK4F7JBCO/FdmWCvTDq+bhxYhLhZ6VNmiv /Occ7hKC3qk6VD56J98LSnWP0Y3xY5T4Vl2Tey6EK+yA5Zryrwk0NntiZjI3a9Hdpp30 I8klrYqGi7ryoYSocstz9OzdNN4iKxDcQ1CCkbMHlkjrfHzINKMwT8leemKRXRqrqWTj F7NWNtpO7dGheBmQplDutrwtnt0McQssUv3aWZJH2NgE41rnR1ieBQAc/8vEUGCosbYb pM5g== 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=PKvyPcnXWbp2n40FSUxLn2TdMlFjo3RNViM3jvAdEec=; b=FpJg31hpydsk/C9XUcgWG2tI5p0+p3aWTuXTwJ6ox6X7FM+Hz3aXWl1M1Xs6eaenSv Fe65RnlnLo7VCM1/2fB5RIy9jmmtevgpGfZhB3HfqQn1jAA6OfOMiAgLtlTfhK21q5xe kERARtugkNbM7XlBVieLhz1vlQmQJ4ZZ4EXpsX10vMKXAMaggi2oT4riSI9l7eiVJaIS jE2e6Tr2gsNY3HghLJkcTm+kjOK54MBKmylJSgvZ59U8WR4joZtskGwrGz4o4/2FAnp5 AdEAqHnRUGyzqLbPMO8HRImm1FErIPWZhLBBxck1/xuud8cyvoAZoyEtvNi/YsgTFU/V m9Kw== 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 o6si21616205plh.23.2019.01.10.00.55.18; Thu, 10 Jan 2019 00:55:34 -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 S1727675AbfAJIyM (ORCPT + 99 others); Thu, 10 Jan 2019 03:54:12 -0500 Received: from relay.sw.ru ([185.231.240.75]:53434 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727547AbfAJIyM (ORCPT ); Thu, 10 Jan 2019 03:54:12 -0500 Received: from [172.16.25.169] by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1ghW6D-0002nj-Jp; Thu, 10 Jan 2019 11:54:01 +0300 Subject: Re: [PATCH] ipset: fix a missing check of nla_parse To: Pablo Neira Ayuso Cc: Kangjie Lu , pakki001@umn.edu, 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> <20190109224335.qe6f4x4722qz6x5p@salvia> From: Kirill Tkhai Message-ID: <298cbd2a-06fd-39c1-7d5f-5adcf21b68b2@virtuozzo.com> Date: Thu, 10 Jan 2019 11:54:01 +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: <20190109224335.qe6f4x4722qz6x5p@salvia> 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 10.01.2019 01:43, Pablo Neira Ayuso wrote: > On Wed, Dec 26, 2018 at 12:16:25PM +0300, Kirill Tkhai wrote: >> 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); > > @Kangjie: nitpick, could you align this line below? ie. > > 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. > > netlink_unicast() is responsible for releasing this skb2. We return earlier at "if (ret)", so netlink_unicast() is not called. >>> errline = nla_data(cda[IPSET_ATTR_LINENO]); Kirill