Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2476549yba; Mon, 15 Apr 2019 12:26:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQBYFzEqCOLT4Ve3SE/KkPRoo9Tr9/AAS3jnDsGEOXyQgFKnq6gDIE5nO4dHJ0hAMyIqfc X-Received: by 2002:a62:209c:: with SMTP id m28mr75815264pfj.233.1555356413440; Mon, 15 Apr 2019 12:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555356413; cv=none; d=google.com; s=arc-20160816; b=SNdpojVQMrEgN4KUYwUoQXmqu8NWTSFYgMkQbHTeWFihzqtcadZPRqGR2TQPLeOH24 t4kjHL42eJp+AjdhqN1haB80e5UY5/qwdIlNXPOWYiAvXQRTW5CLHqq+WV82DlVzv1pM zw/Oe2lGkeFt7iW8yCfOv2tuTWsXu1J6BVdDYYJ2K3FsSBFkUPZnTm1KPcFiQNT5rv4Z LgZSjnvVdIfRs0Uyvp1cxa8nmtopXAOOIO++IYlpIzMo+Oz4ocTM6i9DtBRqolUq+hI/ xAr4SF56o+WqL7qeLKR9lmRv2MLbltfhhtv10gwmnNfXIX8amX92evcEJTVr1rnJ+cO1 SDfg== 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=Se8Mkf/B0UG9i7W1ynO4eLuB7yM7rjnUBrSGb2CXS3k=; b=lqVkb6k6VN3vW3//UU1AQT9E1QvkV5XDIUxOsRvv8Wfcor1455Usr72Q3T9Yvn88ZT pmYtx0DuVXhPQPMD+YQ3Hf3o9wbrDeewwjnWZxji3hx9tYOoTHeMVDFWOP0K2fVHqsyY 8Ts5chdwOsSMsS00/ll32USAM30MK6zDPPCCwh24mPU0xp5lbIQIEStrlGOqT/FdBifr vQ1v1i8lnAbQw5h8pkZgFVx0qS5LCt6M7aTNyK6JKWcGiRYtgprXZy7W+NBIxxl2ZZiB N9rjOibC7+wpNsAC5sMQHs5WPhtVRNLXAyY5SvqnEy/086LWT/hAYNBneoEd9l8fNFQ+ p66w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z+oYnQfS; 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 f128si44770017pgc.473.2019.04.15.12.26.37; Mon, 15 Apr 2019 12:26:53 -0700 (PDT) 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=z+oYnQfS; 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 S1728758AbfDOTF3 (ORCPT + 99 others); Mon, 15 Apr 2019 15:05:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:39100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729716AbfDOTFZ (ORCPT ); Mon, 15 Apr 2019 15:05:25 -0400 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 44937218A1; Mon, 15 Apr 2019 19:05:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355124; bh=gmku6RqsM67ebLOu6DxW0dwT4QGytn6flDHxHcH6T2Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z+oYnQfSNpd8EZqi88PLXVhwQtuynHNp+uDm3HRlpB1AZp5REtdzc/SZ+5qwoyPeb to9H4Lze4G9TpNUB9bdGkXAK/e+x5SSoyYFC1GlFEvCV5GzoZWUrvYEDBExMe9oYDy N5X6Dk03eJywG8Kg4PMCwgok7POsXNrjwx3VUWec= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dust Li , Eric Dumazet , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 022/101] tcp: fix a potential NULL pointer dereference in tcp_sk_exit Date: Mon, 15 Apr 2019 20:58:20 +0200 Message-Id: <20190415183741.556302042@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183740.341577907@linuxfoundation.org> References: <20190415183740.341577907@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 [ Upstream commit b506bc975f60f06e13e74adb35e708a23dc4e87c ] When tcp_sk_init() failed in inet_ctl_sock_create(), 'net->ipv4.tcp_congestion_control' will be left uninitialized, but tcp_sk_exit() hasn't check for that. This patch add checking on 'net->ipv4.tcp_congestion_control' in tcp_sk_exit() to prevent NULL-ptr dereference. Fixes: 6670e1524477 ("tcp: Namespace-ify sysctl_tcp_default_congestion_control") Signed-off-by: Dust Li Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/tcp_ipv4.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 30fdf891940b..11101cf8693b 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -2490,7 +2490,8 @@ static void __net_exit tcp_sk_exit(struct net *net) { int cpu; - module_put(net->ipv4.tcp_congestion_control->owner); + if (net->ipv4.tcp_congestion_control) + module_put(net->ipv4.tcp_congestion_control->owner); for_each_possible_cpu(cpu) inet_ctl_sock_destroy(*per_cpu_ptr(net->ipv4.tcp_sk, cpu)); -- 2.19.1