]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cxl/test: Zero out LSA backing memory to avoid leaking to user
authorDave Jiang <dave.jiang@intel.com>
Fri, 5 Jun 2026 18:44:26 +0000 (11:44 -0700)
committerDave Jiang <dave.jiang@intel.com>
Wed, 10 Jun 2026 18:20:04 +0000 (11:20 -0700)
Memory through vmalloc() is not zeroed out. When this memory is copied
into output payload, it leaks memory content to user. Use vzalloc()
instead to zero out the memory.

Suggested-by: sashiko-bot
Link: https://lore.kernel.org/linux-cxl/20260605173146.2B9A31F00893@smtp.kernel.org/
Fixes: 7d3eb23c4ccf ("tools/testing/cxl: Introduce a mock memory device + driver")
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Link: https://patch.msgid.link/20260605184426.4070913-1-dave.jiang@intel.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
tools/testing/cxl/test/mem.c

index 9a7cd3f46a1ee53f1f4d902132fdbd5274f302d8..739343cd58022abfaa7bdd83c04f386813c5e285 100644 (file)
@@ -1724,7 +1724,7 @@ static int cxl_mock_mem_probe(struct platform_device *pdev)
                return -ENOMEM;
        dev_set_drvdata(dev, mdata);
 
-       mdata->lsa = vmalloc(LSA_SIZE);
+       mdata->lsa = vzalloc(LSA_SIZE);
        if (!mdata->lsa)
                return -ENOMEM;
        mdata->fw = vmalloc(FW_SIZE);