Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3435182imu; Sun, 11 Nov 2018 15:02:58 -0800 (PST) X-Google-Smtp-Source: AJdET5cqJxz0WkmhmtarC4kQd/mry+DJ3oO2a1XJVasnVn0pozKllY/w7FXCH7iKtfA4JjQuhEma X-Received: by 2002:a63:ed42:: with SMTP id m2mr15558835pgk.147.1541977378756; Sun, 11 Nov 2018 15:02:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541977378; cv=none; d=google.com; s=arc-20160816; b=GyGCF1zktQb31UZwt7aEXiWrCUaymoPjsXHrann5r2uCuA9NYMIYC6M/muoKWb3BSD 5Cb50LnZ/ATA+TLhvNUaNWiMkwHXeYvLO6LpQ7NXzx4V7T1NI2p55l5fSfm0oYxuGdfU fM/+zmjnqHzlT+xo+KXjwbIubNwkfeexO3Fm/nKL2nuKgUhmq2kevo1rQbBNMoM8OVt2 TJhtV5E5qgdaR5mNM8VriPHKJZjHa9keB8RKxhX2WGh+RttJ+2j1d+jbhi4zYNk2bhwE P1jtCkvdf8DHyjVck/oBoKUGqqDCGajxyoaRUZw/2Egu7+yzovoGOicm3Myk0KmOHxE/ lg4A== 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=nVay1q/EzMWdQahNIEgq1QlGvEmWfZEQEZ9XuHUPHs8=; b=E7CXQVrey5NdSFjzU2QRsdyLc3X124Trg7obETXBKmUYIlJVUxJVT1Bxp1d/akEbk2 i0LtzHHqBCcq5oOUCbKe+cdGyEIiOJcmLoiDRUyBXmK5bXXYVi5tFWDwWtZFkwuZQaoz 8SLD8Io1TTAhJFqr6/Na3OdPb6Vh9w4zdifdvZJYa98XYgpZo6T4qDNDpSyaF0J32C6P YIn/FZIfhmrn5O8TZRMLago13K0KRV3fleXgHvRuLpHDr1MF/GgyFtylXmkvhiPvpzCF jtrkeya5lqyYzxljBkwj3vBilYqcNuQfXF93SacJhO5dplUv4EIHcAQjoDzXfotMKJKa VapA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OOCTyflJ; 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 u8-v6si14519194pgl.59.2018.11.11.15.02.43; Sun, 11 Nov 2018 15:02:58 -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=OOCTyflJ; 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 S2390777AbeKLIw2 (ORCPT + 99 others); Mon, 12 Nov 2018 03:52:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:51248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390612AbeKLIW1 (ORCPT ); Mon, 12 Nov 2018 03:22:27 -0500 Received: from localhost (unknown [206.108.79.134]) (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 A43052245E; Sun, 11 Nov 2018 22:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975550; bh=JoPM/m0Q08md6bvnOz6XMde0lJOsWNqfkO8CvzrpEgA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OOCTyflJ7b9B+mRcfWHah7/n3ZKYeUV45o1YecD2BDPKFRtMJqxCVpvEt6l06/Yjf sXoWQzq+9tpT4q/EzBcChn/PEM9UCe4JB0uJIKQMvX23LnnPsxZZF6AarZPicylIyL QlKwJDrSjMV9RJIMfb9PpiR/1y7Cw/lKg+8ubfnM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+c61979f6f2cba5cb3c06@syzkaller.appspotmail.com, Theodore Tso , stable@kernel.org, Sasha Levin Subject: [PATCH 4.14 091/222] ext4: fix argument checking in EXT4_IOC_MOVE_EXT Date: Sun, 11 Nov 2018 14:23:08 -0800 Message-Id: <20181111221656.107700843@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Theodore Ts'o [ Upstream commit f18b2b83a727a3db208308057d2c7945f368e625 ] If the starting block number of either the source or destination file exceeds the EOF, EXT4_IOC_MOVE_EXT should return EINVAL. Also fixed the helper function mext_check_coverage() so that if the logical block is beyond EOF, make it return immediately, instead of looping until the block number wraps all the away around. This takes long enough that if there are multiple threads trying to do pound on an the same inode doing non-sensical things, it can end up triggering the kernel's soft lockup detector. Reported-by: syzbot+c61979f6f2cba5cb3c06@syzkaller.appspotmail.com Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/ext4/move_extent.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/fs/ext4/move_extent.c +++ b/fs/ext4/move_extent.c @@ -526,9 +526,13 @@ mext_check_arguments(struct inode *orig_ orig_inode->i_ino, donor_inode->i_ino); return -EINVAL; } - if (orig_eof < orig_start + *len - 1) + if (orig_eof <= orig_start) + *len = 0; + else if (orig_eof < orig_start + *len - 1) *len = orig_eof - orig_start; - if (donor_eof < donor_start + *len - 1) + if (donor_eof <= donor_start) + *len = 0; + else if (donor_eof < donor_start + *len - 1) *len = donor_eof - donor_start; if (!*len) { ext4_debug("ext4 move extent: len should not be 0 "