Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9941330ybi; Wed, 24 Jul 2019 12:43:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvaSuINqXj4RUWzqMyVn31JFZT3wlYB5ZqQd4h3X3w6gERkaJ0imTOIV4LWja60fs7dCJh X-Received: by 2002:a65:4509:: with SMTP id n9mr29592136pgq.133.1563997437582; Wed, 24 Jul 2019 12:43:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563997437; cv=none; d=google.com; s=arc-20160816; b=whWg8wYSfXLCm8l0KBQWksDXK/8GmejaLxWt8Uz45vrwDgwMte4p546w2GK2j9qu18 lh73Ukz3yabDyrC2dOAZsfrm0QSlro7tWf4xUQUpW0LzAO9mB9YH/gDoSt4weMzYQTLM IaZu6JOA+g94yg49asl9zbP+Q4hfbLFUbh2EJkZJMRDd21Y1prLFzwcR6VkZx2J5DADw NZ6lyuNr/5q/tAaVkuZQ2AcU71GJqUYRCLOqxXjyzregXI1W1jQZL60G/sdvRm4zP/hO 9dVuNEh+xNCgJCeuB05ihy50BLmrMxgI/JC8sJ498szyKjLhxMrNe94JRb++DuDbZnzl IaXQ== 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=bMpPV3U3Vez6lhw55GU+Kyx7RrcQWCUpzI8tzoIs25k=; b=nnErpiHns62wGZAdiKhhhlLoCLQ/kT0Wbnm8VQQekrK+EzwfcBGYNzQ3d+VsGu77n2 cZPbt3G5ylxEXCg0yG/503z7bASGC/tqPrk+ftPieeQW4QB3bkmG/n+Cohco+Kj3rMI+ nG02hErdTacY4Uyevux5fhggxSkfkzEAXaRdhlgFhFmnvB/wh3PtDhkF2Cx2mmutKx5C U3h6Fbj6bKm83RqlqFV+K/tzZlYcE0/0EHfih6ECqIQSZXrRWCZdrjiwjQYbOAEt0ANn enPZqxkNUswUULASK8fwzmN7gO3G82Q9i78VyXzebCbY1O5QgoRU03soYZsh1eQ4Hm79 N5dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2V4ridoe; 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 q8si14727805pfc.155.2019.07.24.12.43.43; Wed, 24 Jul 2019 12:43:57 -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=2V4ridoe; 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 S2390167AbfGXTlV (ORCPT + 99 others); Wed, 24 Jul 2019 15:41:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:42580 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390138AbfGXTlR (ORCPT ); Wed, 24 Jul 2019 15:41:17 -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 0544622BEA; Wed, 24 Jul 2019 19:41:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997276; bh=m/TcuuKzU220TiJSgXTGr3A15gmnjrA9g4FvnmRYxz8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2V4ridoekXOhTGSKjsvYAwZJGDpX7cZplLs4hH85a2U8ugo6g4jrio25vqVU0AANH 8pb5WHHGL758h5QVBsLQhsMRt2WlNAbkwkCWEASjl8Dz3qpCcZVWg0CBpU9GIaLcqx Jc0bEGMWyi3M2cevXbIJ6y5O1hzWVu1VFV85v6X0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Henry Burns , Vitaly Wool , David Rientjes , Shakeel Butt , Vitaly Vul , Mike Rapoport , Xidong Wang , Jonathan Adams , Andrew Morton , Linus Torvalds Subject: [PATCH 5.2 379/413] mm/z3fold.c: lock z3fold page before __SetPageMovable() Date: Wed, 24 Jul 2019 21:21:10 +0200 Message-Id: <20190724191802.255562204@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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 From: Henry Burns commit 810481a246089117d98e3373a3cb735c3efc1f90 upstream. Following zsmalloc.c's example we call trylock_page() and unlock_page(). Also make z3fold_page_migrate() assert that newpage is passed in locked, as per the documentation. [akpm@linux-foundation.org: fix trylock_page return value test, per Shakeel] Link: http://lkml.kernel.org/r/20190702005122.41036-1-henryburns@google.com Link: http://lkml.kernel.org/r/20190702233538.52793-1-henryburns@google.com Signed-off-by: Henry Burns Suggested-by: Vitaly Wool Acked-by: Vitaly Wool Acked-by: David Rientjes Reviewed-by: Shakeel Butt Cc: Vitaly Vul Cc: Mike Rapoport Cc: Xidong Wang Cc: Jonathan Adams Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/z3fold.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) --- a/mm/z3fold.c +++ b/mm/z3fold.c @@ -924,7 +924,16 @@ retry: set_bit(PAGE_HEADLESS, &page->private); goto headless; } - __SetPageMovable(page, pool->inode->i_mapping); + if (can_sleep) { + lock_page(page); + __SetPageMovable(page, pool->inode->i_mapping); + unlock_page(page); + } else { + if (trylock_page(page)) { + __SetPageMovable(page, pool->inode->i_mapping); + unlock_page(page); + } + } z3fold_page_lock(zhdr); found: @@ -1331,6 +1340,7 @@ static int z3fold_page_migrate(struct ad VM_BUG_ON_PAGE(!PageMovable(page), page); VM_BUG_ON_PAGE(!PageIsolated(page), page); + VM_BUG_ON_PAGE(!PageLocked(newpage), newpage); zhdr = page_address(page); pool = zhdr_to_pool(zhdr);