From 48fddba63787167f7cdc718d39c99efedb0790f4 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Thu, 20 Mar 2025 01:34:10 +0000 Subject: [PATCH] devfs: Return early from sysctl_devname() if no input is given Otherwise we end up searching for a device using an uninitialized key, tripping up KMSAN. MFC after: 2 weeks (cherry picked from commit 48d6b52add36cc09e7fb1fbec44ab66c0742f320) --- sys/fs/devfs/devfs_devs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c index db879efe803..c6dcd4fc764 100644 --- a/sys/fs/devfs/devfs_devs.c +++ b/sys/fs/devfs/devfs_devs.c @@ -86,6 +86,9 @@ sysctl_devname(SYSCTL_HANDLER_ARGS) struct cdev_priv *cdp; struct cdev *dev; + if (req->newptr == NULL) + return (EINVAL); + #ifdef COMPAT_FREEBSD11 if (req->newlen == sizeof(ud_compat)) { error = SYSCTL_IN(req, &ud_compat, sizeof(ud_compat));