Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4114233ybi; Mon, 29 Jul 2019 19:34:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDmEDRHq8ouk8fQOx3j428cAUk8fVGm4oARk73t/ptWI6PXHXHCBGcuR2xcaENV1IjfSBB X-Received: by 2002:a63:774c:: with SMTP id s73mr108433781pgc.238.1564454057613; Mon, 29 Jul 2019 19:34:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564454057; cv=none; d=google.com; s=arc-20160816; b=TrWoPe4ud2CS+BaenO77wMUzMpVIG9JEd86YxgZExARXA1U7D1i2wLNQiCEOfz57kE nVYmRECKEuxUXmQT4P2HznTXbYUegeeJhwpHy1S0qpS8oSXmEAEZ81TZEPxSReJyObA5 W74Z6aOFb0SIjVVG42A5UwgoGmpw/vOFLLhU8YgruUj1k4mKaN/SjfYHKgXWlZ7Udw6G Uiy/Pb572VsMLdA5X+TwCrAq3xrC0h8TQRk2Fj+Qkgx7Epx/vNVyLfDfcw+E1Q41Jiyl WN7HaheA3nxqKzbSoP/3VF6pSlsPan4lv1TpNP4bQ6N7gBDhKYXtDtS+kzO9E7eIkbyq QgGw== 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=9SJxK+Nq/GAEqNrmbh/YB+FfqjcyWjaF/zWohZUHKiA=; b=b99PuJ9yfMQSWsdjDZzM3gSSICIEVJRTCNhizUtPjf8xl+xU5k6fXdlPtW0QZcYJiH tQmz7srbsZsEsSR0vvtz1IDvQKNyU5kvNTqzsjtOulT85oanoo3uT4JUa1g2WAS9/UBe /WvSmgw5RKtC72ehsZ59s3Z+yJfBcoju1KULiPJiQUABQJ1R/BlLjYC3ZnOSNOYK4taa hp3CyLEVOuZS9IbW5uThfX/HpiKWisuOP8CvuadRn7OsI5nbvlI0OI+tDl+Wx5LdMB+1 mzs9b5WLVEt97kZ78mNr+zJAf2y9pXxA+DXozCzI9AhAaS/T+GHHwUGsz6oM6XoSosbv GDIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WWjF5m0W; 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 u11si26859876plr.431.2019.07.29.19.34.02; Mon, 29 Jul 2019 19:34:17 -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=WWjF5m0W; 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 S2389430AbfG2TpA (ORCPT + 99 others); Mon, 29 Jul 2019 15:45:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:33610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389862AbfG2Toz (ORCPT ); Mon, 29 Jul 2019 15:44:55 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 8E7D920C01; Mon, 29 Jul 2019 19:44:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429495; bh=y14D6dLa6fiGZGwns2WfE1OLGZlOsrlPNniRzRvoRGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WWjF5m0WJG7s2XWTJmWf2DXqdA8uTo/X/o3WH2YlHuEzy6K5Vg/+bwv7UfULBRmb+ wsh8WGYv6BlrEzwMOcx4JADOVaSKgHUPcvxSI95Ao65TUF2FwB8IhrrZTaiaZ9lS/X thr7HwIuzDINly+xIXjWZy/ExF7x2UuZQBFAkNe4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ocean Chen , Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 4.19 077/113] f2fs: avoid out-of-range memory access Date: Mon, 29 Jul 2019 21:22:44 +0200 Message-Id: <20190729190714.022413119@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190655.455345569@linuxfoundation.org> References: <20190729190655.455345569@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 56f3ce675103e3fb9e631cfb4131fc768bc23e9a ] blkoff_off might over 512 due to fs corrupt or security vulnerability. That should be checked before being using. Use ENTRIES_IN_SUM to protect invalid value in cur_data_blkoff. Signed-off-by: Ocean Chen Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/segment.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 8fc3edb6760c..92f72bb5aff4 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -3261,6 +3261,11 @@ static int read_compacted_summaries(struct f2fs_sb_info *sbi) seg_i = CURSEG_I(sbi, i); segno = le32_to_cpu(ckpt->cur_data_segno[i]); blk_off = le16_to_cpu(ckpt->cur_data_blkoff[i]); + if (blk_off > ENTRIES_IN_SUM) { + f2fs_bug_on(sbi, 1); + f2fs_put_page(page, 1); + return -EFAULT; + } seg_i->next_segno = segno; reset_curseg(sbi, i, 0); seg_i->alloc_type = ckpt->alloc_type[i]; -- 2.20.1