Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3815657ybi; Mon, 29 Jul 2019 13:10:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqysLjE6Cls4x+FiOSDGpDXJBR+6RQ4aAq8li2KVs5hkSCn22jprQyx3Di3Aq5ecCeqST8OD X-Received: by 2002:a17:90a:2506:: with SMTP id j6mr80039495pje.129.1564431022007; Mon, 29 Jul 2019 13:10:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564431022; cv=none; d=google.com; s=arc-20160816; b=rTxFCY4/iY91LYYWi2kpXNroFMwbOCHWhDE5uAhN0f34VMue3OIJde4oq6D//ENj+b /JFDcpf54N2iVyLSMhfZoKS3yTx9IsrhwH/aH5EGKTayyNe7Zes8OZ5vmomCk/WQkq5J 3UZ0ykD4wXw7/rEQoeG0BN0QEl9StqQcjBrXwrPIf/83Ru8c59iRkv6SwspmsePMpVPX uezOXupi/6UwKpcqBnRtFn+aiqlRZoifvjjuXayXhpivJEDJsLR405pMJHGlSNaXccgM sem6jPdWZtLlBqFTFw6IFViytocS8iL9PGVzTzWuI/IjocNUNCsRf7FG94oMAmYzvyvI 6GfQ== 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=isj6Ct7eWdueffMg6mHeR45LW9DTcGXjeLzlcCJhVjw=; b=Xrh09s86cIKrVmGDobZUOtJM5OHvaKdvgLA0lyevcdzh0W4786xqGs9qye3jyZuHRc JeSIEmsm6Qmu0lJXe8OCp9hnkmwguLWS0CBIHZLNNUgAaRrZDb6+59BXLUvBDikis7c8 ljKapO6kf9RTm3KhrRhIiCEI+laIm8FaOMhMC9qiAW+ziTPRYEXzrhen+qvq1/e4I9CY nNwdOc2cbeeLGIL/1tfRbh58aJ98/RBh/649WLxUe46DBBfvbuJM6tKNFjlA9NhO56Pt q/pd3Y2S28N4h7DNr/fkQOtVbXNI52Lb9ljyXm7HSTQ7r6+CqqzYNed/NZSjSwLVgV+K qtlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jT2VXhtS; 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 i198si27195455pfe.228.2019.07.29.13.10.07; Mon, 29 Jul 2019 13:10: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=jT2VXhtS; 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 S2388724AbfG2Thc (ORCPT + 99 others); Mon, 29 Jul 2019 15:37:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:52302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388714AbfG2Tha (ORCPT ); Mon, 29 Jul 2019 15:37:30 -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 086212171F; Mon, 29 Jul 2019 19:37:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429049; bh=4P2i2gaZ1antH6yCHEkpjWcNYzqo3v1guLr01cMlNC0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jT2VXhtSh20kLuh45jJCN8PRyM+8D1C/EB1URDGL4ETtdKLcASg0mhp11o1reFJWD h+584Ksu5cj9JDwUznNx8Kt11pSdNOLxBuYXayxs9na7z73jXiapzzJbpf+AEvg9Iu bUTkZh/aSEXhhLhaQYC1pCtP/qQDjYLOy1esMjvE= 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.14 266/293] f2fs: avoid out-of-range memory access Date: Mon, 29 Jul 2019 21:22:37 +0200 Message-Id: <20190729190844.753195129@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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 70bd15cadb44..18d51c36a5e3 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2612,6 +2612,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