From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68A05C33CB3 for ; Tue, 28 Jan 2020 14:36:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3E39F2467E for ; Tue, 28 Jan 2020 14:36:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580222161; bh=VHUpfhuw0/MTQti92wD/w94WGMQ7FjzhvQC450J6ysY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=m/UJO3hv/SmfEL2taw6ZL7p2RfyOh3UpKC3TLu2QMxS3q9w4fxuXWci2db6PlAX4u uXJpFOs+lylpD9luy4iD+7LeN4firsM9sBaLxWOlYTSTYFvu6P5OIYQehfHzpl3hf6 dh8cCF8Ml0hBI2KL+BEy89wzHXmonNZ1xga8jrsU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731608AbgA1OWd (ORCPT ); Tue, 28 Jan 2020 09:22:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:48248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727549AbgA1OW1 (ORCPT ); Tue, 28 Jan 2020 09:22:27 -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 1074124681; Tue, 28 Jan 2020 14:22:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221345; bh=VHUpfhuw0/MTQti92wD/w94WGMQ7FjzhvQC450J6ysY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U2lkubMcNELLCdPF/YJii3s0Fr0gNN6VpKeMZKEeDdZsMd9jfKbktooFmfAnXLhvy 26r0YFFL5eaykG2z5wq2MZ3mV2M2eT2AzSFzdyotrstUt5axv09B9sHUEJDb/vIgoE 76wCD/g3ygidcKxkaoYpKS970O4rkdeXW+du9XBU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , "David S. Miller" , Sasha Levin Subject: [PATCH 4.9 151/271] inet: frags: call inet_frags_fini() after unregister_pernet_subsys() Date: Tue, 28 Jan 2020 15:05:00 +0100 Message-Id: <20200128135903.800317410@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@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: Eric Dumazet [ Upstream commit ae7352d384a552d8c799c242e74a934809990a71 ] Both IPv6 and 6lowpan are calling inet_frags_fini() too soon. inet_frags_fini() is dismantling a kmem_cache, that might be needed later when unregister_pernet_subsys() eventually has to remove frags queues from hash tables and free them. This fixes potential use-after-free, and is a prereq for the following patch. Fixes: d4ad4d22e7ac ("inet: frags: use kmem_cache for inet_frag_queue") Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ieee802154/6lowpan/reassembly.c | 2 +- net/ipv6/reassembly.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c index c01df341b5f64..5936bfafb1c43 100644 --- a/net/ieee802154/6lowpan/reassembly.c +++ b/net/ieee802154/6lowpan/reassembly.c @@ -633,7 +633,7 @@ err_sysctl: void lowpan_net_frag_exit(void) { - inet_frags_fini(&lowpan_frags); lowpan_frags_sysctl_unregister(); unregister_pernet_subsys(&lowpan_frags_ops); + inet_frags_fini(&lowpan_frags); } diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 4aed9c45a91ad..3f488555999e3 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c @@ -592,8 +592,8 @@ err_protocol: void ipv6_frag_exit(void) { - inet_frags_fini(&ip6_frags); ip6_frags_sysctl_unregister(); unregister_pernet_subsys(&ip6_frags_ops); inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT); + inet_frags_fini(&ip6_frags); } -- 2.20.1