[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20191202114630.qejem3irhz4yv66p@rric.localdomain>
Date: Mon, 2 Dec 2019 11:46:39 +0000
From: Robert Richter <rrichter@...vell.com>
To: John Garry <john.garry@...wei.com>
CC: Borislav Petkov <bp@...en8.de>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
James Morse <james.morse@....com>,
"tony.luck@...el.com" <tony.luck@...el.com>,
"linux-edac@...r.kernel.org" <linux-edac@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
wanghuiqiang <wanghuiqiang@...wei.com>,
Xiaofei Tan <tanxiaofei@...wei.com>,
Linuxarm <linuxarm@...wei.com>,
"Huangming (Mark)" <huangming23@...wei.com>
Subject: Re: linuxnext-2019127 edac warns (was Re: edac KASAN warning in
experimental arm64 allmodconfig boot)
On 02.12.19 10:23:29, John Garry wrote:
> On 28/11/2019 21:12, Robert Richter wrote:
> > On 27.11.19 17:07:33, John Garry wrote:
> > > [ 22.104498] BUG: KASAN: use-after-free in
> > > edac_remove_sysfs_mci_device+0x148/0x180
> >
> > It is triggered in edac_remove_sysfs_mci_device().
> >
> > device_unregister(&dimm->dev) not only removes the sysfs entry, it
> > also frees the dimm struct in dimm_attr_release(). When incrementing
> > the loop in mci_for_each_dimm(), the dimm struct is accessed again
> > which causes the use-after-free. But, the dimm struct shouln'd be
> > released here already.
> >
> > edac_remove_sysfs_mci_device() should not release the devices at this
> > point. We need clean release functions for mci and dimm_info and
> > refcounts to protect pdev/dev mappings. And mci_for_each_dimm() must
> > be checked how it handles device removals and if it is safe.
> >
> > Let's see how this can be fixed.
> >
> > Thanks for reporting the issue.
>
> Fine, and would any fix also deal with the v5.4 mem leak which I mentioned
> also?
Yes, I have identified the leaks:
# grep edac /sys/kernel/debug/kmemleak | sort | uniq -c
1 [<000000003c0f58f9>] edac_mc_alloc+0x3bc/0x9d0 # mci->csrows
16 [<00000000bb932dc0>] edac_mc_alloc+0x49c/0x9d0 # csr->channels
16 [<00000000e2734dba>] edac_mc_alloc+0x518/0x9d0 # csr->channels[chn]
1 [<00000000eb040168>] edac_mc_alloc+0x5c8/0x9d0 # mci->dimms
34 [<00000000ef737c29>] ghes_edac_register+0x1c8/0x3f8 # see edac_mc_alloc()
Thanks,
-Robert
Powered by blists - more mailing lists