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=-6.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 autolearn=ham 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 D7156C7618B for ; Tue, 23 Jul 2019 12:10:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AC26B218B8 for ; Tue, 23 Jul 2019 12:10:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563883800; bh=trOOc0umusdq+UA/HGzcYzNEUJTexMMe+DdxLZ9QHhw=; h=Subject:To:Cc:From:Date:List-ID:From; b=Y5/Eiov8ECFcHjjI1512BaVX/6OdZ3rZhGJTj3YT9wXGT007Pvj055oQLHOjceEpK oW/QXcuX6GKRXneOyzUKREp7yqsduX5BueCc5wyW+GKNaJbjgnTBJyMRQJrDzA7VQv /xZHAWVJ22GguvXOen00UGSWYiTvZuXD3f8pChR0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731982AbfGWMKA (ORCPT ); Tue, 23 Jul 2019 08:10:00 -0400 Received: from new2-smtp.messagingengine.com ([66.111.4.224]:51199 "EHLO new2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730000AbfGWMKA (ORCPT ); Tue, 23 Jul 2019 08:10:00 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id A8A857C; Tue, 23 Jul 2019 08:09:58 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 23 Jul 2019 08:09:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=X8mfQa JxP+hVhRMH7ILkYCPdOXVTvoSIj4HDz+ZkIJg=; b=np54jGbTxbIuclqPlCQaOr MYTaqtDUx/aVgG6SoGx0kAE16SBIPIKUdEA6jvzuEOa07rMNqXdDcGL3N8d74qLM 5qLyL/ms1XZ272GtZnBqxbcvq85RsnQZ8oRUGGXcBTMO+dJXspMPtoKq1X9DE0y8 J6pNqWqEQyDakF9uS4aWeGtGaICdXTfd+GQnWr1Sq5on47ovZ/diHPZ80yfUY3Bi QE3uHFeHcLaAfzGl8lHh5elNv8A+zrEUN9i6Mjd4QCjEhI4ZG//HmKvoLw6gECuv OucGRnc74THVvg0BqRJ7bb8Q5VsRYotrOstdrFi5YlZzDIhSDnN9GkU0ZkDym8fw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrjeekgdegkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepuffvhfffkfggtgfgsehtkeertddttd flnecuhfhrohhmpeeoghhrvghgkhhhsehlihhnuhigfhhouhhnuggrthhiohhnrdhorhhg qeenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecukfhppeekfedrkeeirdekledrud dtjeenucfrrghrrghmpehmrghilhhfrhhomhepghhrvghgsehkrhhorghhrdgtohhmnecu vehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) by mail.messagingengine.com (Postfix) with ESMTPA id 17325380083; Tue, 23 Jul 2019 08:09:57 -0400 (EDT) Subject: FAILED: patch "[PATCH] resource: fix locking in find_next_iomem_res()" failed to apply to 4.14-stable tree To: namit@vmware.com, akpm@linux-foundation.org, bhelgaas@google.com, bp@suse.de, dan.j.williams@intel.com, dave.hansen@linux.intel.com, mingo@kernel.org, peterz@infradead.org, stable@vger.kernel.org, torvalds@linux-foundation.org, toshi.kani@hpe.com Cc: From: Date: Tue, 23 Jul 2019 14:09:46 +0200 Message-ID: <156388378659181@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 4.14-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 49f17c26c123b60fd1c74629eef077740d16ffc2 Mon Sep 17 00:00:00 2001 From: Nadav Amit Date: Thu, 18 Jul 2019 15:57:31 -0700 Subject: [PATCH] resource: fix locking in find_next_iomem_res() Since resources can be removed, locking should ensure that the resource is not removed while accessing it. However, find_next_iomem_res() does not hold the lock while copying the data of the resource. Keep holding the lock while the data is copied. While at it, change the return value to a more informative value. It is disregarded by the callers. [akpm@linux-foundation.org: fix find_next_iomem_res() documentation] Link: http://lkml.kernel.org/r/20190613045903.4922-2-namit@vmware.com Fixes: ff3cc952d3f00 ("resource: Add remove_resource interface") Signed-off-by: Nadav Amit Reviewed-by: Andrew Morton Reviewed-by: Dan Williams Cc: Borislav Petkov Cc: Toshi Kani Cc: Peter Zijlstra Cc: Dave Hansen Cc: Bjorn Helgaas Cc: Ingo Molnar Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/kernel/resource.c b/kernel/resource.c index d22423e85cf8..3ced0cd45bdd 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -326,7 +326,7 @@ EXPORT_SYMBOL(release_resource); * * If a resource is found, returns 0 and @*res is overwritten with the part * of the resource that's within [@start..@end]; if none is found, returns - * -1 or -EINVAL for other invalid parameters. + * -ENODEV. Returns -EINVAL for invalid parameters. * * This function walks the whole tree and not just first level children * unless @first_lvl is true. @@ -365,16 +365,16 @@ static int find_next_iomem_res(resource_size_t start, resource_size_t end, break; } + if (p) { + /* copy data */ + res->start = max(start, p->start); + res->end = min(end, p->end); + res->flags = p->flags; + res->desc = p->desc; + } + read_unlock(&resource_lock); - if (!p) - return -1; - - /* copy data */ - res->start = max(start, p->start); - res->end = min(end, p->end); - res->flags = p->flags; - res->desc = p->desc; - return 0; + return p ? 0 : -ENODEV; } static int __walk_iomem_res_desc(resource_size_t start, resource_size_t end,