Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1191662ybi; Fri, 2 Aug 2019 10:51:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFxHIbp75HrYD5BBzwy2dt4zeo0r/GM0bsIw/CX1RYq2X46gy4wnuediJ7h4/PN8C2n1xN X-Received: by 2002:a63:4185:: with SMTP id o127mr13968494pga.82.1564768299125; Fri, 02 Aug 2019 10:51:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564768299; cv=none; d=google.com; s=arc-20160816; b=Q4f/RE5wLBNfuypokGL163cDFBHmgRs8LkZI/DvRb7LCGHNV7tCl33z9ywSHgMLIin 3GtmmZ9PdwpNgSVk9f+2yTBY/phJFiqcF87yXTBej1ERpqLMtuU+eA1wq/Kar+EO5eSO mu+2HqSu6tc8ppiH8YY6CtY5o2ZeyDJ7cFOu8Q42+33WUP8fHO7PW/Y27cUI9SteVXge sOG5fLKgsYQ1qeHFN4Wcp/AvwkxzWPAcJMaJgvnhHM/PEg4XgnI/B/kUl6y39Gq2p9oi tzoV8Q6UmWyfjslpBSdM1MuhMl5Y31LNPL9Z4rygVmTORN9Cbac8JjO6FxUte20a4rF6 Lk4g== 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=gklA8FSRm0cIezO+qvemrjB+W0u6w4WfmW/Q6WMiSTU=; b=v7n4IILIwz09ktPzzs/TgJYQ1+b7chWR9Ssf8MJNFLZyDOtHnIYIxakaSC/a7L7DKG zN8U7ZeyG2UOWtfPnLYz7wmi9pJAUC6yXq8szpPW0E4N5RFD5P305OY/TAc/pAS6pZAE XVN7cG0W/D0HAHfy9NMovP6WMjErX8tZ2yzmvYFa7otlnIP9sOJYEANsQGotRP+sL/si WYRq2nl66aW9pkm1yrpfIpgKTAh89M4QKQ+NO5MPDa3zjFhWZXHYkXOrPDDWZKaSdL27 0QZBLaApSFBkncV6XhTjgl5rfz0jAgTKHJljwrc6uj/d7aKpQfX8EaGn/a28cpUN2ypa lnyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=c4w7ukpv; 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 b18si34214640plz.389.2019.08.02.10.51.24; Fri, 02 Aug 2019 10:51:39 -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=c4w7ukpv; 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 S2392112AbfHBJvy (ORCPT + 99 others); Fri, 2 Aug 2019 05:51:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:57198 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392043AbfHBJvu (ORCPT ); Fri, 2 Aug 2019 05:51:50 -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 EEB7A2064A; Fri, 2 Aug 2019 09:51:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564739510; bh=sj7trxfS9zf6pgZfptpJ+kanUgEfuUOnNltiHE6tFRQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c4w7ukpvEP93CGQJITfGGKOwYtqxomxL7CWCKA95duvcGzdpqbZUSRHnW437pSjrD kP60u9+0N5r0G7R3X6uplYzjOLxRtD8j3zvwE9HjXtIppKlXSQ8WOjtT6490tmZls8 pdfrqFg69M1Z8R+yBiBlIKjWq5+lS1vfiLOLvkKo= 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.9 193/223] f2fs: avoid out-of-range memory access Date: Fri, 2 Aug 2019 11:36:58 +0200 Message-Id: <20190802092249.833766176@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092238.692035242@linuxfoundation.org> References: <20190802092238.692035242@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 2fb99a081de8..c983f7d28f03 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -1709,6 +1709,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