Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4159617pxk; Tue, 8 Sep 2020 12:12:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOJqqAIC7DsMWDxAwA/765ues00mafhQwDueCnFn8X6ZgNLz1dBgRFNWHuQawb08/ztea8 X-Received: by 2002:a17:907:2168:: with SMTP id rl8mr27051042ejb.308.1599592323933; Tue, 08 Sep 2020 12:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599592323; cv=none; d=google.com; s=arc-20160816; b=PPGDwwQZQajGz0Y5WR14BxFfVuHbUh4s9Ikzb7A6BIVMX2S5BGg+7bF3HbuqDQZjkv sy7Qb2pBr3bhR9IYIQWw1MX0buMMjnK4NHSiTyETCT8gZuFjtywhW8VSNsgzxyP09nqf +yglP0rf/oeCt6UCHtzVHRtQVr5MX3DmJRoQfwr9YiDQShmXS2Wv9xHfqtRq4H+pPhW6 WkJvuTatlAtHXtcCZNtbQB6sYDGNDWlD8BZ+52QnhYOuw50SWNWcRdouuKQdQInBTfYQ bPQl1NpLUyEwOc+nA35qbAppjzagwfLwmO7rxm1305M0i9ZRTSZSLbtu066by9KToaLt fPTQ== 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=w+uozKHWgapITd9rqkqVF3rvxf7BWtbzowrenSvm1FM=; b=DUj3LiYPVjKy0yGjTnP45iUIj9WByNZnvK7e28dHiXay4Xmt0zXRXBLbHZ2dWuHwRt 1xPyPrw7EbKet6K9cLqFESnyI89Qw1/04Ui6xVfDbTOnPxNDENJk6aLc3gaic8qWqRES VwY00fHfBX3GX80GqxeIIlLNOmdkoKALmE26CkaL9HOinBdiaUdC9OEWtIqWJAcZKcXV BojXQzGEw3K28p5SlKuDuKmxqk6NbrgZtb7+LzRQRO6wv9i7dKpnf5nOE7uJk6IAuBGT KS7LdS6xJ5ifMxIIfpi6e3sB7wsXO070li6VtbKtAa84cCfqHSo9rzSXh9lZeS20KPU3 54+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sFpg0S48; 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 f23si134335edw.461.2020.09.08.12.11.41; Tue, 08 Sep 2020 12:12:03 -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=sFpg0S48; 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 S1731741AbgIHTKB (ORCPT + 99 others); Tue, 8 Sep 2020 15:10:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:52606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731236AbgIHQFh (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 CD75623CD2; Tue, 8 Sep 2020 15:46:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599579971; bh=MEmvLFwTluSLMx2cM/SWoItoFmupNuwGFBxSHz1bvcg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sFpg0S48KOFyCmvo598XHjanPOE/vnsF7ItVcNW0gLX9doliqsfNkGDIebKSbCzs9 /prhWfmDhjNLnurlIxe0r9qVriGohoeE/H5/YtgCd7ojyf19O7Nx/DXzfZPoUFAq79 cyf+aNvX4o6/DXQ+G6L4mWjH/a2Jm0XW6yNYE7GU= 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 078/129] ext2: dont update mtime on COW faults Date: Tue, 8 Sep 2020 17:25:19 +0200 Message-Id: <20200908152233.596628167@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 1ef6ea0efe8e68d0299dad44c39dc6ad9e5d1f39 upstream. When running in a dax mode, if the user maps a page with MAP_PRIVATE and PROT_WRITE, the ext2 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 ext2 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/ext2/file.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -93,8 +93,10 @@ static vm_fault_t ext2_dax_fault(struct struct inode *inode = file_inode(vmf->vma->vm_file); struct ext2_inode_info *ei = EXT2_I(inode); vm_fault_t ret; + bool write = (vmf->flags & FAULT_FLAG_WRITE) && + (vmf->vma->vm_flags & VM_SHARED); - if (vmf->flags & FAULT_FLAG_WRITE) { + if (write) { sb_start_pagefault(inode->i_sb); file_update_time(vmf->vma->vm_file); } @@ -103,7 +105,7 @@ static vm_fault_t ext2_dax_fault(struct ret = dax_iomap_fault(vmf, PE_SIZE_PTE, NULL, NULL, &ext2_iomap_ops); up_read(&ei->dax_sem); - if (vmf->flags & FAULT_FLAG_WRITE) + if (write) sb_end_pagefault(inode->i_sb); return ret; }