Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6361559ybi; Wed, 31 Jul 2019 13:00:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxW83d0kFUR7JUfYmlT2flo9fJZ/htNNcIyxJEw1t0y438d/Rl6TzF8ZBa6GX0hiofuaPSC X-Received: by 2002:a63:20d:: with SMTP id 13mr105076734pgc.253.1564603219983; Wed, 31 Jul 2019 13:00:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564603219; cv=none; d=google.com; s=arc-20160816; b=PhlaIytxlrEknrNuPszP7gq2RtLQ5CdQ5quxbO24rfmLUIUaGM/480IVJ1XYGQ10Ap DdOM/g1jO+uNV071eVf+zvu8k/ZdQ+GPJC4MSLqoBNyerl0bmPANVbik1Vk3a9/3RZW8 yOx98a6WjGDtzNO3cyaTgqtcnu4yoF+44nrhi8dhs0XE+yJeyIam54yqTPnxqHAt05OA Ua2zWZ/BPsQdy2Ui/kBwxo7bBtORGcaQkV7wXM1WvweSsqAu8Gs6mFGj4NBbCyWvSXip y8rqQ/8ainPp7p9+x48hfOgJK1sTBqzBFJ9JTDvPGntoo+qoqKMjTTlBSHb9cj9DbPUr f3Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=MShC9Tz7uOyHZBUNvIccsaVabKdxFslnsGHRSNUiivw=; b=fc0TEJAIbE5sJ5LtGu2i9VCkJo8DmKdWGa8YX4ShFAF3ufbL8CV5yn/bgVDKFvbAOM O4RCINtAnVxkmRYG8QClgv1quEZfZV5LHoT7RKjkRoLJ2NHYkqkp1UOpnoTzB/xwAS0A zrUEwpSLuQXO/DCDoG91cZ/fBDuNzNHViQJNC5cHKm2G8aANPhdF9Eb+Qwue8w0TSllT Yado/lQbrqDicJWRyZMsPQcYotFWzDC9MUanw52SR11Lfh2FOy0xPamcUjoCTg1BcgmH 8wgYR7moW2dE7al+O+4RKDhj0Z4ZtfQeo2W9gHnU+UrBFh11bsIV1fj3Pdw13fxdrNYG 0kHg== ARC-Authentication-Results: i=1; mx.google.com; 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 l44si2252506pjb.23.2019.07.31.13.00.05; Wed, 31 Jul 2019 13:00:19 -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; 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 S1730843AbfGaTLS (ORCPT + 99 others); Wed, 31 Jul 2019 15:11:18 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:47597 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726073AbfGaTLS (ORCPT ); Wed, 31 Jul 2019 15:11:18 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 5177E802D1; Wed, 31 Jul 2019 21:11:04 +0200 (CEST) Date: Wed, 31 Jul 2019 21:11:15 +0200 From: Pavel Machek To: pavel@ucw.cz Cc: linux-kernel@vger.kernel.org, Ocean Chen , Chao Yu , Jaegeuk Kim , Sasha Levin Subject: Re: [PATCH 4.19 077/113] f2fs: avoid out-of-range memory access Message-ID: <20190731191115.GB4630@amd> References: <20190729190655.455345569@linuxfoundation.org> <20190729190714.022413119@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="i9LlY+UWpKt15+FH" Content-Disposition: inline In-Reply-To: <20190729190714.022413119@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --i9LlY+UWpKt15+FH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > [ Upstream commit 56f3ce675103e3fb9e631cfb4131fc768bc23e9a ] >=20 > blkoff_off might over 512 due to fs corrupt or security > vulnerability. That should be checked before being using. >=20 > Use ENTRIES_IN_SUM to protect invalid value in cur_data_blkoff. >=20 > 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(+) >=20 > 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 =3D CURSEG_I(sbi, i); > segno =3D le32_to_cpu(ckpt->cur_data_segno[i]); > blk_off =3D 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 =3D segno; We normally use -EUCLEAN to signal filesystem corruption. Plus, it is good idea to report it to the syslog and mark filesystem as "needing fsck" if filesystem can do that. Thanks, Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --i9LlY+UWpKt15+FH Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl1B59MACgkQMOfwapXb+vKm+wCaA0MU06luGhPkGR0VcewLLETN nO0AniAbQox6kLkCPYywtE0Jd77Wlw72 =J5xo -----END PGP SIGNATURE----- --i9LlY+UWpKt15+FH--