Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5034143ybl; Tue, 14 Jan 2020 02:20:43 -0800 (PST) X-Google-Smtp-Source: APXvYqwPGocsDmM0L6CUFQR7OqsUfTFMbpthHL6TjG5PYPjOySyF8CLv5goID6V2LU1MbEPWHvtv X-Received: by 2002:a9d:6758:: with SMTP id w24mr17616849otm.155.1578997243067; Tue, 14 Jan 2020 02:20:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578997243; cv=none; d=google.com; s=arc-20160816; b=eoIYA57+Fq0wZCnwaHwvZJ2hATiNeL09Gh62F4/v2cnr8ELypSVIaBXjAjnW/UQVWb B2T3RBdso/0gkSQSLfxWPNAeauG73zAuvo6jyzsFWYgmZUPKEvnIoiycp0E+aXkU+WnF twqr8bW2JBMMYHfYuq2gcOl6Y8QXSvT1XYDPVfPeJignRGpX1tigcY01htVyPRzQnFJR HeAaEocQaBNObOl9Vu2yRGv8al52/mdOTi8XkWBiQ6lqFlYFPKhyks6a+Nl7Ni3Qjofj N801n4OMj0EzFzHvZNCZUrjsIqzY+K+/DSpPHr+rh7p6Hy11Du7+UBEqwJqJIjtA0wgE Iu8w== 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=+W60uhO7Xw0JwbqMuhldKoM8ZRg22h5RBMYLwZ45YOk=; b=M+Uw2EY140ZjE5ws+87A2dv5JvDYttFdlu7qVf+bh273mAQvdGSnP4J+qXDsnlNJia gC/xTyA3VfdaeNs8u5vKrhytPaEim+xv4yoKjx1BxZ255PMKIwD1SiEW2rDKe/xdmR+W wdJd1Wwx4JL0ub/ZunSkDBqEOHzLv6/+tmUo8mlTKeHkq9c7jlCYUTWSiCp79gPAswfE ZjKqd6NHXdzGhPif6l7fmWWHTCOfIixa6vpv7qinuZPnwoSTeDV/cYexoAcPDego+irb 9arXD3psGISIBzQgQKoIO4AbjEnQ/1gBUJvTiZXKQeZTjFVLJAPInB7LkGtlRls2v1AK 0NuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fYSV9xzo; 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 j5si7017728oii.114.2020.01.14.02.20.31; Tue, 14 Jan 2020 02:20: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; dkim=pass header.i=@kernel.org header.s=default header.b=fYSV9xzo; 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 S1730364AbgANKG3 (ORCPT + 99 others); Tue, 14 Jan 2020 05:06:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:35572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729963AbgANKG0 (ORCPT ); Tue, 14 Jan 2020 05:06:26 -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 D449024677; Tue, 14 Jan 2020 10:06:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578996386; bh=hzYuebpsFq1xFNMWn96tvRnGDTzteUizVMhWlBa9x8A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fYSV9xzodACnoAyBSOQcc6AzHITiLYLzCZtKZj0nSicUqhnMHk/CjkwTxq0C8zPgn gdTEy7Z12wTEFOi2IPGAUvT/jQoB7DRv0Nok6kN1Cd/4UgX6pCRtZ+CLP8p8p/yV7z dNniY6MFZLXdsPwK2e3kwpkwDUCjVBacwc+N3HX8= 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 5.4 78/78] netfilter: ipset: avoid null deref when IPSET_ATTR_LINENO is present Date: Tue, 14 Jan 2020 11:01:52 +0100 Message-Id: <20200114094403.749795669@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200114094352.428808181@linuxfoundation.org> References: <20200114094352.428808181@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 @@ -1658,6 +1658,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_min_failed(attr) || !attr[IPSET_ATTR_SETNAME] || @@ -1674,7 +1675,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)