Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1082177ybi; Fri, 2 Aug 2019 09:03:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzH6NyU0D4uCpaLrl4N0++KVTULrsgoeEGeQMOylywgKtI0Xiqw2w/z/Iba4cBH3CBOzU80 X-Received: by 2002:a65:64c5:: with SMTP id t5mr51601617pgv.168.1564761821900; Fri, 02 Aug 2019 09:03:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564761821; cv=none; d=google.com; s=arc-20160816; b=YB46KfD+vrKnT5K178ZjTZaY8CpPrq2ieiXjuGe0BYLoDBUwQ/p3iGgfiKWuWq2SqB Kcgzy16jo6lIFAyymewrYcbc1T49P/kfSdsV7VaTDk/fuiYU4wRSWIV5DT44qV50gB7b 7TLMIEDuvnCdzM9AuIKnAkbQOd+VqUV/5XDhKRI/+NG3/I7XRw3t12EOTz6Pqt8ECmZE n4sIxqCd9NUsbOiEcpqnpIpRAXN8BGyDQ2xNwe6J412H+v4NkqZe5tbciJ87EltxbQoC M0EdOqB5Aeb4Arju59tXznd0qSFSyZgoNbziCAegbBENF+8oyuGilBhHZlz/D/HtbtXG yNww== 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=ztCgdSa6AgZRBI6SJeW7du7Xgh6X0oG39q2Y7T0UY10=; b=Zq8BzIpu/2WHCCtqM/n4I4AAS7Ld1IZguA7RR/nbcHDzV8YtVqub/mMmoZAUj/QcDP 6vHtA6AHsUEnLgJzG+0asPix8z0bS+VE+Kc23sXGVm6tlgyfYE7vQnumtAsGEjTmR9Kz AQHH8xJ9sK7SVcBU/0ABT3cOoKy64YYHSX53V3MRWDWwCbBXr+xXZ1pAiSdjKAFfJ0iv uigKDg3944l0Gb3Q7+KrLmFy1csasqbjE9RWQhwS/hcgaWF+H1fJO55PNaTGMvPXfRJO ZKYozAt63PtxpUNOIgj166NqjjeUg4hsCs2AJuJgVu1vXtQ4WfqATfL4dFOJQE0k9IcS 875w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=stZB2COi; 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 d3si38504899pfr.161.2019.08.02.09.03.26; Fri, 02 Aug 2019 09:03:41 -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=stZB2COi; 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 S2404037AbfHBJfw (ORCPT + 99 others); Fri, 2 Aug 2019 05:35:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:36446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403951AbfHBJfs (ORCPT ); Fri, 2 Aug 2019 05:35:48 -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 4C43F217D4; Fri, 2 Aug 2019 09:35:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564738547; bh=GEH+uPofXaxBZWYuFfTZ7w7GMA0dFFwr7imYVc2tTAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=stZB2COi7fQkfq5viOq0Atw1q+thgVZraacZMddMIgqb7eIfNclDryD2gMDDwkgfl niSNV4Ga5J9xrfPJzgxg42j4889xwZfX74yPreKJLGy3ks29Y58K27pHelcvQ3jXpB +TV0sQOZtoL/KUTaceyLRG6Z9Ls48S/oSroxI/30= 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.4 130/158] f2fs: avoid out-of-range memory access Date: Fri, 2 Aug 2019 11:29:11 +0200 Message-Id: <20190802092229.871546373@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092203.671944552@linuxfoundation.org> References: <20190802092203.671944552@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 6802cd754eda..014bee5c0e75 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -1510,6 +1510,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