Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4161270pxk; Tue, 8 Sep 2020 12:14:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3/b21DyTPE0LwwuR8/+rrNHS0rMdlkV03w6aKpqHmMSEGknixi0oRSAUju/wE+I7Hegl+ X-Received: by 2002:a05:6402:1386:: with SMTP id b6mr512211edv.296.1599592480801; Tue, 08 Sep 2020 12:14:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599592480; cv=none; d=google.com; s=arc-20160816; b=C7c0Ti5ZNd003ZuRuZBJsSvrcQ367BU51qKDWITPWAC2n7xLrmiQF3lxi8POA6n9Mq bM95pniwDZ10eKqL1tVj97F8zxhP7Uyq02j1rxKEPnhqLsmInxK9wPfhzU6fa6PUhZhh 4e3teyMOM8+2Osuqj2EW84qA3TVJnzsmELFQBSeEO8QRWOFeTArnAJ0UE+pyp5gJRdLg 7BQje0wC5P/ZA6pD15vkChjcAffNfUJYyRMU2+hfhr9WbydoRlf66+ihXdlZs2kqUG9/ cwbuPgV6Nlr8gSOavZh14NN3StIyN0w2Jx/w4PYx7N8BRtGvp4xXmNHsrNfgnsfV8AS+ ucpw== 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=HJLzsGy49ZDTXAuJzzE9Vd1S1UlmJQrl341rZf4W4qI=; b=gdn3PjrwrtH6n0ij18PgUzI6shnzlk9nxrOcf3wdaCbjL372hs90aAORJhDP+WVSJ7 wEkCp2bL7bBIEOfi67bmSRq5GxdAkfChYgHYHa/9EGb5OEZ+3euQQp2BtHocxUJA2EO0 HW22vO9LVR4Gm23aBSlzc9KbQV9eDewA/LgcuaDxnJkfPNi+zfb/FLjPuX/9z+EyoMPv Cnc0LMtvLTTleQQlA8OWko+GVAxTI7J/l9QPXw+a/DbsyewOnueq508XgUJNy6J9NmHm 5xnFlOqAerl5k3nHPHLidtrWSLMjhFzY7j9rP1KLLfQ42rormceJiQI14ByCRnGoa9y4 Cuhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=du720iQz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d3si11728226ejm.474.2020.09.08.12.14.17; Tue, 08 Sep 2020 12:14:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=du720iQz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730863AbgIHTKT (ORCPT + 99 others); Tue, 8 Sep 2020 15:10:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:53446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731239AbgIHQFh (ORCPT ); Tue, 8 Sep 2020 12:05:37 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 5665522A83; Tue, 8 Sep 2020 15:46:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599579973; bh=OHJAv06qZoq3OhRqsI02z1f04r0K+39Op1CU4gZCoO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=du720iQzOk4zYlbLMRRbmxbxc+IZdu0XI5LmB4asZhgoodOirqqw3Bf0nSSrsTxtO uGaKMFUbb5nQnAt4zk80dZQ6oRACG0K5oBapAlgZIg/Ev5QBxqZ6RJl3EOUI8N3J2e bTpEbJ7I9gKpRJirq3Atfy0hRUT6ZFWe9kVqMqMM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , Linus Torvalds Subject: [PATCH 5.4 079/129] xfs: dont update mtime on COW faults Date: Tue, 8 Sep 2020 17:25:20 +0200 Message-Id: <20200908152233.646658986@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908152229.689878733@linuxfoundation.org> References: <20200908152229.689878733@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: Mikulas Patocka commit b17164e258e3888d376a7434415013175d637377 upstream. When running in a dax mode, if the user maps a page with MAP_PRIVATE and PROT_WRITE, the xfs filesystem would incorrectly update ctime and mtime when the user hits a COW fault. This breaks building of the Linux kernel. How to reproduce: 1. extract the Linux kernel tree on dax-mounted xfs filesystem 2. run make clean 3. run make -j12 4. run make -j12 at step 4, make would incorrectly rebuild the whole kernel (although it was already built in step 3). The reason for the breakage is that almost all object files depend on objtool. When we run objtool, it takes COW page fault on its .data section, and these faults will incorrectly update the timestamp of the objtool binary. The updated timestamp causes make to rebuild the whole tree. Signed-off-by: Mikulas Patocka Cc: stable@vger.kernel.org Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/xfs/xfs_file.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1172,6 +1172,14 @@ __xfs_filemap_fault( return ret; } +static inline bool +xfs_is_write_fault( + struct vm_fault *vmf) +{ + return (vmf->flags & FAULT_FLAG_WRITE) && + (vmf->vma->vm_flags & VM_SHARED); +} + static vm_fault_t xfs_filemap_fault( struct vm_fault *vmf) @@ -1179,7 +1187,7 @@ xfs_filemap_fault( /* DAX can shortcut the normal fault path on write faults! */ return __xfs_filemap_fault(vmf, PE_SIZE_PTE, IS_DAX(file_inode(vmf->vma->vm_file)) && - (vmf->flags & FAULT_FLAG_WRITE)); + xfs_is_write_fault(vmf)); } static vm_fault_t @@ -1192,7 +1200,7 @@ xfs_filemap_huge_fault( /* DAX can shortcut the normal fault path on write faults! */ return __xfs_filemap_fault(vmf, pe_size, - (vmf->flags & FAULT_FLAG_WRITE)); + xfs_is_write_fault(vmf)); } static vm_fault_t