Received: by 10.213.65.68 with SMTP id h4csp1800364imn; Thu, 29 Mar 2018 11:15:44 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+7180JS0EaFadZoTxi9aSeQm6znmbf8Rag92JuL80YOX49SP0Ays+X3MiKjPGCnnk/rQhg X-Received: by 10.99.42.209 with SMTP id q200mr6136924pgq.379.1522347344343; Thu, 29 Mar 2018 11:15:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522347344; cv=none; d=google.com; s=arc-20160816; b=OcL/M/13WB0bdxZ9WVIfsExtx8LOfCfJkP5RQq2DCZTXxR6/J5fbvgBTiIILvCtzgS 6deR5AcnTnR4YpR093MNFJRUCkc3959uC1Rg61WB73qbO6/83RXiKNCpw3m/i7v1ZOso Oq+scDnTgn/3TWtltTb3/px8mLMRMAT+js3DWl7PxU+dNTZuusZ+gR68UbN7HVWb/ZI3 5JhTP43/yz/mR7+rTPUI2BrF1899pbq7h6jmSEnD8kztHoH1H4SFV8pQp0Q56Z0sfC96 F9RgN5Hb8IWpQYYIQRdXu1kl/RSgGfqmmleM3FK044x6TjCX2MOT6fVGzrOTo6cyg/Qu 0ojA== 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=QQZL4XUHNWLslAJaj+3yY9Ag1+0aTG0d4A+48gZnPoA=; b=zlAEH7k0CXnw2oac+haS+8RV32XaBJ+61CxKZD3ifGNihzo4mii5I/krlaayDoYTJ/ wL3TAlsbHwI0WMk+o3EA+1m+Dv+Qf2Lsn5epVer49VU9T3eir3zbbD5JUmnk3D1+BGY8 5ptMvUBV0X6qDNAlSmrB71jO5Xy3c0s8ZOi/eMtAxhw88ZoAYFYJX1FqF7KJoyWCaRBk CoSV6ysH8Ppz6/4l+/uyViyx/soPmF90Ojk16GEmn0kKqjkz+Mtyw6+/M9zgquFToSb8 canZTIizSllSjcXTzLf8/g9XX8RbX75tNAmMRrIDu5nKwolamIHQSfR20P2kJrA/7UEi TEkg== 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 e93-v6si6181605plk.159.2018.03.29.11.15.30; Thu, 29 Mar 2018 11:15:44 -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 S1754355AbeC2SM5 (ORCPT + 99 others); Thu, 29 Mar 2018 14:12:57 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60154 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754124AbeC2SHr (ORCPT ); Thu, 29 Mar 2018 14:07:47 -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 14B49BAC; Thu, 29 Mar 2018 18:07:46 +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.4 03/20] net: Fix hlist corruptions in inet_evict_bucket() Date: Thu, 29 Mar 2018 20:00:39 +0200 Message-Id: <20180329175742.027507747@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180329175741.886181131@linuxfoundation.org> References: <20180329175741.886181131@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.4-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; }