From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63A6BC43387 for ; Tue, 15 Jan 2019 16:54:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 29E6C20651 for ; Tue, 15 Jan 2019 16:54:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547571251; bh=5cdb3Ecp8Ru2IQdzHxju0n0bH8ujoaDhR6AT++Ua4hY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=nrMb2jl+YGwKYf4K19HJJpHx9m+SEQlIEMHAOkwiCsff6wzb2OLjrVyUlNuy4TkWk ppF7y4Kyu0ATVCy9xNejkfibxrGnTjcT7rlOSEgArY+URvJuzUHZafDFHc7LaBdxeG CtQIAcSCLM+wUb5OPvB2PoYXcrbWw3IXyGqtpOxg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733192AbfAOQnS (ORCPT ); Tue, 15 Jan 2019 11:43:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:60952 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733191AbfAOQnR (ORCPT ); Tue, 15 Jan 2019 11:43:17 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 6C3E62054F; Tue, 15 Jan 2019 16:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547570596; bh=5cdb3Ecp8Ru2IQdzHxju0n0bH8ujoaDhR6AT++Ua4hY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FBZCJ10QW4GgPHVYHIUqFjX3cRL35Db0QEnbVSDcG8fjbPFpLuv7eMux9HPtSCw1p QpbdxYaAAXx7f9deUrF29oFdLX1h6GVccJ/CCyMf+0Jmbc5aLNs2WsoZK7uJYlz+0N B7ah0iTXAU3bKzjhTZIHKJDzoG+TViNf1/MNTt2g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Theodore Tso , stable@kernel.org Subject: [PATCH 4.19 39/50] ext4: fix a potential fiemap/page fault deadlock w/ inline_data Date: Tue, 15 Jan 2019 17:36:15 +0100 Message-Id: <20190115154912.149568527@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190115154909.933241945@linuxfoundation.org> References: <20190115154909.933241945@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Theodore Ts'o commit 2b08b1f12cd664dc7d5c84ead9ff25ae97ad5491 upstream. The ext4_inline_data_fiemap() function calls fiemap_fill_next_extent() while still holding the xattr semaphore. This is not necessary and it triggers a circular lockdep warning. This is because fiemap_fill_next_extent() could trigger a page fault when it writes into page which triggers a page fault. If that page is mmaped from the inline file in question, this could very well result in a deadlock. This problem can be reproduced using generic/519 with a file system configuration which has the inline_data feature enabled. Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/inline.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -1890,12 +1890,12 @@ int ext4_inline_data_fiemap(struct inode physical += (char *)ext4_raw_inode(&iloc) - iloc.bh->b_data; physical += offsetof(struct ext4_inode, i_block); - if (physical) - error = fiemap_fill_next_extent(fieinfo, start, physical, - inline_len, flags); brelse(iloc.bh); out: up_read(&EXT4_I(inode)->xattr_sem); + if (physical) + error = fiemap_fill_next_extent(fieinfo, start, physical, + inline_len, flags); return (error < 0 ? error : 0); }