From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12383C142 for ; Mon, 4 Sep 2023 18:36:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C991C433C7; Mon, 4 Sep 2023 18:36:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1693852593; bh=AQkwkmdndnbM7gO1zbjje40B+lrolHYwIaiDpigLD7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z0JfOQwwPwTSGBMqReqNahRSucKl22BA8QA/egLZH8qJny4eX7XQ6Ymf2C9CURZc9 ciBSOM+DX4o5iZXSobqHHHQylqp6dvYuv+1Lio4nR3EbGF337FDfekEwTXtT5c+4ms NTV1+y1d9kpqmsqUJd0FQh3Y9GrKFp0rFgKZSdcc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ryusuke Konishi , syzbot+0ad741797f4565e7e2d2@syzkaller.appspotmail.com, Andrew Morton Subject: [PATCH 5.15 24/28] nilfs2: fix general protection fault in nilfs_lookup_dirty_data_buffers() Date: Mon, 4 Sep 2023 19:30:55 +0100 Message-ID: <20230904182946.344370086@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230904182945.178705038@linuxfoundation.org> References: <20230904182945.178705038@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ryusuke Konishi commit f83913f8c5b882a312e72b7669762f8a5c9385e4 upstream. A syzbot stress test reported that create_empty_buffers() called from nilfs_lookup_dirty_data_buffers() can cause a general protection fault. Analysis using its reproducer revealed that the back reference "mapping" from a page/folio has been changed to NULL after dirty page/folio gang lookup in nilfs_lookup_dirty_data_buffers(). Fix this issue by excluding pages/folios from being collected if, after acquiring a lock on each page/folio, its back reference "mapping" differs from the pointer to the address space struct that held the page/folio. Link: https://lkml.kernel.org/r/20230805132038.6435-1-konishi.ryusuke@gmail.com Signed-off-by: Ryusuke Konishi Reported-by: syzbot+0ad741797f4565e7e2d2@syzkaller.appspotmail.com Closes: https://lkml.kernel.org/r/0000000000002930a705fc32b231@google.com Tested-by: Ryusuke Konishi Cc: Signed-off-by: Andrew Morton Signed-off-by: Ryusuke Konishi Signed-off-by: Greg Kroah-Hartman --- fs/nilfs2/segment.c | 5 +++++ fs/nilfs2/segment.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -725,6 +725,11 @@ static size_t nilfs_lookup_dirty_data_bu struct page *page = pvec.pages[i]; lock_page(page); + if (unlikely(page->mapping != mapping)) { + /* Exclude pages removed from the address space */ + unlock_page(page); + continue; + } if (!page_has_buffers(page)) create_empty_buffers(page, i_blocksize(inode), 0); unlock_page(page);