Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2565514imu; Thu, 29 Nov 2018 07:00:27 -0800 (PST) X-Google-Smtp-Source: AFSGD/W/KQud00NGXcgXH+4CKJ3I2DEt2y8zGjCs/wBkLHjikG6EoUl8sMulVaK3tut+e3bNyRp0 X-Received: by 2002:a62:442:: with SMTP id 63mr1667603pfe.156.1543503627650; Thu, 29 Nov 2018 07:00:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543503627; cv=none; d=google.com; s=arc-20160816; b=unccot9QJ87Al6k9TK7nPfTuXmA9FB/6CUuWmIFZwksBQGjpwGsJf/BfVyUzPPzpC8 5GGpLmsOCwkoAUecA0LyPtDAurfh6CiFXGYTVppKJmPi+fH+l70xwwHc++6kY9Ck76S+ b067+0bIKfa3LRdGETKUbwEbmwmuc7BwWFBpv1uPvXsblKykZXdenOPhIxg13UtSu+FU W7C9WXy4uvQvCuZ9Es1I1PafBRDDn6bksMi8Yara01gs+o5nBTlAZ4/BXdHQGx06rIvo I5dJR6mpD7Ie9bdM847u8JpB0Z3xS1lF2Cl8+yXH3RIyA78ZJ3nhKW+Xputmk8FN09LD Bw/A== 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=5Y1u7SAO54jGe+AYdE9/QEIDnsfxYWVD4SOCxHUvDPs=; b=rQ84Kjkzp5WB63S1BajEP+sEWU+MABM6Gys/B20VqGTJFBYkQuge+061L7YfAb7k16 rgEAr/8lvqe0UtsCCb4VfM6i7Uj3eGsO7ceDogczXESH85MIU0sj7eoeanZnQLmtqkc+ S4Hl5IvJtJqJ3WIVSzXWBSuC5nwGhFVPU0EcFQ6uCi6kcRXJu0P9AF3JEQJoUOVLZJT9 ek1EM0Io4kUYDGDnJEa/Tx/77cRfy51bsi2cPReE7MM0odR0chRLTpJlcbK+aheOK/N9 o949a6rkyEP1m2lthTWmW5HBEcqktXChSh+xEG1Ci8UZxYB8Opy2ua7aCMEXg/rm6VTt l3/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jlVavSS0; 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 i5si2234808pfo.189.2018.11.29.06.59.59; Thu, 29 Nov 2018 07:00:27 -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=jlVavSS0; 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 S1729905AbeK3CDV (ORCPT + 99 others); Thu, 29 Nov 2018 21:03:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:49792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730793AbeK3B0G (ORCPT ); Thu, 29 Nov 2018 20:26:06 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 C4FA92133F; Thu, 29 Nov 2018 14:20:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501235; bh=iSlorhtqpqFlw/uvyMBbl75HVE7OrBj5J06vwFWYyzE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jlVavSS0QeFCEXTtqhW70GUZxT0d3ERRoe7xpbirPOzzVBJ6e50W7hGLlz7wDqUEB JA7DwOXEEuin217ZZ8zW+L0GGAUUt9AUgNYepC6V+LyL2dl8Mm2y5/vw1hb65sdC9T ACUiAX4uydyRsgrLLuPD7d7fqjoKmRaEbqDNvlZ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dalegaard , Liping Zhang , Pablo Neira Ayuso , Amit Pundir Subject: [PATCH 4.4 72/86] netfilter: nf_tables: fix oops when inserting an element into a verdict map Date: Thu, 29 Nov 2018 15:12:37 +0100 Message-Id: <20181129140115.788351734@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140109.832117862@linuxfoundation.org> References: <20181129140109.832117862@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Liping Zhang commit 58c78e104d937c1f560fb10ed9bb2dcde0db4fcf upstream. Dalegaard says: The following ruleset, when loaded with 'nft -f bad.txt' ----snip---- flush ruleset table ip inlinenat { map sourcemap { type ipv4_addr : verdict; } chain postrouting { ip saddr vmap @sourcemap accept } } add chain inlinenat test add element inlinenat sourcemap { 100.123.10.2 : jump test } ----snip---- results in a kernel oops: BUG: unable to handle kernel paging request at 0000000000001344 IP: [] nf_tables_check_loops+0x114/0x1f0 [nf_tables] [...] Call Trace: [] ? nft_data_init+0x13e/0x1a0 [nf_tables] [] nft_validate_register_store+0x60/0xb0 [nf_tables] [] nft_add_set_elem+0x545/0x5e0 [nf_tables] [] ? nft_table_lookup+0x30/0x60 [nf_tables] [] ? nla_strcmp+0x40/0x50 [] nf_tables_newsetelem+0x11e/0x210 [nf_tables] [] ? nla_validate+0x60/0x80 [] nfnetlink_rcv+0x354/0x5a7 [nfnetlink] Because we forget to fill the net pointer in bind_ctx, so dereferencing it may cause kernel crash. Reported-by: Dalegaard Signed-off-by: Liping Zhang Signed-off-by: Pablo Neira Ayuso Signed-off-by: Amit Pundir Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_tables_api.c | 1 + 1 file changed, 1 insertion(+) --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -3452,6 +3452,7 @@ static int nft_add_set_elem(struct nft_c dreg = nft_type_to_reg(set->dtype); list_for_each_entry(binding, &set->bindings, list) { struct nft_ctx bind_ctx = { + .net = ctx->net, .afi = ctx->afi, .table = ctx->table, .chain = (struct nft_chain *)binding->chain,