Skip to content

Commit 257c4b0

Browse files
AlisonSchofielddavejiang
authored andcommitted
cxl/region: Use %pa printk format to emit resource_size_t
KASAN reports a stack-out-of-bounds access in validate_region_offset() while running the cxl-poison.sh unit test because the printk format specifier, %pr format, is not a match for the resource_size_t type of the variables. %pr expects struct resource pointers and attempts to dereference the structure fields, reading beyond the bounds of the stack variables. Since these messages emit an 'A exceeds B' type of message, keep the resource_size_t's and use the %pa specifier to be architecture safe. BUG: KASAN: stack-out-of-bounds in resource_string.isra.0+0xe9a/0x1690 [] Read of size 8 at addr ffff88800a7afb40 by task bash/1397 ... [] The buggy address belongs to stack of task bash/1397 [] and is located at offset 56 in frame: [] validate_region_offset+0x0/0x1c0 [cxl_core] Fixes: c3dd676 ("cxl/region: Add inject and clear poison by region offset") Signed-off-by: Alison Schofield <alison.schofield@intel.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent f4d0279 commit 257c4b0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/cxl/core/region.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3663,14 +3663,14 @@ static int validate_region_offset(struct cxl_region *cxlr, u64 offset)
36633663

36643664
if (offset < p->cache_size) {
36653665
dev_err(&cxlr->dev,
3666-
"Offset %#llx is within extended linear cache %pr\n",
3666+
"Offset %#llx is within extended linear cache %pa\n",
36673667
offset, &p->cache_size);
36683668
return -EINVAL;
36693669
}
36703670

36713671
region_size = resource_size(p->res);
36723672
if (offset >= region_size) {
3673-
dev_err(&cxlr->dev, "Offset %#llx exceeds region size %pr\n",
3673+
dev_err(&cxlr->dev, "Offset %#llx exceeds region size %pa\n",
36743674
offset, &region_size);
36753675
return -EINVAL;
36763676
}

0 commit comments

Comments
 (0)