From: Mikhail Zaslonko <zaslonko@linux.ibm.com>
To: sashiko-reviews@lists.linux.dev
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
linux-s390@vger.kernel.org, Heiko Carstens <hca@linux.ibm.com>
Subject: Re: [PATCH v3 3/3] s390/debug: Fix race between debug area resize and event logging
Date: Tue, 8 Sep 2026 19:00:43 +0200 [thread overview]
Message-ID: <b36cfca5-bb81-4506-9c41-ff36376ebe6d@linux.ibm.com> (raw)
In-Reply-To: <20260903132123.12F271F00A3F@smtp.kernel.org>
On 03-Sep-26 15:21, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>
> Pre-existing issues:
> - [High] Preexisting NULL pointer dereference in debug_info_copy() if debug_register_static() fails to allocate memory.
> --
>
>
> [Severity: High]
> This isn't a bug introduced by this patch, but I noticed a potential NULL
> pointer dereference in debug_info_copy() if debug_register_static() fails
> to allocate memory.
>
> In arch/s390/kernel/debug.c:debug_register_static(), if the allocation fails:
>
> if (!copy) {
> pr_err("Registering debug feature %s failed\n", id->name);
>
> /* Clear pointers to prevent tracing into released initdata. */
> raw_spin_lock_irqsave(&id->lock, flags);
> id->areas = NULL;
> id->active_pages = NULL;
> id->active_entries = NULL;
> raw_spin_unlock_irqrestore(&id->lock, flags);
>
> return;
> }
>
> This sets id->areas to NULL but leaves id->pages_per_area and id->nr_areas
> with their original EARLY_PAGES and EARLY_AREAS values.
>
> Later, if debug_info_copy() is called when a user accesses the exposed
> debugfs file:
>
> for (i = 0; i < in->nr_areas; i++) {
> for (j = 0; j < in->pages_per_area; j++)
> memcpy(rc->areas[i][j], in->areas[i][j], PAGE_SIZE);
>
> Will this cause a NULL pointer dereference when accessing in->areas[i][j]
> since in->areas is NULL but the loop still executes based on in->nr_areas?
> Should we reset id->pages_per_area and id->nr_areas to 0 on the error path
> in debug_register_static(), or add a NULL check in debug_info_copy()?
>
The scenario above is unrealistic since upon debug_register_static() failure,
the _debug_register(id) is not called. So no debugfs entry exists for this id
on the failure path and a user can't access it and initiate debug_info_copy().
Thus, severity is arguably High.
Nevertheless, it's a fair finding. Everywhere in the debug feature code a NULL
areas pointer implies zero bounds: debug_info_alloc() sets areas to NULL when
pages_per_area is 0, and debug_areas_swap() swaps areas, nr_areas and
pages_per_area together. The error path of debug_register_static() is the only
exception. That's worth fixing even though nothing can currently observe it.
I will send a separate small patch.
next prev parent reply other threads:[~2026-09-08 17:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 13:07 [PATCH v3 0/3] s390/debug: Fix several s390dbf issues reported by AI scan Mikhail Zaslonko
2026-09-03 13:07 ` [PATCH v3 1/3] s390/debug: Fix NULL pointer dereference in debug_set_level() Mikhail Zaslonko
2026-09-03 13:16 ` sashiko-bot
2026-09-03 13:07 ` [PATCH v3 2/3] s390/debug: Do not repeat parameter override notice on debug_set_level() Mikhail Zaslonko
2026-09-03 13:17 ` sashiko-bot
2026-09-03 13:07 ` [PATCH v3 3/3] s390/debug: Fix race between debug area resize and event logging Mikhail Zaslonko
2026-09-03 13:21 ` sashiko-bot
2026-09-08 17:00 ` Mikhail Zaslonko [this message]
2026-09-03 19:33 ` [PATCH v3 0/3] s390/debug: Fix several s390dbf issues reported by AI scan Heiko Carstens
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=b36cfca5-bb81-4506-9c41-ff36376ebe6d@linux.ibm.com \
--to=zaslonko@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-s390@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.