Received: by 10.213.65.68 with SMTP id h4csp1800495imn; Thu, 29 Mar 2018 11:15:52 -0700 (PDT) X-Google-Smtp-Source: AIpwx48icefnz+vNlefYT3NOzmrbbc/5MejU6vj7Kb59O6x+panBAMci/CiqOhx3OvXm8782HHd0 X-Received: by 2002:a17:902:c24:: with SMTP id 33-v6mr9623412pls.88.1522347352879; Thu, 29 Mar 2018 11:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522347352; cv=none; d=google.com; s=arc-20160816; b=dHIj/42MtdmHgaU/dF5q0zsSoJZeKQWWrn22LeQr0hBxxdzCr/9DW3jgwWWHcVuhmQ WmNSQx9pDVE4mWx7w8JvB4CmPrV2Jtb+u7wyeYO3AwivQQHg4MLohaQp8mQN0YPlkc9n Rzx+7a6xqXOnQjqIpW4D0bHx4W1T6Armj3Qm7mRs7ci3sYD2flKmYMS0C5LWPol5WW45 P+QOWALeGwjWta0Sc640UMqiD/QG60RMV4lxtkeVEss4kxb2zTi7xvXhx3TKnCxP5XbX zt+m5QQOdIE+KjkRjSn2uVMdd3hyWI/DgTYMeAyGrhXB4mqo2aFK2XxWhcE05xJxSaTI cTtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=MaYqeV9YmzKTi0r55Xr4cqp6ZOjLv53ClNjePZwvCy4=; b=XGrO86H6mtnx3ecnskMnZ5dF/t+Ba6eoM/DWJse5WsYrFAku08riXsAHe3K6wISC5G tDzZAFYZsYqIgD7nLH4t7OsKQ8eqj+AIrx2buV+4VOwF547PQONYVQs5RW1/hbWCTr5J mR9PN/uTRPJM2O5Jm8scDuIcU5MHRXRytutN9EEblH4UmcBfOMJmCRqC18VjQmwnaKLv UtfSqAA7HYXtNhCqD3tShHEEmB2RxyGBOdJsPMNGYgj3JfEMZ6RSqx91N0abQpKBwe4W 2dXpufi+Q64daDQ/nqNRicKpjw8QWyUdfO3OjQ8H2Tm/PhBLL9MTlNlU9HWiojd5wkQ+ Dkbw== 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 w128si4327727pgb.460.2018.03.29.11.15.38; Thu, 29 Mar 2018 11:15:52 -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; 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 S1754036AbeC2SHb (ORCPT + 99 others); Thu, 29 Mar 2018 14:07:31 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60004 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753986AbeC2SH1 (ORCPT ); Thu, 29 Mar 2018 14:07:27 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BF447AA6; Thu, 29 Mar 2018 18:07:26 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kirill Tkhai , "David S. Miller" Subject: [PATCH 4.9 09/28] net: Fix hlist corruptions in inet_evict_bucket() Date: Thu, 29 Mar 2018 20:00:28 +0200 Message-Id: <20180329175734.574879436@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180329175733.447823703@linuxfoundation.org> References: <20180329175733.447823703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kirill Tkhai [ Upstream commit a560002437d3646dafccecb1bf32d1685112ddda ] inet_evict_bucket() iterates global list, and several tasks may call it in parallel. All of them hash the same fq->list_evictor to different lists, which leads to list corruption. This patch makes fq be hashed to expired list only if this has not been made yet by another task. Since inet_frag_alloc() allocates fq using kmem_cache_zalloc(), we may rely on list_evictor is initially unhashed. The problem seems to exist before async pernet_operations, as there was possible to have exit method to be executed in parallel with inet_frags::frags_work, so I add two Fixes tags. This also may go to stable. Fixes: d1fe19444d82 "inet: frag: don't re-use chainlist for evictor" Fixes: f84c6821aa54 "net: Convert pernet_subsys, registered from inet_init()" Signed-off-by: Kirill Tkhai Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/inet_fragment.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/ipv4/inet_fragment.c +++ b/net/ipv4/inet_fragment.c @@ -119,6 +119,9 @@ out: static bool inet_fragq_should_evict(const struct inet_frag_queue *q) { + if (!hlist_unhashed(&q->list_evictor)) + return false; + return q->net->low_thresh == 0 || frag_mem_limit(q->net) >= q->net->low_thresh; }