From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f41.google.com (mail-dl1-f41.google.com [74.125.82.41]) (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 444771684A4 for ; Mon, 23 Mar 2026 09:00:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774256433; cv=none; b=byp6Day/K88dsldvWNezT8R5ya/URVMPJXHXVYZOzuD0ZTn2xRdfVRlFdegOojQHrdgcFiA01Fs3JX/iJVjSuKvA2UhrBODZ9EBK4V6HBNFUi0dMcD4b8G7eu3KKXhA/LKGqwVW4x398MfalqF+baBgar5eKjRWGWDk1w05s7gY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774256433; c=relaxed/simple; bh=qQrOSHf0WJEFpQioIq+31gpjWdkGTgezHWFp2FWOmTA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=YLKBMeYD5Jhhh7YlYsUJ3+/ileAyKRj+fYU72Ejop5troUeuf3kllKhVz5y2ci6gzPnPIer9bSeHXxeIVGzNb9gTu1bRVRInDxu6XWu4b6RP81cvTX6CfcO/psHt7Otr4TDjznPyyZESAdkP7wu+EDLOz8LyiWgKipc/E2HKHcY= 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=AO1bs9pK; arc=none smtp.client-ip=74.125.82.41 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="AO1bs9pK" Received: by mail-dl1-f41.google.com with SMTP id a92af1059eb24-12a74039dc6so1665273c88.0 for ; Mon, 23 Mar 2026 02:00:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1774256431; x=1774861231; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=273aLwz/em1jqAyb3LReQqEgJUsg7bfCsBCihZh13oI=; b=AO1bs9pK3lKokmz4hxc8K7CXqoDs3iky16tgRBRzIABUtd4TZhHtgWEVchYcLHpb9C sHeLMGIL99+mxv58Ay7t67KqfP2XepXca5I4VruRsxVEVicRaKpAdwcNE5n9qxG7opnS OHx9CcRmqI2aKL3RSwVPvvryrYMwGpN8p3EUhCkU2IYRyeIA0J6tk5ajfTLA5XwldF77 DnmyEuJ41rfXe1hfIu6hCEKGsRbGZfaM/NhtoBen6jW+8XXhS8PHs7hXMZJV/fafmwAJ lUU5G248W9LLwKdN4Prd/CCoVp12HiHkGpTmvbx10OwoDi5HYm+lW7ntlSeYa9gP7y0R 3SRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774256431; x=1774861231; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=273aLwz/em1jqAyb3LReQqEgJUsg7bfCsBCihZh13oI=; b=JcYCVM6r3KBNfyaphJEEzwbiyO/zMvDaZnlgvVdqrpHHcr9pDk39Ac0qVM6EFFsaQP dM9kV0Mh9tQ0YunirV9ta0GtwDtT7AwxqyzNPzDwOToIJ+KlxiSjFg79kLa35zp1NYQn EX1+MGfyRsTWnCK5mYzkXj7VFF2Ibb/qh0TFOcrTJaJMMe/vbtM9s6h/XNJkgjxDtSWA N9bjkkfh2yd6bIslz3OhwTGwnk3UvLlHg5fy62gQlSrYqJRVt2mm+Obmvy0/VX8C0DKR pFAqNcrig4W/gn7rM6G7EtTDNZb25PbNfuzJHCRhqO6cxUBr6THenuZ6yBeAkmU3eMlC mrxw== X-Forwarded-Encrypted: i=1; AJvYcCVVDvg5tF0TDrEgvhlx+XAAN4rWjMhc6dJUhhtihKd1Y0KgZAfRsqK5Svy/hM3q9JUZ3UQ2OW0RkGi93d8=@vger.kernel.org X-Gm-Message-State: AOJu0YyWNy+pg4r5mKQgYtDkbE9TjUbisD+AP8yUArAjVD4yOQSDRphB AABbyyRndmlrgd9CVRkfj4RVLuE4e9MG0TcrpYjcpbQjKgwu2ej2E4Wp X-Gm-Gg: ATEYQzx9uVX85GLF6M50jANl+MRq0p2VVVs8X42dkjq4aCmVU7uPUaZ9kQBis2o4gPN nPW0HChFxN+0wbFO0Bf1pKy5inRNXiPKZ8tJP3kqddB7+YWoP9rqvbKD/Orn7GCENeVF5vEXYq8 q96fok+b/++6YTGsw7J438Zq2wfBgQJHhoNdIrL/EH1YPMbMAtJzSsvAbcZxyoESz06LJzfwmBC ggWQng5wRDArxml/1oEdimavPw92OcoodVDOTpnWfQ8f4ps8Q0HhRf3Z98zfwECz2StDa+3c71t Nfpvflk312vcNz5gz+JfbSV8nUZgLdhShdoNTCU+MocWfwrZBhqumlZYLzFrAfcndpkZ40BKXvk CzT18ROhRfy5txrby5kFGZQnhF5suUknV0QODloTaD72dC5EBHJk8iwBe0iFgihh9BMFRdcOrp9 3fT1NPoSNRY2YLEwItkRP6SIYUAGQbDghT0+UMnhc6KVjkfNUaYRmE9EIHyXlWBYSWUK/GU0F36 5ftb0GPKMlz8L7l8HvuAZuDhZbYuEq8hdnxo8YiRRVWLXNyq8wapKqfVmK7y3YE4/w= X-Received: by 2002:a05:7022:252c:b0:128:c1be:152b with SMTP id a92af1059eb24-12a7263d77fmr4636197c88.4.1774256430993; Mon, 23 Mar 2026 02:00:30 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 02:00:30 -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 Subject: [PATCH v2 0/3] debugfs: disallow NULL string creation and fix callers Date: Mon, 23 Mar 2026 16:58:43 +0800 Message-ID: <20260323085930.88894-1-hanguidong02@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit A recent bug report [1] highlighted a NULL pointer dereference when reading a debugfs string file created with a NULL pointer. The community discussed the issue and agreed that creating string nodes with NULL is invalid and should be forbidden at creation time [2]. Since no fix was submitted following the discussion, I have implemented the agreed solution. Patch 1 modifies debugfs_create_str() to reject NULL pointers, returning early and triggering a WARN_ON to expose offending callers. Patch 2 is a code hygiene fix. While modifying the file, I noticed the EXPORT_SYMBOL_GPL for debugfs_create_str() was misplaced far away from the function body. This patch moves it to the correct location. I carefully audited existing callers across the kernel tree. Some drivers passing NULL have already been independently identified and fixed [3]. The remaining subsystem (soundwire) is addressed in patch 3 by initializing its string parameter to an empty string (""). The existing code correctly and safely handles empty strings. While auditing, I also noticed a devm_kstrdup/kfree mismatch in the interconnect subsystem which has been addressed in a separate patch [4]. Changes in v2: - Link to v1: https://lore.kernel.org/driver-core/20260317185920.43387-1-hanguidong02@gmail.com/ - Patch 1 & 2: No changes. - Patch 3: Rewritten to use kstrdup() instead of devm_kstrdup() to match debugfs's kfree() behavior. Moved initialization to sdw_debugfs_init() to correctly handle the global pointer and avoid overwriting during slave probe. - Patch 4 (drm/i915): Dropped. Further analysis confirmed those specific pointers are not passed to debugfs_create_str() [5]. [1] https://lore.kernel.org/lkml/17647e4c.d461.19b46144a4e.Coremail.yangshiguang1011@163.com/ [2] https://lore.kernel.org/lkml/2025122221-gag-malt-75ba@gregkh/ [3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8cc27f5c6dd1 [4] https://lore.kernel.org/linux-pm/20260318024815.7655-1-hanguidong02@gmail.com/ [5] https://lore.kernel.org/driver-core/8ac4b6ef2dfbc1dce0047dee55f2df609287a3ec@intel.com/ Gui-Dong Han (3): debugfs: check for NULL pointer in debugfs_create_str() debugfs: fix placement of EXPORT_SYMBOL_GPL for debugfs_create_str() soundwire: debugfs: initialize firmware_file to empty string drivers/soundwire/debugfs.c | 9 +++++++-- fs/debugfs/file.c | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) -- 2.43.0