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: <YvS+/BRcHa5pTSXA@corigine.com>
Date:   Thu, 11 Aug 2022 09:34:04 +0100
From:   Simon Horman <simon.horman@...igine.com>
To:     Yinjun Zhang <yinjun.zhang@...igine.com>
Cc:     Jialiang Wang <wangjialiang0806@....com>,
        "kuba@...nel.org" <kuba@...nel.org>,
        "davem@...emloft.net" <davem@...emloft.net>,
        "edumazet@...gle.com" <edumazet@...gle.com>,
        "pabeni@...hat.com" <pabeni@...hat.com>,
        "niejianglei2021@....com" <niejianglei2021@....com>,
        oss-drivers <oss-drivers@...igine.com>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3] nfp: fix use-after-free in area_cache_get()

On Thu, Aug 11, 2022 at 05:10:44AM +0100, Yinjun Zhang wrote:
> On Wed, 10 Aug 2022 15:30:57 +0800 Jialiang Wang wrote:
> > area_cache_get() is used to distribute cache->area and set cache->id,
> >  and if cache->id is not 0 and cache->area->kref refcount is 0, it will
> >  release the cache->area by nfp_cpp_area_release(). area_cache_get()
> >  set cache->id before cpp->op->area_init() and nfp_cpp_area_acquire().
> > 
> > But if area_init() or nfp_cpp_area_acquire() fails, the cache->id is
> >  is already set but the refcount is not increased as expected. At this
> >  time, calling the nfp_cpp_area_release() will cause use-after-free.
> > 
> > To avoid the use-after-free, set cache->id after area_init() and
> >  nfp_cpp_area_acquire() complete successfully.
> > 
> > Note: This vulnerability is triggerable by providing emulated device
> >  equipped with specified configuration.
> > 
> >  BUG: KASAN: use-after-free in nfp6000_area_init (/home/user/Kernel/v5.19
> > /x86_64/src/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c:7
> > 60)
> >   Write of size 4 at addr ffff888005b7f4a0 by task swapper/0/1
> > 
> >  Call Trace:
> >   <TASK>
> >  nfp6000_area_init (/home/user/Kernel/v5.19/x86_64/src/drivers/net
> > /ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c:760)
> >  area_cache_get.constprop.8 (/home/user/Kernel/v5.19/x86_64/src/drivers
> > /net/ethernet/netronome/nfp/nfpcore/nfp_cppcore.c:884)
> > 
> >  Allocated by task 1:
> >  nfp_cpp_area_alloc_with_name
> > (/home/user/Kernel/v5.19/x86_64/src/drivers
> > /net/ethernet/netronome/nfp/nfpcore/nfp_cppcore.c:303)
> >  nfp_cpp_area_cache_add
> > (/home/user/Kernel/v5.19/x86_64/src/drivers/net
> > /ethernet/netronome/nfp/nfpcore/nfp_cppcore.c:802)
> >  nfp6000_init (/home/user/Kernel/v5.19/x86_64/src/drivers/net/ethernet
> > /netronome/nfp/nfpcore/nfp6000_pcie.c:1230)
> >  nfp_cpp_from_operations
> > (/home/user/Kernel/v5.19/x86_64/src/drivers/net
> > /ethernet/netronome/nfp/nfpcore/nfp_cppcore.c:1215)
> >  nfp_pci_probe (/home/user/Kernel/v5.19/x86_64/src/drivers/net/ethernet
> > /netronome/nfp/nfp_main.c:744)
> > 
> >  Freed by task 1:
> >  kfree (/home/user/Kernel/v5.19/x86_64/src/mm/slub.c:4562)
> >  area_cache_get.constprop.8 (/home/user/Kernel/v5.19/x86_64/src/drivers
> > /net/ethernet/netronome/nfp/nfpcore/nfp_cppcore.c:873)
> >  nfp_cpp_read (/home/user/Kernel/v5.19/x86_64/src/drivers/net/ethernet
> > /netronome/nfp/nfpcore/nfp_cppcore.c:924
> > /home/user/Kernel/v5.19/x86_64
> > /src/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cppcore.c:973)
> >  nfp_cpp_readl (/home/user/Kernel/v5.19/x86_64/src/drivers/net/ethernet
> > /netronome/nfp/nfpcore/nfp_cpplib.c:48)
> > 
> > Signed-off-by: Jialiang Wang <wangjialiang0806@....com>
> 
> Thanks.
> Reviewed-by: Yinjun Zhang <yinjun.zhang@...igine.com>

Acked-by: Simon Horman <simon.horman@...igine.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ