Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3066627imu; Sun, 9 Dec 2018 16:30:37 -0800 (PST) X-Google-Smtp-Source: AFSGD/XdVpjKlR6X/wI2oDwoVIR6+XtrCY8VFPb48J2/B4q6xpR9xOuwPU+ZjewafbBFkLi12zZB X-Received: by 2002:a62:868b:: with SMTP id x133mr10921641pfd.252.1544401837002; Sun, 09 Dec 2018 16:30:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544401836; cv=none; d=google.com; s=arc-20160816; b=RaGHjQZC6CqSdjhFN6uQI8O9/bUm/SFSdJUpd56834yZKZipSTiNIRk2tKbgx9xLh7 ehz75j2t4e9eILSZXhiKJ5s2hxpP8YrgrRtNCQvxMSaxqiZXDtStW1EcnUBXarmXgWRH v+P7dcjiq7UtGxXq56q4En6d5oijpfLSLz5SkW6xeFJj2rv7X6zj/i3mLii8QPio7pYE T+sNZqpksdt/8iBahFhnwPaEPStaS4oU1bRooM+TRVZ8utMUU5pOrwQP8E3h/uvQMmdk HV5O5TqESWfgcFPF3pn5RUFmzUqSI3NuF7PWRdHQx8iyzSukzfklIY6n9aM7PBNaVU2U Bb7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=/nOXqHY2VkVe+c/96QbMbRbjuf+AmXuXSGTRXP7sz1Q=; b=njOWZi2Dmzj9XTe7ktbPseSmWqpv3yU7XvVyEUR6NuH2sib0A8z35toCwd3O+G+cS4 5SnCn/XpX1TpWTlWHkMdtyMxvE/ZvpdZrjXfbfAN9Y1TLNLsPPAyC/Bx0CHtMB2rcOGt T0fSrw2mW/FaMEpWqbBDdr2R4heaEbmlQi17R9FMm7lNwDO9ybGH+hAr0q4iPhdLPXC8 4YL6arw+lJPBKk+gTDiQvytFSDIkk/qVWIe1yL4yWGSPVwoYm5f24vMv4s5BPQFcUaxF wqabRe71fyPK5Q3Asce2eIuIpps7/6JsjDny8KpeB8V7brXjz0JLiOJ07o5oJ58CTHee PYzg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p126si8057942pgp.529.2018.12.09.16.30.21; Sun, 09 Dec 2018 16:30:36 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728254AbeLIWLe (ORCPT + 99 others); Sun, 9 Dec 2018 17:11:34 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:37700 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726975AbeLIWLb (ORCPT ); Sun, 9 Dec 2018 17:11:31 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW73C-0002iq-9o; Sun, 09 Dec 2018 21:55:46 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72d-0003P3-QH; Sun, 09 Dec 2018 21:55:11 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Florian Westphal" , "Pablo Neira Ayuso" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 145/328] netfilter: nf_tables: fix register ordering In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Florian Westphal commit d209df3e7f7002d9099fdb0f6df0f972b4386a63 upstream. We must register nfnetlink ops last, as that exposes nf_tables to userspace. Without this, we could theoretically get nfnetlink request before net->nft state has been initialized. Fixes: 99633ab29b213 ("netfilter: nf_tables: complete net namespace support") Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso [bwh: Backported to 3.16: - We don't call nft_chain_filter_{init,fini}() or {,un}register_netdevice_notifier() - Adjust context] Signed-off-by: Ben Hutchings --- --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -4042,6 +4042,10 @@ static int __init nf_tables_module_init( { int err; + err = register_pernet_subsys(&nf_tables_net_ops); + if (err < 0) + return err; + info = kmalloc(sizeof(struct nft_expr_info) * NFT_RULE_MAXEXPRS, GFP_KERNEL); if (info == NULL) { @@ -4053,17 +4057,19 @@ static int __init nf_tables_module_init( if (err < 0) goto err2; + /* must be last */ err = nfnetlink_subsys_register(&nf_tables_subsys); if (err < 0) goto err3; pr_info("nf_tables: (c) 2007-2009 Patrick McHardy \n"); - return register_pernet_subsys(&nf_tables_net_ops); + return err; err3: nf_tables_core_module_exit(); err2: kfree(info); err1: + unregister_pernet_subsys(&nf_tables_net_ops); return err; }