From: sashiko-bot@kernel.org
To: "Mukesh Ojha" <mukesh.ojha@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH v3 26/26] meminspect: Add debug kinfo compatible driver
Date: Wed, 08 Jul 2026 07:37:55 +0000 [thread overview]
Message-ID: <20260708073755.DED0C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260708070809.2660886-1-mukesh.ojha@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] Missing `return` statements after `dev_err_probe()` calls cause the driver to ignore size and base validations, leading to buffer overflows.
- [High] The driver attempts to use `rmem->priv` as a virtual address pointer, but it is never mapped or populated for this compatible string.
- [High] The driver uses `__pa()` instead of `__pa_symbol()` for statically allocated kernel symbols, which is invalid on architectures where kernel text/data is not in the linear map.
- [Medium] The shared memory checksum is updated non-atomically, exposing an intermediate, invalid state to concurrent external readers.
- [Low] Unconditional access to conditionally compiled `struct module` members causes build failures.
--
--- Patch [26]: [PATCH v3 26/26] meminspect: Add debug kinfo compatible driver ---
commit 8eff82a7a3c1597f04d6cc3418d6d9376460f4fc
Author: Eugen Hristev <ehristev@kernel.org>
meminspect: Add debug kinfo compatible driver
This commit adds a driver that copies registered memory regions to a shared
memory zone supplied via OF. It keeps only the addresses in a format that
is compatible with Kinfo.
> diff --git a/kernel/meminspect/kinfo.c b/kernel/meminspect/kinfo.c
> new file mode 100644
> index 0000000000000..7451c13bc3163
> --- /dev/null
> +++ b/kernel/meminspect/kinfo.c
[ ... ]
> +static void update_kernel_all_info(struct kernel_all_info *all_info)
> +{
> + struct kernel_info *info;
> + u32 *checksum_info;
> + int index;
> +
> + all_info->magic_number = DEBUG_KINFO_MAGIC;
> + all_info->combined_checksum = 0;
> +
> + info = &all_info->info;
> + checksum_info = (u32 *)info;
> + for (index = 0; index < sizeof(*info) / sizeof(u32); index++)
> + all_info->combined_checksum ^= checksum_info[index];
[Severity: Medium]
Could this non-atomic update expose an invalid intermediate state to
concurrent external readers?
If a crash occurs concurrently with the execution of this loop, the exposed
checksum in the mapped shared memory might be zero or partially computed.
Would it be safer to compute the checksum locally and then write it to the
shared memory once?
> +}
> +
> +static void __maybe_unused register_kinfo_region(void *priv,
> + const struct inspect_entry *e)
> +{
> + struct debug_kinfo *kinfo = priv;
> + struct kernel_all_info *all_info = kinfo->all_info_addr;
> + struct kernel_info *info = &all_info->info;
> + struct uts_namespace *uts;
> + u64 paddr;
> +
> + if (e->pa)
> + paddr = e->pa;
> + else
> + paddr = __pa(e->va);
[Severity: High]
Is __pa() the correct translation macro to use here for statically allocated
kernel symbols?
On architectures like x86_64, kernel symbols reside in the kernel image
mapping outside the direct linear mapping. Calling __pa() on these
addresses can trigger a virtual bug on kernel panic if CONFIG_DEBUG_VIRTUAL
is enabled. Should this use __pa_symbol() instead?
> +
> + switch (e->id) {
[ ... ]
> +static int debug_kinfo_probe(struct platform_device *pdev)
> +{
> + struct kernel_all_info *all_info;
> + struct device *dev = &pdev->dev;
> + struct reserved_mem *rmem;
> + struct debug_kinfo *kinfo;
> + struct kernel_info *info;
> +
> + rmem = of_reserved_mem_lookup(dev->of_node);
> + if (!rmem)
> + return dev_err_probe(dev, -ENODEV, "no such reserved mem of node name %s\n",
> + dev->of_node->name);
> +
> + /* Need to wait for reserved memory to be mapped */
> + if (!rmem->priv)
> + return -EPROBE_DEFER;
[Severity: High]
Will rmem->priv ever be populated for this compatible string?
The core framework only populates rmem->priv if there is a
RESERVEDMEM_OF_DECLARE callback that explicitly maps the memory. Since
there appears to be no such callback for google,debug-kinfo, this might
cause the driver to enter an endless probe defer loop.
> +
> + if (!rmem->base || !rmem->size)
> + dev_err_probe(dev, -EINVAL, "unexpected reserved memory\n");
> +
> + if (rmem->size < sizeof(struct kernel_all_info))
> + dev_err_probe(dev, -EINVAL, "reserved memory size too small\n");
[Severity: High]
Are these dev_err_probe calls missing return statements?
Without returning an error, execution proceeds. If the reserved memory is
indeed too small, the subsequent memset will write out-of-bounds of the
reserved memory region.
> +
> + kinfo = devm_kzalloc(dev, sizeof(*kinfo), GFP_KERNEL);
> + if (!kinfo)
> + return -ENOMEM;
> +
> + platform_set_drvdata(pdev, kinfo);
> +
> + kinfo->dev = dev;
> + kinfo->all_info_addr = rmem->priv;
> + kinfo->all_info_size = rmem->size;
> +
> + all_info = kinfo->all_info_addr;
> +
> + memset(all_info, 0, sizeof(struct kernel_all_info));
> + info = &all_info->info;
> + info->enabled_all = IS_ENABLED(CONFIG_KALLSYMS_ALL);
> + info->enabled_absolute_percpu = IS_ENABLED(CONFIG_KALLSYMS_ABSOLUTE_PERCPU);
> + info->enabled_base_relative = IS_ENABLED(CONFIG_KALLSYMS_BASE_RELATIVE);
> + info->enabled_cfi_clang = IS_ENABLED(CONFIG_CFI_CLANG);
> + info->name_len = KSYM_NAME_LEN;
> + info->bit_per_long = BITS_PER_LONG;
> + info->module_name_len = MODULE_NAME_LEN;
> + info->symbol_len = KSYM_SYMBOL_LEN;
> + info->thread_size = THREAD_SIZE;
> + info->enabled_modules_tree_lookup = IS_ENABLED(CONFIG_MODULES_TREE_LOOKUP);
> + info->mod_mem_offset = offsetof(struct module, mem);
> + info->mod_kallsyms_offset = offsetof(struct module, kallsyms);
[Severity: Low]
Will this cause compilation errors if CONFIG_MODULES or CONFIG_KALLSYMS
are disabled?
The struct module type is incomplete if CONFIG_MODULES is disabled, and
the kallsyms member only exists if CONFIG_KALLSYMS is enabled.
> +
> + kinfo->nb.notifier_call = kinfo_notifier_cb;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260708-meminspect-v3-v3-0-7aa5a0a74d5c@oss.qualcomm.com?part=26
next prev parent reply other threads:[~2026-07-08 7:38 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 5:31 [PATCH v3 00/26] Introduce meminspect Mukesh Ojha
2026-07-08 5:31 ` [PATCH v3 01/26] kernel: " Mukesh Ojha
2026-07-08 7:21 ` sashiko-bot
2026-07-08 7:38 ` Lorenzo Stoakes
2026-07-08 13:33 ` Mukesh Ojha
2026-07-08 5:31 ` [PATCH v3 02/26] init/version: Annotate static information into meminspect Mukesh Ojha
2026-07-08 7:21 ` sashiko-bot
2026-07-08 5:31 ` [PATCH v3 03/26] mm/percpu: " Mukesh Ojha
2026-07-08 5:31 ` [PATCH v3 04/26] cpu: " Mukesh Ojha
2026-07-08 5:31 ` [PATCH v3 05/26] genirq/irqdesc: " Mukesh Ojha
2026-07-08 7:20 ` sashiko-bot
2026-07-08 7:46 ` Lorenzo Stoakes
2026-07-08 5:31 ` [PATCH v3 06/26] timers: " Mukesh Ojha
2026-07-08 5:31 ` [PATCH v3 07/26] timekeeping: Register tk_data " Mukesh Ojha
2026-07-08 7:18 ` sashiko-bot
2026-07-08 5:31 ` [PATCH v3 08/26] kernel/fork: Annotate static information " Mukesh Ojha
2026-07-08 7:16 ` sashiko-bot
2026-07-08 5:31 ` [PATCH v3 09/26] mm/page_alloc: " Mukesh Ojha
2026-07-08 5:31 ` [PATCH v3 10/26] mm/show_mem: " Mukesh Ojha
2026-07-08 5:31 ` [PATCH v3 11/26] mm/swapfile: " Mukesh Ojha
2026-07-08 7:47 ` Lorenzo Stoakes
2026-07-08 19:05 ` Mukesh Ojha
2026-07-09 14:53 ` Lorenzo Stoakes
2026-07-10 4:09 ` Christoph Hellwig
2026-07-08 5:31 ` [PATCH v3 12/26] kernel/vmcore_info: Register dynamic " Mukesh Ojha
2026-07-08 7:25 ` sashiko-bot
2026-07-08 5:31 ` [PATCH v3 13/26] kernel/configs: " Mukesh Ojha
2026-07-08 7:20 ` sashiko-bot
2026-07-08 5:31 ` [PATCH v3 14/26] mm/init-mm: Annotate static " Mukesh Ojha
2026-07-08 7:23 ` sashiko-bot
2026-07-08 7:52 ` Lorenzo Stoakes
2026-07-08 5:31 ` [PATCH v3 15/26] panic: " Mukesh Ojha
2026-07-08 5:31 ` [PATCH v3 16/26] kallsyms: " Mukesh Ojha
2026-07-08 7:23 ` sashiko-bot
2026-07-08 5:31 ` [PATCH v3 17/26] mm/mm_init: " Mukesh Ojha
2026-07-08 5:31 ` [PATCH v3 18/26] sched/core: Annotate runqueues " Mukesh Ojha
2026-07-08 7:22 ` sashiko-bot
2026-07-08 5:31 ` [PATCH v3 19/26] mm/numa: Register node data information " Mukesh Ojha
2026-07-08 7:29 ` sashiko-bot
2026-07-08 7:55 ` Lorenzo Stoakes
2026-07-08 5:31 ` [PATCH v3 20/26] mm/sparse: Register " Mukesh Ojha
2026-07-08 7:27 ` sashiko-bot
2026-07-08 5:32 ` [PATCH v3 21/26] printk: " Mukesh Ojha
2026-07-08 7:24 ` sashiko-bot
2026-07-08 7:59 ` Lorenzo Stoakes
2026-07-08 18:53 ` Mukesh Ojha
2026-07-09 8:16 ` Petr Mladek
2026-07-08 5:32 ` [PATCH v3 22/26] remoteproc: qcom: Move minidump data structures into its own header Mukesh Ojha
2026-07-08 7:23 ` sashiko-bot
2026-07-08 5:32 ` [PATCH v3 23/26] soc: qcom: Add minidump backend driver Mukesh Ojha
2026-07-08 7:26 ` sashiko-bot
2026-07-08 5:32 ` [PATCH v3 24/26] soc: qcom: smem: Add minidump platform device Mukesh Ojha
2026-07-08 5:32 ` [PATCH v3 25/26] dt-bindings: reserved-memory: Add Google Kinfo Pixel reserved memory Mukesh Ojha
2026-07-08 7:08 ` [PATCH v3 26/26] meminspect: Add debug kinfo compatible driver Mukesh Ojha
2026-07-08 7:37 ` sashiko-bot [this message]
2026-07-08 8:06 ` Lorenzo Stoakes
2026-07-08 18:46 ` Mukesh Ojha
2026-07-09 13:24 ` Petr Pavlu
2026-07-08 7:11 ` [PATCH v3 00/26] Introduce meminspect Lorenzo Stoakes
2026-07-08 8:18 ` Lorenzo Stoakes
2026-07-09 20:42 ` Mukesh Ojha
2026-07-10 1:51 ` Liam R. Howlett
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260708073755.DED0C1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=mukesh.ojha@oss.qualcomm.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox