From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-bn3nam01on0094.outbound.protection.outlook.com ([104.47.33.94]:25184 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1031755AbeCAPYQ (ORCPT ); Thu, 1 Mar 2018 10:24:16 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Gao Feng , Pablo Neira Ayuso , Sasha Levin Subject: [added to the 4.1 stable tree] netfilter: nf_nat_snmp: Fix panic when snmp_trap_helper fails to register Date: Thu, 1 Mar 2018 15:22:50 +0000 Message-ID: <20180301152116.1486-38-alexander.levin@microsoft.com> References: <20180301152116.1486-1-alexander.levin@microsoft.com> In-Reply-To: <20180301152116.1486-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Gao Feng This patch has been added to the 4.1 stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit 75c689dca98851d65ef5a27e5ce26b625b68751c ] In the commit 93557f53e1fb ("netfilter: nf_conntrack: nf_conntrack snmp helper"), the snmp_helper is replaced by nf_nat_snmp_hook. So the snmp_helper is never registered. But it still tries to unregister the snmp_helper, it could cause the panic. Now remove the useless snmp_helper and the unregister call in the error handler. Fixes: 93557f53e1fb ("netfilter: nf_conntrack: nf_conntrack snmp helper") Signed-off-by: Gao Feng Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/ipv4/netfilter/nf_nat_snmp_basic.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/net/ipv4/netfilter/nf_nat_snmp_basic.c b/net/ipv4/netfilter/nf= _nat_snmp_basic.c index cc626e1b06d3..64a8bbc06f23 100644 --- a/net/ipv4/netfilter/nf_nat_snmp_basic.c +++ b/net/ipv4/netfilter/nf_nat_snmp_basic.c @@ -1260,16 +1260,6 @@ static const struct nf_conntrack_expect_policy snmp_= exp_policy =3D { .timeout =3D 180, }; =20 -static struct nf_conntrack_helper snmp_helper __read_mostly =3D { - .me =3D THIS_MODULE, - .help =3D help, - .expect_policy =3D &snmp_exp_policy, - .name =3D "snmp", - .tuple.src.l3num =3D AF_INET, - .tuple.src.u.udp.port =3D cpu_to_be16(SNMP_PORT), - .tuple.dst.protonum =3D IPPROTO_UDP, -}; - static struct nf_conntrack_helper snmp_trap_helper __read_mostly =3D { .me =3D THIS_MODULE, .help =3D help, @@ -1288,17 +1278,10 @@ static struct nf_conntrack_helper snmp_trap_helper = __read_mostly =3D { =20 static int __init nf_nat_snmp_basic_init(void) { - int ret =3D 0; - BUG_ON(nf_nat_snmp_hook !=3D NULL); RCU_INIT_POINTER(nf_nat_snmp_hook, help); =20 - ret =3D nf_conntrack_helper_register(&snmp_trap_helper); - if (ret < 0) { - nf_conntrack_helper_unregister(&snmp_helper); - return ret; - } - return ret; + return nf_conntrack_helper_register(&snmp_trap_helper); } =20 static void __exit nf_nat_snmp_basic_fini(void) --=20 2.14.1