From: sashiko-bot@kernel.org
To: "Jia He" <justin.he@arm.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 5/7] misc: reject duplicate names in misc_register()
Date: Thu, 14 May 2026 17:18:28 +0000 [thread overview]
Message-ID: <20260514171829.2816FC2BCB3@smtp.kernel.org> (raw)
In-Reply-To: <20260514050455.2954509-6-justin.he@arm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unchecked strcmp() introduces a NULL pointer dereference kernel panic if a miscdevice is registered with a NULL name.
--
commit 45aa5c1645ea4c93820557b37841fd395426656c
Author: Jia He <justin.he@arm.com>
misc: reject duplicate names in misc_register()
This commit introduces a check in misc_register() to prevent registering
duplicate miscdevice names, returning -EEXIST early. It aims to avoid
triggering a backtrace from sysfs_create_dir_ns() when a duplicate name is
encountered.
> diff --git a/drivers/char/misc.c b/drivers/char/misc.c
> --- a/drivers/char/misc.c
> +++ b/drivers/char/misc.c
[ ... ]
> + {
> + struct miscdevice *c;
> +
> + list_for_each_entry(c, &misc_list, list) {
> + if (strcmp(c->name, misc->name) == 0) {
Could this lead to a NULL pointer dereference if a caller passes a miscdevice
with a NULL name? For instance, if a driver fails to allocate a name string
via kasprintf() and passes NULL without checking.
Before this change, the subsystem handled NULL names somewhat gracefully.
device_create_with_groups() safely formats NULL pointers as "(null)" via %s,
and misc_seq_show() explicitly protects against them when reading /proc/misc.
Additionally, if a device with a NULL name is successfully registered (such as
being the first device when the list is empty), would subsequent calls to
misc_register() by other drivers crash when this loop evaluates the NULL
c->name?
> + misc_minor_free(misc->minor);
> + if (is_dynamic)
> + misc->minor = MISC_DYNAMIC_MINOR;
> + err = -EEXIST;
> + goto out;
> + }
> + }
> + }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260514050455.2954509-1-justin.he@arm.com?part=5
next prev parent reply other threads:[~2026-05-14 17:18 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-14 5:04 [PATCH 0/7] Silence spurious warnings and crashes from kunit test suites Jia He
2026-05-14 5:04 ` [PATCH 1/7] init/initramfs_test: wait_for_initramfs() before running Jia He
2026-05-14 5:58 ` David Disseldorp
2026-05-14 12:29 ` sashiko-bot
2026-05-15 5:24 ` Justin He
2026-05-14 5:04 ` [PATCH 2/7] kfence: kunit: skip when no pool is available Jia He
2026-05-14 7:54 ` Marco Elver
2026-05-14 5:04 ` [PATCH 3/7] lib/math/int_log: drop WARN_ON for value == 0 Jia He
2026-05-14 5:04 ` [PATCH 4/7] kunit: platform: catch duplicate (name, id) in kunit_platform_device_add() Jia He
2026-05-14 16:30 ` sashiko-bot
2026-05-14 5:04 ` [PATCH 5/7] misc: reject duplicate names in misc_register() Jia He
2026-05-14 7:00 ` Greg Kroah-Hartman
2026-05-14 7:25 ` Justin He
2026-05-14 17:18 ` sashiko-bot [this message]
2026-05-14 5:04 ` [PATCH 6/7] hw_breakpoint_test: fix test_many_cpus failure on large systems Jia He
2026-05-14 8:01 ` Marco Elver
2026-05-14 5:04 ` [PATCH 7/7] lib/tests: test_ratelimit: fix stress test thread lifecycle and leak Jia He
2026-05-14 18:18 ` sashiko-bot
2026-05-15 5:33 ` Justin He
2026-05-14 7:02 ` [PATCH 0/7] Silence spurious warnings and crashes from kunit test suites Greg Kroah-Hartman
2026-05-14 7:17 ` Justin He
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=20260514171829.2816FC2BCB3@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=justin.he@arm.com \
--cc=linux-perf-users@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox