Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3006704imu; Mon, 19 Nov 2018 09:16:02 -0800 (PST) X-Google-Smtp-Source: AFSGD/UjvlXVOsRVeQWTva9Rj+MbfENWANeNP9ctG6MFVlNZOKph60a5FKcs/dTSJuT/XGLK9J6w X-Received: by 2002:a17:902:142:: with SMTP id 60mr8601158plb.330.1542647762276; Mon, 19 Nov 2018 09:16:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542647762; cv=none; d=google.com; s=arc-20160816; b=BPEaO3d0Jq17OdArDmGmV+aAQ7PMi2nHYzUfK9kEfIVSRTxSPTUxt6iOYalj5RZeTv /W0TaZVuzf5sIR5Ms7tMTi7QMnir0GaS1iqDIxY0HHA7M+GWd1xsYlboOceCpDzDaGnE Fw9vujBo7yeqh8MvNy5NLOXhyYK8hxd/cdy1Yab05QpsUdVxRj8rse9wzRG57Ab+jgaw xXlKmHdgxP2ZNLFt93shZp+rghLupgcOafH3m3yT8t5Iiz15bUq8PdfSuBomusC+9b1j 9uERsYjX1ewGyxAyeS44Yu6NJSj8HWBceEaUraiVCnX8y/3sDwyQsnlNFLuoA24p+Gqe FhGQ== 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=X4MOHEMhdDng0KgKonBNhmDqkm6alGPRHEC0Azo2MFg=; b=r1/+lhImp0oZci5fUxOYLIufzSDIAyWvZ2kSuMNdoXLPTORu9CSrrLLUh+RkZb13Hw uMx4EaPROzOw0/F5XPF/kQTowvhCa0dCv/okFIQYYpPFtqdHX7y5hk2o3XTE4fLtohQJ N0QWs5K4gp+GueyFDqrv5d2rXcn9zZ2nDQjAl64d6OwBB86ddBaqlvdmsjr3XROLZiNR rnryKcK9xzo7znIovPkGe9GVq5a3WOiGghz3wsmvoUOHfa9GNjD5koRnSgp91uB75kRh YiCDxJcSPWTkTivjyslqxMLdRbN1WyR2XdUQN28sYmommI9pLwzPpBCaq8xYlOjlf0pP e6Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="VNXXN/cJ"; 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 y1si39716972pgy.174.2018.11.19.09.15.45; Mon, 19 Nov 2018 09:16:02 -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="VNXXN/cJ"; 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 S2406368AbeKTD2H (ORCPT + 99 others); Mon, 19 Nov 2018 22:28:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:42336 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405677AbeKTD2G (ORCPT ); Mon, 19 Nov 2018 22:28:06 -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 39ED62146D; Mon, 19 Nov 2018 17:03:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542647029; bh=JtiMojO03rwZ1GHhrKkj+HlaFB3n6XIPWsGF2IT7N+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VNXXN/cJpGGBej8nmxnkfyn2p1sVjycnxI+fMhtOskBkDdlwH8x9d3j3yPxRNl5RF VMKmmLSxHyc85ZIzjUMxYMs+neoiMh7GtogVFImhdiPBLK2aakAkL6kIrtXw2GCXDt ysvFltHMdLpvHN6nCwESXYEKnsI87XlV16Gj48Qo= 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 3.18 23/90] ext4: fix argument checking in EXT4_IOC_MOVE_EXT Date: Mon, 19 Nov 2018 17:29:05 +0100 Message-Id: <20181119162624.685062665@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162620.585061184@linuxfoundation.org> References: <20181119162620.585061184@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 3.18-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 @@ -533,9 +533,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 "