[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y1bUlK4aLQ0cZmLW@google.com>
Date: Mon, 24 Oct 2022 11:08:20 -0700
From: Jaegeuk Kim <jaegeuk@...nel.org>
To: Pavel Machek <pavel@...x.de>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-kernel@...r.kernel.org, stable@...r.kernel.org,
Wenqing Liu <wenqingliu0120@...il.com>,
Chao Yu <chao@...nel.org>
Subject: Re: [PATCH 5.10 052/390] f2fs: fix to do sanity check on summary info
On 10/24, Pavel Machek wrote:
> Hi!
>
> > From: Chao Yu <chao@...nel.org>
> >
> > commit c6ad7fd16657ebd34a87a97d9588195aae87597d upstream.
> >
> > As Wenqing Liu reported in bugzilla:
> >
> > https://bugzilla.kernel.org/show_bug.cgi?id=216456
> >
> > BUG: KASAN: use-after-free in recover_data+0x63ae/0x6ae0 [f2fs]
> > Read of size 4 at addr ffff8881464dcd80 by task mount/1013
>
> I believe this is missing put_page on the error path:
>
> > +++ b/fs/f2fs/gc.c
> > @@ -1003,6 +1003,14 @@ static bool is_alive(struct f2fs_sb_info
> > return false;
> > }
> >
> > + max_addrs = IS_INODE(node_page) ? DEF_ADDRS_PER_INODE :
> > + DEF_ADDRS_PER_BLOCK;
> > + if (ofs_in_node >= max_addrs) {
> > + f2fs_err(sbi, "Inconsistent ofs_in_node:%u in summary, ino:%u, nid:%u, max:%u",
> > + ofs_in_node, dni->ino, dni->nid, max_addrs);
> > + return false;
> > + }
> > +
> > *nofs = ofs_of_node(node_page);
> > source_blkaddr = data_blkaddr(NULL, node_page, ofs_in_node);
> > f2fs_put_page(node_page, 1);
>
> So something like this is needed. (Feel free to test/adapt/apply).
Urg.. thank you so much for pointing this out. Applied the change to the tree.
https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev&id=a22aeafb3d3569aecf811dca1aceff656695cdb4
>
> Signed-off-by: Pavel Machek <pavel@...x.de>
>
> Best regards,
> Pavel
>
> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
> index 4546e01b2ee0..dab794225cce 100644
> --- a/fs/f2fs/gc.c
> +++ b/fs/f2fs/gc.c
> @@ -1110,6 +1110,7 @@ static bool is_alive(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
> if (ofs_in_node >= max_addrs) {
> f2fs_err(sbi, "Inconsistent ofs_in_node:%u in summary, ino:%u, nid:%u, max:%u",
> ofs_in_node, dni->ino, dni->nid, max_addrs);
> + f2fs_put_page(node_page, 1);
> return false;
> }
>
>
> --
> DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Powered by blists - more mailing lists