Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp92477yba; Mon, 1 Apr 2019 02:24:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqywtZKBdBEIf79hsl6I7YbTxFxvogQCTvXLaRbIEj3Gq4gxeWT/AURq4tSbYay4Tt6rr+Vh X-Received: by 2002:a17:902:9881:: with SMTP id s1mr33163917plp.99.1554110699431; Mon, 01 Apr 2019 02:24:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554110699; cv=none; d=google.com; s=arc-20160816; b=0pORXLR5MfXpmJArC3ZubqHs0UTT8fS6vei+yQdN9K6ROXvUQXfWApYBpa7zVv9HUz CKP0F4u/hS0eqWxtvBnMyZV0Jq7PMJRupI95lP2R2pawTbuBaDCQMtWJEgOQicP3Jsyf V7JtxoM1zRQN2bTQKZyXf4u2hzcRotCxdILUSVIUB3cLFKCe4y/dDB+fOvyR3jtkMizZ Lz8zi2FtItB04Qw7v8myZYIz37eY/vFiLiDJ6uD2nut+LZYdIaXsxxAtRswITBS+Gme9 PwAeepsAYGpsM06RMZXsZp70OLqK6mxkF8GFsqNG9ymOgubHyGd1addMQvOMOKOsQH4W pGGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=G79lPwHlmGqFf9NxN0nb+7/V1m5OMopGzu30AXNNOBY=; b=Z7vepY2J6PNvY1rjonc7yaz9Lz0RF/8yBh/1PmBnJ2ADyp463jkDO27pMW79irlnNH 4vM+Iy3+LoNdE4h4QERqN5YB7najo2g8mDnKNvtzWqoRMxHR3M2NQxn5grR8BalxLvWW rk927ObV8I6DHAY1CmxkLPETL707cyQ3rqSxijiwIVUb49G/O2sZ5zQePjG0JejBMCcK OKazKnA8dgZ7WOX1E0YYRL8Yqhvgnd47XPG45Qad6bq6z7fmEsHJqcMOzeTCd7SaFeSR mI+qR7lYyJoXG3sUorLdOoIm+6sIbb+oAQV5Y62Peqy0NBSti8RRlI9OWXnttBm4vHKg TeXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=gU90VgSh; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 91si8431856pla.14.2019.04.01.02.24.43; Mon, 01 Apr 2019 02:24:59 -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=@google.com header.s=20161025 header.b=gU90VgSh; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726605AbfDAJXw (ORCPT + 99 others); Mon, 1 Apr 2019 05:23:52 -0400 Received: from mail-yb1-f193.google.com ([209.85.219.193]:43815 "EHLO mail-yb1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725821AbfDAJXw (ORCPT ); Mon, 1 Apr 2019 05:23:52 -0400 Received: by mail-yb1-f193.google.com with SMTP id a123so1498505ybg.10 for ; Mon, 01 Apr 2019 02:23:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=G79lPwHlmGqFf9NxN0nb+7/V1m5OMopGzu30AXNNOBY=; b=gU90VgShcnQ+VldL4dMf9XTRHPmDzIkSIZvknFrF7cXy+vFjD54WDtBWILb+mocQOs H/iqjuptFyNFH/eJC+2kVVcVcHIFGHc3JQB+cmK09w/7QE4lEQh91JrRukj6VbI+yiNc Im/Ciz2G181hNbpXbjY+J99DVByWPnXiV42eZUoaIL3StihdvHtVcuE1Cn5gw86f+cRi vIGX3t2vAqgmOiI/jTFnb28TwFeLcOCQABBOG5AvKmRYqe3oiXkcYo4cddPYXvuT9jAK QE1KQynPsv63UOHublrcO/TCBoboJb00eQmAjB9K7CnZBmDEI77QaJx8QAhFQOX8bzFk Lr5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=G79lPwHlmGqFf9NxN0nb+7/V1m5OMopGzu30AXNNOBY=; b=HF3RNMLhb/FpKDh7rY1b3wwwJ6z+rDd23x92K54kPI6pm6i9d1xFJMXV9hRv8RkvIa R0BTJm3p73n9LRBaUPvOA5h5AS2NXTz5WWu28gppyA1Rn4mTav3WyEg5xk/AYgHNFQgL QKOsXPOVqgnosjLKXPTGuFGhUCvuIQWQQDgIH4aexe0mB9NU8AAbl1b1VrHFp/9Q0PEe 3ebpsnwgEUsMAjwjh0StjoR0M3vDZNFEQrToWcLRfR+9O2pCV6WU7RZWiPpfTMvVTDI1 J9zRAA6fxrmQLCLDfwcsafQCy1gEqdTyYT9UVbObKXJyH7NojnMtGAiAz0VXykKIA1UX DEIw== X-Gm-Message-State: APjAAAUwO6UtuNpjGf2Wm2LfCRBUOASiofuP1/8Vphf27CqIwgoHOiYd bjxOy64CedDWgFegeImI9gBJIE57VBgiUEt3roqwIQ== X-Received: by 2002:a25:aae5:: with SMTP id t92mr4476279ybi.461.1554110631378; Mon, 01 Apr 2019 02:23:51 -0700 (PDT) MIME-Version: 1.0 References: <20190401080453.87465-1-dust.li@linux.alibaba.com> In-Reply-To: <20190401080453.87465-1-dust.li@linux.alibaba.com> From: Eric Dumazet Date: Mon, 1 Apr 2019 02:23:39 -0700 Message-ID: Subject: Re: [PATCH] tcp: fix a potential NULL pointer dereference in tcp_sk_exit To: "dust.li" Cc: David Miller , Alexey Kuznetsov , Hideaki YOSHIFUJI , netdev , LKML , caspar@linux.alibaba.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 1, 2019 at 1:05 AM dust.li wrote: > > From: Dust Li > > 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. > > Signed-off-by: Dust Li Fixes: 6670e1524477 ("tcp: Namespace-ify sysctl_tcp_default_congestion_control") Signed-off-by: Eric Dumazet Thanks. > --- > 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 277d71239d75..2f8039a26b08 100644 > --- a/net/ipv4/tcp_ipv4.c > +++ b/net/ipv4/tcp_ipv4.c > @@ -2578,7 +2578,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.14.4.44.g2045bb6 >