Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5254018imu; Tue, 15 Jan 2019 14:09:32 -0800 (PST) X-Google-Smtp-Source: ALg8bN6O11K255wpQ1uCo4oc9QXajSc98tU9nXuva+PXq6vcTwnODQvfmB8+sAqNicxtVKjIEBIw X-Received: by 2002:a63:ef04:: with SMTP id u4mr5820303pgh.197.1547590172606; Tue, 15 Jan 2019 14:09:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547590172; cv=none; d=google.com; s=arc-20160816; b=nhRpSeo8KrXQQjn0MFJpN5fh27yLmb1pRhb3rtnMz+ghD2uVSdlBjevUL6Q37AdnAn WqqnDZAHVPQM1DxMy1i4fjihd6r5shEcgW5hMEX6Spc1hSIM5t4amigFUxC4eBdXRX4x inV92w2QyO43sdcw+L2SqSdM0a/A1PGFaHf4vCIQnj+dy/BUlFNQ/hgHW3xnnxCwuOX2 DgINOVDw+z5RmaZtb51XDJICbjnTOnPBCOop7/6YMyHExekF1kkaagiNMbDil8wMhDkG oaXBup4rH7qezKhROrG4/jlJZieM7bfqv3zUOXUG5Vp9+EdBOqUhVQQAURgi/Z2hoxnq uFOA== 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=jZEnTbKWiKLyZpli9kPyKkpLn76M0Kj0thr654yPPg4=; b=D5A3Ct7GDgBGlhKTr5lbrvhY5Qo2Aki3/OG3F+bms7wAXcWOcgSc97msIl+h8dBhJS 9ZKaGUI5lryRX15YV+oakIgCnBAHftM3OCX/1X1mxqHTFBFJTKdHELiXurXH+hAbNrUA vzLqHJgUcaUzzZc0ZhVlLGKUXB1/SJhNP3Hzig14oLHbRLMCU4Ovi4oTLOeWiwow0cnB ezmVluE1OZcYTtU6g7R2j4deKs806ybaQ835xffKO0HbsWRUo+x4+EOv5mFzmVZzd+V9 G4IjSDPkbD4aLxOxa3jyB6xcLtWEeRjMRmuv894lIi9bReY0tomZWgXOSA0qze9xwKsd tMvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a7xMyqbQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u4si4111102pga.91.2019.01.15.14.09.16; Tue, 15 Jan 2019 14:09:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a7xMyqbQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731358AbfAOQrb (ORCPT + 99 others); Tue, 15 Jan 2019 11:47:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:35132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387776AbfAOQpX (ORCPT ); Tue, 15 Jan 2019 11:45:23 -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 C8C812054F; Tue, 15 Jan 2019 16:45:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547570723; bh=c2M1jaoFp9FgANG0adpn6/LfjOehHLZRFuN6oFslx6I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a7xMyqbQcgg27UubMHYDACMmZiEjJRfHi0fHTdkAUim8Um9LqaGNqv+A02gqoy1qi YkZj+dGDXtY1mtAjm4axp9tKMzZZ5frojwJhpi0iMmnx16sarfOjq8fy11qTu4cuUP E6DFP3tt53JUlWENh08mmy8OehMsM4PFa88Dp8Ws= 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.20 48/57] ext4: fix a potential fiemap/page fault deadlock w/ inline_data Date: Tue, 15 Jan 2019 17:36:29 +0100 Message-Id: <20190115154913.681736352@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190115154910.734892368@linuxfoundation.org> References: <20190115154910.734892368@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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-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); }