public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Theodore Ts'o <tytso@mit.edu>,
	stable@kernel.org, Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 3.18 16/22] ext4: fix argument checking in EXT4_IOC_MOVE_EXT
Date: Wed, 31 Oct 2018 19:12:00 -0400	[thread overview]
Message-ID: <20181031231206.29509-16-sashal@kernel.org> (raw)
In-Reply-To: <20181031231206.29509-1-sashal@kernel.org>

From: Theodore Ts'o <tytso@mit.edu>

[ 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 <tytso@mit.edu>
Cc: stable@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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 4d1049517e4a..ebe809bac808 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -533,9 +533,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


  parent reply	other threads:[~2018-10-31 23:13 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-31 23:11 [PATCH AUTOSEL 3.18 01/22] locking/lockdep: Fix debug_locks off performance problem Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 02/22] ataflop: fix error handling during setup Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 03/22] swim: fix cleanup on setup error Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 04/22] tun: Consistently configure generic netdev params via rtnetlink Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 05/22] perf tools: Free temporary 'sys' string in read_event_files() Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 06/22] perf tools: Cleanup trace-event-info 'tdata' leak Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 07/22] cpupower: Fix coredump on VMWare Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 08/22] mmc: sdhci-pci-o2micro: Add quirk for O2 Micro dev 0x8620 rev 0x01 Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 09/22] x86/olpc: Indicate that legacy PC XO-1 platform should not register RTC Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 10/22] regulator: fixed: Default enable high on DT regulators Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 11/22] x86: boot: Fix EFI stub alignment Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 12/22] kprobes: Return error if we fail to reuse kprobe instead of BUG_ON() Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 13/22] ath10k: schedule hardware restart if WMI command times out Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 14/22] scsi: esp_scsi: Track residual for PIO transfers Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 15/22] Drivers: hv: kvp: Fix two "this statement may fall through" warnings Sasha Levin
2018-10-31 23:12 ` Sasha Levin [this message]
2018-10-31 23:12 ` [PATCH AUTOSEL 3.18 17/22] MD: fix invalid stored role for a disk Sasha Levin
2018-10-31 23:12 ` [PATCH AUTOSEL 3.18 18/22] usb: chipidea: Prevent unbalanced IRQ disable Sasha Levin
2018-10-31 23:12 ` [PATCH AUTOSEL 3.18 19/22] uio: ensure class is registered before devices Sasha Levin
2018-10-31 23:12 ` [PATCH AUTOSEL 3.18 20/22] scsi: lpfc: Correct soft lockup when running mds diagnostics Sasha Levin
2018-10-31 23:12 ` [PATCH AUTOSEL 3.18 21/22] signal: Always deliver the kernel's SIGKILL and SIGSTOP to a pid namespace init Sasha Levin
2018-10-31 23:12 ` [PATCH AUTOSEL 3.18 22/22] mfd: menelaus: Fix possible race condition and leak Sasha Levin
2018-11-01  0:27   ` Alexandre Belloni
2018-11-01  1:29     ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181031231206.29509-16-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox