EDAC, ghes: Fix use after free and add reference
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 10 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | EDAC, ghes: Fix Use after free in ghes_edac remove pathdrivers/ | +1 | 0 replies | |
| 2/2 | EDAC, ghes: Reference count GHES users of ghes_edacdrivers/ | +3 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/2] EDAC, ghes: Fix use after free and add reference
Hello,
ghes_edac can only be registered once, later attempts will silently do nothing as the driver is already setup. The unregister path also only expects to be called once, but doesn't check.
This leads to KASAN splats if multiple GHES entries are unregistered, as the free()d memory is dereferenced, and if we're lucky, free()d a second time.
Patch 1 is the minimum needed to prevent the dereference and double free, but this does expose the lack of symmetry. If we unregister one GHES entry, subsequent notifications will be lost. Unregistering is unsafe if another CPU is using the free()d memory in ghes_edac_report_mem_error().
To fix this, Patch 2 uses ghes_init as a reference count.
We can now unbind all the GHES entries, causing ghes_edac to be unregistered, and start rebinding them again.
Thanks,
James Morse (2):
EDAC, ghes: Fix Use after free in ghes_edac remove path EDAC, ghes: Reference count GHES users of ghes_edac
drivers/edac/ghes_edac.c | 4 ++++ 1 file changed, 4 insertions(+)
Signature · 1 line
2.20.1