Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5024160ybl; Tue, 14 Jan 2020 02:09:56 -0800 (PST) X-Google-Smtp-Source: APXvYqyJdm10p2SjUmlsdAHzQL2EZIZyluSWcdLXLrgLkTfwdFAR1lubhXpTYVkONFgRsPLeSG3B X-Received: by 2002:a05:6830:1d59:: with SMTP id p25mr16964270oth.308.1578996596105; Tue, 14 Jan 2020 02:09:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578996596; cv=none; d=google.com; s=arc-20160816; b=MfBxTFGGQIWAWE5yTTy88Xv36Rybn1v44OYMZeaNJAGXWJNg7QPqYxBn7gpsJhPllL R487A5l3Q89SbosEiLqMi25MAMQLhfNtnlADYN4EFkfDTZiVdBJxXe4YA5i4ijrasUyp Gwfci566QaNoV4oDUcdT7Pg1WI+f+C1o23wU6xIi5DWusKeJC7ATFRGH0BH+AypTMmdk TTu2dzB1sPEI01lbuh27ccai7cq4Z/nUTI71l+vp+o39mGUmOxut6Dg40FUJKi6wrqNM 44hhjbGLf/kBNuVhsiS5BohCND7eWwcuDAtaEbqHVMNokVijCt7xENXVJi/gYT0JoSF0 GkYw== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fw0L0qA8eR48CRJYGyRtzbMUuLHKaU69edDX9spMqYc=; b=Fp+FUVTq8LNPPGSrzjkOBpsT2MECFmFWn+dLJKIR+z8jOHQ75+oD+wHOWxljelishO KSA9Z9ub1wIFsT4wJwm7OfgznZDd/aYtj8elFKWVB+i3nrL+V0MsFLvEyiNcZzZPpIYu 42bh6OG51frxj3tTfsX2nAnlk7RSpuogek8VFWySkb0EPu7S/QekatyrjGjpEsGmmOHZ 2KI38EP1YgHBjzrRU77ZT60rVcpffSHz4NOTVaL+296L1MXIClsih1omcA44PfSNrpt9 ciNnMEsAytLD7GwNKKIN/Kdwr/1q8nGZtJDm0dIHlMndsI1DmvoIv+Fwu2KmBPkSyMp9 e9Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Zq/lrezi"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o16si8694667otp.289.2020.01.14.02.09.45; Tue, 14 Jan 2020 02:09:56 -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; dkim=pass header.i=@kernel.org header.s=default header.b="Zq/lrezi"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731064AbgANKIo (ORCPT + 99 others); Tue, 14 Jan 2020 05:08:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:40436 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731061AbgANKIm (ORCPT ); Tue, 14 Jan 2020 05:08:42 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 08A8420678; Tue, 14 Jan 2020 10:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578996522; bh=T67fHZqidlAyh8FbzLOG1P11xKFtdBYShqTE/DNKaeg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zq/lreziWcqXQqg6p8JG2MMaNq7OeGJUWPzv2Q+5cwzNi0KDE1GukPqz7VTPClrsd gMxcTFD8ataIMnamYDIo2T5ICg1Cuk8GJpxGbKIFjU9dtvW+LNUHNGEZSv4q2HiF95 MPURjWIKR3DNhKdNlD3Ar/JmuPAFGhpmexhqHj+0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jozsef Kadlecsik , syzbot+34bd2369d38707f3f4a7@syzkaller.appspotmail.com, Florian Westphal , Pablo Neira Ayuso Subject: [PATCH 4.19 46/46] netfilter: ipset: avoid null deref when IPSET_ATTR_LINENO is present Date: Tue, 14 Jan 2020 11:02:03 +0100 Message-Id: <20200114094348.890539049@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200114094339.608068818@linuxfoundation.org> References: <20200114094339.608068818@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Florian Westphal commit 22dad713b8a5ff488e07b821195270672f486eb2 upstream. The set uadt functions assume lineno is never NULL, but it is in case of ip_set_utest(). syzkaller managed to generate a netlink message that calls this with LINENO attr present: general protection fault: 0000 [#1] PREEMPT SMP KASAN RIP: 0010:hash_mac4_uadt+0x1bc/0x470 net/netfilter/ipset/ip_set_hash_mac.c:104 Call Trace: ip_set_utest+0x55b/0x890 net/netfilter/ipset/ip_set_core.c:1867 nfnetlink_rcv_msg+0xcf2/0xfb0 net/netfilter/nfnetlink.c:229 netlink_rcv_skb+0x177/0x450 net/netlink/af_netlink.c:2477 nfnetlink_rcv+0x1ba/0x460 net/netfilter/nfnetlink.c:563 pass a dummy lineno storage, its easier than patching all set implementations. This seems to be a day-0 bug. Cc: Jozsef Kadlecsik Reported-by: syzbot+34bd2369d38707f3f4a7@syzkaller.appspotmail.com Fixes: a7b4f989a6294 ("netfilter: ipset: IP set core support") Signed-off-by: Florian Westphal Acked-by: Jozsef Kadlecsik Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/ipset/ip_set_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/net/netfilter/ipset/ip_set_core.c +++ b/net/netfilter/ipset/ip_set_core.c @@ -1666,6 +1666,7 @@ static int ip_set_utest(struct net *net, struct ip_set *set; struct nlattr *tb[IPSET_ATTR_ADT_MAX + 1] = {}; int ret = 0; + u32 lineno; if (unlikely(protocol_failed(attr) || !attr[IPSET_ATTR_SETNAME] || @@ -1682,7 +1683,7 @@ static int ip_set_utest(struct net *net, return -IPSET_ERR_PROTOCOL; rcu_read_lock_bh(); - ret = set->variant->uadt(set, tb, IPSET_TEST, NULL, 0, 0); + ret = set->variant->uadt(set, tb, IPSET_TEST, &lineno, 0, 0); rcu_read_unlock_bh(); /* Userspace can't trigger element to be re-added */ if (ret == -EAGAIN)