In the Linux kernel, the following vulnerability has been resolved:
powerpc/pseries/memhp: Fix access beyond end of drmem array
dlparmemoryremovebyindex() may access beyond the bounds of the drmem lmb array when the LMB lookup fails to match an entry with the given DRC index. When the search fails, the cursor is left pointing to &drmeminfo->lmbs[drmeminfo->n_lmbs], which is one element past the last valid entry in the array. The debug message at the end of the function then dereferences this pointer:
pr_debug("Failed to hot-remove memory at %llx\n",
lmb->base_addr);
This was found by inspection and confirmed with KASAN:
pseries-hotplug-mem: Attempting to hot-remove LMB, drc index 1234 ================================================================== BUG: KASAN: slab-out-of-bounds in dlpar_memory+0x298/0x1658 Read of size 8 at addr c000000364e97fd0 by task bash/949
dumpstacklvl+0xa4/0xfc (unreliable) printreport+0x214/0x63c kasanreport+0x140/0x2e0 _asanload8+0xa8/0xe0 dlparmemory+0x298/0x1658 handledlparerrorlog+0x130/0x1d0 dlparstore+0x18c/0x3e0 kobjattrstore+0x68/0xa0 sysfskfwrite+0xc4/0x110 kernfsfopwriteiter+0x26c/0x390 vfswrite+0x2d4/0x4e0 ksyswrite+0xac/0x1a0 systemcallexception+0x268/0x530 systemcallvectoredcommon+0x15c/0x2ec
Allocated by task 1: kasansavestack+0x48/0x80 kasansettrack+0x34/0x50 kasansaveallocinfo+0x34/0x50 _kasankmalloc+0xd0/0x120 _kmalloc+0x8c/0x320 kmallocarray.constprop.0+0x48/0x5c drmeminit+0x2a0/0x41c dooneinitcall+0xe0/0x5c0 kernelinitfreeable+0x4ec/0x5a0 kernelinit+0x30/0x1e0 retfromkerneluser_thread+0x14/0x1c
The buggy address belongs to the object at c000000364e80000 which belongs to the cache kmalloc-128k of size 131072 The buggy address is located 0 bytes to the right of allocated 98256-byte region [c000000364e80000, c000000364e97fd0)
================================================================== pseries-hotplug-mem: Failed to hot-remove memory at 0
Log failed lookups with a separate message and dereference the cursor only when it points to a valid entry.