From nobody Mon Apr 6 23:08:24 2026 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.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 A8E083F8800 for ; Tue, 17 Mar 2026 19:00:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773774031; cv=none; b=jarmsuibBR3COG0bFw2HX7TOx9X9ZdmHjCKUWlcGg0WvXvqAY+l/FHVDrcKEBthUcK4FBD5ymP3Erq6THpPjyiHoCa7spiAyGDM3LPXuQxVHPHNcEqI7EPEgl/+ADS/vgMRi+pbNBo334X3zmm8MMrNkEvNiYK7yAyKX7mEfiys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773774031; c=relaxed/simple; bh=IMmJ1Uxode6XtjAurdNk51CWF8bJbOqEiTkikuLK0kA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QMLEBxQYwycqYpmRd7RZVaxx8x92P/DF+rSgQ3pPgUPUu6nTFVQnbFyieU0Vrbt+Omep7AHv4W0cJ0qgZlTEIAKYiws2/80rn/bw2ftCou609NdpRVlU/IyThY8mT5pgycoLtIGmEPmIUBZU3dpjGfNLFXauEhsYnOTzJawim0A= 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=OyqRYDRt; arc=none smtp.client-ip=209.85.216.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="OyqRYDRt" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-35b95e21ccaso101523a91.0 for ; Tue, 17 Mar 2026 12:00:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773774028; x=1774378828; 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=N2RhT/UW1C987y6pJfFZ8RN5SYowSBt72Kbbj9XR2UU=; b=OyqRYDRtonn4blxvkOO0RDAMk6TP7ykxtPAbYAEm0lQYMiUo3j5byudPtp/Mg/5XQx Ga1+uqUNRflDa5XZznCqdhygMoWoN6y7OeVJiehZhr7Nfm/Ab9u8lzZYmdVbaLGVS8m/ FeQMQghWlAhSEpfwvpU3bTBPivhihdR2K5BdGLeztuyMPofOhZ4JIwDzB+SDkur3EWrG EdZtOZJ59l2IsDLf+uRxMVkZKM5PlHT9ybDwjyTUIlXFjsEmnv9nEhzr6Ra99LvsSnSs R9pnh3rJYw/PTRo8lUvwWqbkHzPBGkmyAKOGuc0ALIO6dIYyphbAafnhdxqSD8vtwZFa swog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773774028; x=1774378828; 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=N2RhT/UW1C987y6pJfFZ8RN5SYowSBt72Kbbj9XR2UU=; b=cLP7dO1btAHQBLjV9+r/XSPVnN+ZxjyMh3Mul1+F8baHJqka8jimQv5jXBbK9owtSZ 3VfKuEocbHdruV42afwKm6rE90cen5bkv9UXoImVoRT6M9/yd39chNBmI6HDzRV68/6b ul7ZhzU0Ni9UL/TWQaObCrxhLb9wQzugZEtOZaq5EOsjsAC9NEI+vl9zJZtYL+cJH8YL rzMVvewM1CfcgIB5HXlp0ml2lxcIobVzUNwoSHLrFD2ricI+UmaNADBMvK4BmvdAWZLu tVtpEtzXmAAHXY3BKw6+b8JOwWCTzWj/Zqx/oZDF5fp35buDm7KTHidujzRiVF2yrtz5 wQiw== X-Gm-Message-State: AOJu0YygN8uTAUJkNjTDy3NBv+qEH29Anuo6Z2DTPWYZFIklrlTg7bQ+ NkmZn9C9hf5R18YOtG2b8FIhwFywssYAmA/PtlScDT+5gQSF1xOllLLO X-Gm-Gg: ATEYQzwzS2spRQEhkV796sHToVJuF2oBcFf8+TrqC/anEx+YPXefGRRs4DDWxwJez8Q H1v3HaVAfFHPJ5LC+mNVVq1bSHYT60yqIrZVNTQKD8MYxVWRBMsOcyC0xr2Fum42gEV2LbzTZnr S9FzmVzY6suI0ZIh2LjupqSlZKrjq88q88a3+w/YnyeT1n+rP/lmysmqRyXdKHJllQACq7FHxIO j8ZWIVahYNeR1LkUTyU4kfxJX5M1C226JEl6kuesxcb3UH9crnd7upB6UaSxp4ZgmZqEWc6whG0 geVMsSNRcgjrYN4Qny8Pt3+vFbO8H9+Q+r9PowuXpNHLBaTGEyZZsRHVDneSArGTeWOgTZexwhh 3tyaU3IqPx1SdtuS9OqXxaJmFq9yE9+yo5oFEMWcp3w7yUHNzCgifEvW5hr8nFdBR1hBS+uL5i3 QML5ZaPdrS9RtF5Ll3Bbi3O63zdK9NTZxlUs04FP7D5bR88KehV7g7frCSr8jo0uvVEttois2/v imgPHflb47ZibEDJ47w4QBtZRyR4QovnhRGKMf1NyDyNAkCq7K/8pAsXjv21ubkSCAuog== X-Received: by 2002:a17:90b:35cb:b0:35b:92ba:66e4 with SMTP id 98e67ed59e1d1-35bb99b2ce2mr555490a91.7.1773774027874; Tue, 17 Mar 2026 12:00:27 -0700 (PDT) Received: from 2045D.localdomain (76.sub-72-110-123.myvzw.com. [72.110.123.76]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35bba5a2c60sm196240a91.9.2026.03.17.12.00.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2026 12:00:27 -0700 (PDT) From: Gui-Dong Han To: gregkh@linuxfoundation.org, dakr@kernel.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, driver-core@lists.linux.dev, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-sound@vger.kernel.org, akaieurus@gmail.com, me@ziyao.cc, Gui-Dong Han , yangshiguang Subject: [PATCH 1/4] debugfs: check for NULL pointer in debugfs_create_str() Date: Wed, 18 Mar 2026 02:59:10 +0800 Message-ID: <20260317185920.43387-2-hanguidong02@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260317185920.43387-1-hanguidong02@gmail.com> References: <20260317185920.43387-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 --- 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