From nobody Fri Apr 3 22:12:19 2026 Received: from mail-dl1-f54.google.com (mail-dl1-f54.google.com [74.125.82.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 317FA38228F for ; Mon, 23 Mar 2026 09:00:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774256459; cv=none; b=ke6G6Pv4FpDsJyJp8sy7bX6nxUnMbWClKjY24NZc32QSH7PBa/vHw2Rv31ppyicl/WP2wUCGUxJUk/8TfNfmnf2QglIjqhi/Y9LIA0ckrv5ZNyEg+A/esbQc2iTJxe//aTq9EfZVSU1NPlDrUcab4UXMfC007Q/Zhb8+0/Y5RW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774256459; c=relaxed/simple; bh=Cl5yPFxk//8Ej78GNhA/VX9CqrDUv6u1CQCqFHTaYvA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I7W4aeGLdLAEGnm9BcgDSW/UgZO2CS5IFo61VhchS9crAOx1XcIfdufKacoVmvjnznWg+5hMf52HI/6I06fUw0RKb31dpzFCNHYSP58NOUrDGS5kB2sDPCufj7rCidMcR22qNH7cOd3hcniC12ePOx9muOqZ9fTMdF1gpItWjng= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NaOKfm+e; arc=none smtp.client-ip=74.125.82.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NaOKfm+e" Received: by mail-dl1-f54.google.com with SMTP id a92af1059eb24-12732e6a123so5214078c88.1 for ; Mon, 23 Mar 2026 02:00:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1774256457; x=1774861257; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u0lLd0QkDOzCbjNYQorhBBOJpZyLtToijPDM8Z8Tmtc=; b=NaOKfm+eKRX7z/WY8Tcwb9pewt5lx9HRDQ0vTOSYaGxc64YykdEhIO6fdE5UlUUMwh YpUVeoHO5zwXKFs7m5hzYgXGyOyA6B89ouCcONKj69ViTZeq/TD7K8k1qKuVzqdLp/Cu gWyKbQto8r03tcG+N2W7Zc5ht8oJ+b7gQs14eeqZNw4gbCwucieAX8ajBuJskoxmYb1J 90V569/3FTkau1ljRMENCvmm4EfiNjnS07XIqOw3MM+bKR8NqAqPzojDF05Yrbnbl6bq hM8END4ViQfzSNIPtZtu+FX3wKJt7A46NOJQfnDJEYuNQVzk7SQ6VvAq+DPloANDDPaQ 6HIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774256457; x=1774861257; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=u0lLd0QkDOzCbjNYQorhBBOJpZyLtToijPDM8Z8Tmtc=; b=ACRZ6Z+E+6bk0NeX1FI/+X5DmUIW9jmO5uC4KpohmgdbZQrpu2CCYAi8VDmdr8Boqe T9m+0MgNI4A46cTXODzOAS2rXTi2mJYbA2Lix08ZvtV0MO0F66MffnQgjCH6WKg8JhKx jT8l2dLZJhlE8QUJechxmTRhMWtMG5yer+XPnpoVeN7piyNzxwhNxrSn1RZb5sPDTgvB yiCBddrlmEb1P02ZCmcmhhW65+18wDuk0ufCXhoGS6RuNTfLgGgF/WpczFDAYNFOuUg1 lJ+V7Rpu/upi9F77y5V4oHvjKVGHZ0pnj9sSgbkCZXjVBnWrcq5cjpQ8QtGOvcU0nSn/ yuhQ== X-Forwarded-Encrypted: i=1; AJvYcCUCj/vQxEB5+RoaYtq9R67+ZvqZ6FRt/uxRBo97i6WRg0g41T6zUyIMunvXW42RgG0hdQzu6oPRPA/YF4I=@vger.kernel.org X-Gm-Message-State: AOJu0YwIUvCi0Nan2yrBDajG3jYUn0IwGUegC0IJSaKk4930bjM5D0q4 8okyHskQ5fBoSbtaFgdnZxzqP4MXRtnvLly3ptV2kTN/MIEW1WK2zczH X-Gm-Gg: ATEYQzz8gsg3qotPbmtKlDqYRiyCZI6LdZQDSocE2DHU0kQtstGAbYxQrm0/IVNZgfy ytgRXNbBKpiJqNkE1mXAAZxXFW45UDSYZI4LYsgLyjlkmXZlyEtHyQ5klVoh41BV/CePKOia3Xp MID2v27Ha9jGzmUPkxcDZv8iDkLhwVqt0u4ygMUuGhDatbyIcoHHJYOUXr1z0iu3ShAM7w3EAAZ I6+qENwUjwzDcJHnewiH1bbFRweo5nMmdLbGRY8ysGyq0m2fwJAkZgr0CcLVABiWLfmwqUPXU5u LEZDpej6gEwUdGRFMpDJIxSfKciuNlUR9tqrT5xP2bKqsQ70pXej9ZiBeG/9tW5RzuQ7bdEqKdq baqSVr/ou8A0+59q08gUaOdUL4qNcgMLw3TxPjcT1n8CrNe4USADOr0DWvG0gIoLk3eIP/iYxnm N+tC9PkW1kHG0/ck4mdwxgSJGY3pkzK6mKESQ5kNnchoawzAr8TJwhAf37ZgFL8qHiOMrNr2IjT xgawhbsN7UZ9uKHKyN79oIROUOAkmQfJy7tzwK6xn4RKQJR92NQNXWidIUAbMSfpmg= X-Received: by 2002:a05:7022:628c:b0:128:cf5c:5352 with SMTP id a92af1059eb24-12a7266f502mr5323136c88.4.1774256457159; Mon, 23 Mar 2026 02:00:57 -0700 (PDT) Received: from 2045L.localdomain (90.sub-75-221-98.myvzw.com. [75.221.98.90]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12a734bb33fsm8620227c88.9.2026.03.23.02.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 02:00:56 -0700 (PDT) From: Gui-Dong Han To: gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, vkoul@kernel.org, yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev Cc: peterz@infradead.org, cristian.marussi@arm.com, sudeep.holla@kernel.org, linux-sound@vger.kernel.org, driver-core@lists.linux.dev, linux-kernel@vger.kernel.org, akaieurus@gmail.com, me@ziyao.cc, Gui-Dong Han , yangshiguang Subject: [PATCH v2 1/3] debugfs: check for NULL pointer in debugfs_create_str() Date: Mon, 23 Mar 2026 16:58:44 +0800 Message-ID: <20260323085930.88894-2-hanguidong02@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260323085930.88894-1-hanguidong02@gmail.com> References: <20260323085930.88894-1-hanguidong02@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Passing a NULL pointer to debugfs_create_str() leads to a NULL pointer dereference when the debugfs file is read. Following upstream discussions, forbid the creation of debugfs string files with NULL pointers. Add a WARN_ON() to expose offending callers and return early. Fixes: 9af0440ec86e ("debugfs: Implement debugfs_create_str()") Reported-by: yangshiguang Closes: https://lore.kernel.org/lkml/2025122221-gag-malt-75ba@gregkh/ Suggested-by: Greg Kroah-Hartman Signed-off-by: Gui-Dong Han --- v2: * No changes. --- fs/debugfs/file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 3376ab6a519d..a941d73251b0 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -1127,7 +1127,7 @@ static const struct file_operations fops_str_wo =3D { * directory dentry if set. If this parameter is %NULL, then the * file will be created in the root of the debugfs filesystem. * @value: a pointer to the variable that the file should read to and write - * from. + * from. This pointer and the string it points to must not be %NUL= L. * * This function creates a file in debugfs with the given name that * contains the value of the variable @value. If the @mode variable is so @@ -1136,6 +1136,9 @@ static const struct file_operations fops_str_wo =3D { void debugfs_create_str(const char *name, umode_t mode, struct dentry *parent, char **value) { + if (WARN_ON(!value || !*value)) + return; + debugfs_create_mode_unsafe(name, mode, parent, value, &fops_str, &fops_str_ro, &fops_str_wo); } --=20 2.43.0