Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:55640 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751028AbeDVKN4 (ORCPT ); Sun, 22 Apr 2018 06:13:56 -0400 Date: Sun, 22 Apr 2018 12:13:50 +0200 From: Greg Kroah-Hartman To: Nathan Chancellor Cc: stable@vger.kernel.org, wangguang , wangguang , Theodore Ts'o Subject: Re: [PATCH 4.4] ext4: bugfix for mmaped pages in mpage_release_unused_pages() Message-ID: <20180422101350.GB10701@kroah.com> References: <20180422094516.9092-1-natechancellor@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180422094516.9092-1-natechancellor@gmail.com> Sender: stable-owner@vger.kernel.org List-ID: On Sun, Apr 22, 2018 at 02:45:16AM -0700, Nathan Chancellor wrote: > From: wangguang > > commit 4e800c0359d9a53e6bf0ab216954971b2515247f upstream. > > Pages clear buffers after ext4 delayed block allocation failed, > However, it does not clean its pte_dirty flag. > if the pages unmap ,in cording to the pte_dirty , > unmap_page_range may try to call __set_page_dirty, > > which may lead to the bugon at > mpage_prepare_extent_to_map:head = page_buffers(page);. > > This patch just call clear_page_dirty_for_io to clean pte_dirty > at mpage_release_unused_pages for pages mmaped. > > Steps to reproduce the bug: > > (1) mmap a file in ext4 > addr = (char *)mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, > fd, 0); > memset(addr, 'i', 4096); > > (2) return EIO at > > ext4_writepages->mpage_map_and_submit_extent->mpage_map_one_extent > > which causes this log message to be print: > > ext4_msg(sb, KERN_CRIT, > "Delayed block allocation failed for " > "inode %lu at logical offset %llu with" > " max blocks %u with error %d", > inode->i_ino, > (unsigned long long)map->m_lblk, > (unsigned)map->m_len, -err); > > (3)Unmap the addr cause warning at > > __set_page_dirty:WARN_ON_ONCE(warn && !PageUptodate(page)); > > (4) wait for a minute,then bugon happen. > > Cc: stable@vger.kernel.org > Signed-off-by: wangguang > Signed-off-by: Theodore Ts'o > [@nathanchance: Resolved conflict from lack of 09cbfeaf1a5a6] > Signed-off-by: Nathan Chancellor > --- > One more bug fix I came across, sorry I forgot to send it with the other > two patches! Thanks for this, now applied. greg k-h