Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 921E6C433EF for ; Thu, 11 Nov 2021 02:46:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B5676113B for ; Thu, 11 Nov 2021 02:46:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234346AbhKKCtg (ORCPT ); Wed, 10 Nov 2021 21:49:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:54356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234393AbhKKCtg (ORCPT ); Wed, 10 Nov 2021 21:49:36 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id BBDA161108; Thu, 11 Nov 2021 02:46:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1636598808; bh=UFlJGPKRzvhz0KcEfzFzM2oDb5a48Pl0wU7EGHP+em8=; h=Date:From:To:Subject:From; b=X4QaU1cgClUeUmqefv3TxQ/ghxwiHmEvgUn1Tb7U7Qwf5dwFajUmdpjnI/WaeRYgS YYT+gRv5F25DsVlVW/MPIEJkxNimZsSI46bdTR+yKd0sWRvWNpksi3VB2OwK9fleWJ 0JYvDgASE/4ah9XB5gD/drFIEwuHPQk1lC5CVV44= Date: Wed, 10 Nov 2021 18:46:47 -0800 From: akpm@linux-foundation.org To: cfijalkovich@google.com, hughd@google.com, mike.kravetz@oracle.com, mm-commits@vger.kernel.org, rongwei.wang@linux.alibaba.com, shy828301@gmail.com, song@kernel.org, stable@vger.kernel.org, william.kucharski@oracle.com, willy@infradead.org, xuyu@linux.alibaba.com Subject: [merged] mm-thp-fix-incorrect-unmap-behavior-for-private-pages.patch removed from -mm tree Message-ID: <20211111024647.QlMdbznQo%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The patch titled Subject: mm, thp: fix incorrect unmap behavior for private pages has been removed from the -mm tree. Its filename was mm-thp-fix-incorrect-unmap-behavior-for-private-pages.patch This patch was dropped because it was merged into mainline or a subsystem tree ------------------------------------------------------ From: Rongwei Wang Subject: mm, thp: fix incorrect unmap behavior for private pages When truncating pagecache on file THP, the private pages of a process should not be unmapped mapping. This incorrect behavior on a dynamic shared libraries which will cause related processes to happen core dump. A simple test for a DSO (Prerequisite is the DSO mapped in file THP): int main(int argc, char *argv[]) { int fd; fd = open(argv[1], O_WRONLY); if (fd < 0) { perror("open"); } close(fd); return 0; } The test only to open a target DSO, and do nothing. But this operation will lead one or more process to happen core dump. This patch mainly to fix this bug. Link: https://lkml.kernel.org/r/20211025092134.18562-3-rongwei.wang@linux.alibaba.com Fixes: eb6ecbed0aa2 ("mm, thp: relax the VM_DENYWRITE constraint on file-backed THPs") Signed-off-by: Rongwei Wang Tested-by: Xu Yu Cc: Matthew Wilcox (Oracle) Cc: Song Liu Cc: William Kucharski Cc: Hugh Dickins Cc: Yang Shi Cc: Mike Kravetz Cc: Collin Fijalkovich Cc: Signed-off-by: Andrew Morton --- fs/open.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) --- a/fs/open.c~mm-thp-fix-incorrect-unmap-behavior-for-private-pages +++ a/fs/open.c @@ -857,8 +857,17 @@ static int do_dentry_open(struct file *f */ smp_mb(); if (filemap_nr_thps(inode->i_mapping)) { + struct address_space *mapping = inode->i_mapping; + filemap_invalidate_lock(inode->i_mapping); - truncate_pagecache(inode, 0); + /* + * unmap_mapping_range just need to be called once + * here, because the private pages is not need to be + * unmapped mapping (e.g. data segment of dynamic + * shared libraries here). + */ + unmap_mapping_range(mapping, 0, 0, 0); + truncate_inode_pages(mapping, 0); filemap_invalidate_unlock(inode->i_mapping); } } _ Patches currently in -mm which might be from rongwei.wang@linux.alibaba.com are