Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp170359imd; Wed, 31 Oct 2018 16:44:21 -0700 (PDT) X-Google-Smtp-Source: AJdET5evgHhX6yMHPzB8xpqMTUxCxEqFtvVxLjzqrCPl6TYKHr0QA9lsuRKo0zpe8+3yyxKfAHEd X-Received: by 2002:a17:902:162:: with SMTP id 89-v6mr5307056plb.293.1541029461561; Wed, 31 Oct 2018 16:44:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029461; cv=none; d=google.com; s=arc-20160816; b=g4NFlzwouMcP5BxZLgRDFJXafzuDLJEuoBzCpdliygthGzQqcox61mCdsiXHLW8V6H 2wvyJ5I0RVbywi0NE/qj429V2wncKv6dsr8awVw47yzZWHzhTXlZ5Ms9DqO6NDJ1GwZZ LVCTmDtzNXz10mrcc5i+zrzwdAfUMxZxS0ZHABghWFN4oVC5vOH1WOdWSV2Y1nefG0Hg TW2VqV3WEscaYkbl+DZ1IqO4SHUXIEAQ+mqHhrjsKJKVt9LFv2U7OoO4N9ijsBgaUEAe Rh4WuCh6ooUWtn1Xek0H0Q858YazEOoHk8RINNWVbe/EM59YyaS9P/VtiXbsUF1RFTCI U6lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=qVnRBMNCZ7RzS54Wi1a0Kc6Z7nFjuTPJ7C6xlbbbI1U=; b=0NhQufV6YUYal+AVuU/gil7HJwMHs0w9B0/SG4Zcoi2iIlR+BSjgup+C1SOGRHj0dN GtchZdVzgcVSrQHa0/6zz8VliGGrQPbekrAHwcTZ4TF0NOZTgCQxT5dzO8fkkB1Xuoo/ yx7go4uPZDG2PNcBA2rMLyEJ8Mm5ZaBBqRTY8zsLrSGXRdV/2hRH8IRayZr/PnYztCST nEjMZRIBUDZV+zICYgAbEob9jibB8OyZVXAgnw61spRArMhxOS9PUKTU62irTdTaK/Og alSALuXRYG/h199og4vEyWQwcF0MpyNDvg3fyaMVpcNG4Xl428p+OwUonNrliDqjvg2z TTnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="uGsH/GZZ"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c14-v6si7290797pga.422.2018.10.31.16.44.07; Wed, 31 Oct 2018 16:44:21 -0700 (PDT) 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="uGsH/GZZ"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729072AbeKAIHk (ORCPT + 99 others); Thu, 1 Nov 2018 04:07:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:55598 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727308AbeKAIHj (ORCPT ); Thu, 1 Nov 2018 04:07:39 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7349220830; Wed, 31 Oct 2018 23:07:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027248; bh=PWEEDArc6o/tcTam/X7oKdXsVa4AEnWWR4Z7ICtEGnw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uGsH/GZZd+q1hN08yIrGLjF/KCT9kJBkJyYei+BB2tXn5KHxwLl+AaHmFFk2ciuZH +5ccIIm6EYYGHVNDSXaEZ4Yjyw+ZrpX4Vh6szXKne67f4qOvz/eWlS24h1/IvX/I3i 2B9pKXuYs44J5EIBOAfMXTJ+rxivm6cgGrZR6Pco= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Theodore Ts'o , stable@kernel.org, Sasha Levin Subject: [PATCH AUTOSEL 4.19 117/146] ext4: fix argument checking in EXT4_IOC_MOVE_EXT Date: Wed, 31 Oct 2018 19:05:12 -0400 Message-Id: <20181031230541.28822-117-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- fs/ext4/move_extent.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c index a409ff70d67b..2f5be02fc6f6 100644 --- a/fs/ext4/move_extent.c +++ b/fs/ext4/move_extent.c @@ -516,9 +516,13 @@ mext_check_arguments(struct inode *orig_inode, 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 " -- 2.17.1