lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJKOXPc-GuTmVzWPXWqSegtckDsfyYj_aOKwK1TKCsYFkK681A@mail.gmail.com>
Date:   Wed, 21 Apr 2021 15:28:01 +0200
From:   Krzysztof Kozlowski <krzk@...nel.org>
To:     Vivek Goyal <vgoyal@...hat.com>
Cc:     Aditya Pakki <pakki001@....edu>,
        Stefan Hajnoczi <stefanha@...hat.com>,
        Miklos Szeredi <miklos@...redi.hu>,
        virtualization@...ts.linux-foundation.org,
        linux-fsdevel@...r.kernel.org,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] fuse: Avoid potential use after free

On Wed, 7 Apr 2021 at 23:25, Vivek Goyal <vgoyal@...hat.com> wrote:
>
> On Tue, Apr 06, 2021 at 06:53:32PM -0500, Aditya Pakki wrote:
> > In virtio_fs_get_tree, after fm is freed, it is again freed in case
> > s_root is NULL and virtio_fs_fill_super() returns an error. To avoid
> > a double free, set fm to NULL.
> >
> > Signed-off-by: Aditya Pakki <pakki001@....edu>
> > ---
> >  fs/fuse/virtio_fs.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
> > index 4ee6f734ba83..a7484c1539bf 100644
> > --- a/fs/fuse/virtio_fs.c
> > +++ b/fs/fuse/virtio_fs.c
> > @@ -1447,6 +1447,7 @@ static int virtio_fs_get_tree(struct fs_context *fsc)
> >       if (fsc->s_fs_info) {
> >               fuse_conn_put(fc);
> >               kfree(fm);
> > +             fm = NULL;
>
> I think both the code paths are mutually exclusive and that's why we
> don't double free it.
>
> sget_fc(), can either return existing super block which is already
> initialized, or it can create a new super block which need to
> initialize further.
>
> If if get an existing super block, in that case fs->s_fs_info will
> still be set and we need to free fm (as we did not use it). But in
> that case this super block is already initialized so sb->s_root
> should be non-null and we will not call virtio_fs_fill_super()
> on this. And hence we will not get into kfree(fm) again.
>
> Same applies to fuse_conn_put(fc) call as well.
>
> So I think this patch is not needed. I think sget_fc() semantics are
> not obvious and that confuses the reader of the code.

This patch might be harmful, might be not. Probably should be skipped
due to uncertain intentions:
https://lore.kernel.org/linux-nfs/YH+7ZydHv4+Y1hlx@kroah.com/

Best regards,
Krzysztof

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ