From nobody Mon Feb 9 15:50:30 2026 Received: from mail-yx1-f52.google.com (mail-yx1-f52.google.com [74.125.224.52]) (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 A97F035BDC7 for ; Wed, 3 Dec 2025 16:23:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764779017; cv=none; b=GyuHPsWjMRPakKD1/arr5/HlwEx0rgN2Rao41rgNzWx39hEupav7FFqT/Po2FCCIS/HYqlq+ugFruHLaGdAJlCPPUO59pMF4mP43GerHr/W77f2xNeq5X+ixBDbMWovuV9SnoZPOt1iPISi2a0SmtC2JvAVroWElEqwoGw6GSyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764779017; c=relaxed/simple; bh=IZvatrejqQTMAZAs55HnDtJ6l1UGli2aSM/VGzyF64M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LTSnzF5/1om+ErHUuimnqljUsR5Y6fPSZP0leKHR8zNOfsmDuZyDOHwLJVOIjZnxKS6G7fti6zRlZyDBnjF+v1QvaKSbfcbAkybC/DrNdJfGgrNfHO/K9LpyRXWHb4O4cfgpkmhFXPWYuxlQ24X8hAFy8EorACxCpSVVpuaB5a0= 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=Vzxiy5Z3; arc=none smtp.client-ip=74.125.224.52 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="Vzxiy5Z3" Received: by mail-yx1-f52.google.com with SMTP id 956f58d0204a3-642fcb38f35so5423690d50.1 for ; Wed, 03 Dec 2025 08:23:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764779014; x=1765383814; 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=BD9kPlC9NqK4/C2x8UYFTQBB7a0NtQWd16jS1I2SUnE=; b=Vzxiy5Z3syVFxXbv2YJu/n6ByE5xezc3Bc414Iqm2g3lBMqUeG5yqgwSwatHEWIyYh MbH7O6MmQfR4U+vhUX/r36k/nG0D7tZzf1n45wppm2RhGQbyCCEdzdcrWMnhx7aPN12k QI6a4ti0p+2RDuRfU9ZFTWXpE3O3wr/Gy0sG0bmgKa7MffWUe3EhDFamDprIHF3QrSWX vuM/WJ32wZxHhpuS5RZQjzUqdI3b1SIuFzQqEHvcejbLQU1ScN9tgQ3RWx47XVcq++xp g38fIDqDwkHoa/8y8AJnRCY/gO4sk8dDUdmUQkdtrHgbQTtLCA3CP0eVJQci8WcXP8Ol zQyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764779014; x=1765383814; 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=BD9kPlC9NqK4/C2x8UYFTQBB7a0NtQWd16jS1I2SUnE=; b=L4aUELTMosEhgoHPAlE7fZtiGiR9a+uYPHhaecEh2TmwZz6GvXRNw6/x3jwntdvKCT fzZyzpSM245zqyoCWbW8XhnfOAUPCgUNpXF8FocaCcpp9XWqCTMkLyK0+m7itHRb3ZeP SGvfHtjg+tNFT/M284c1CiB6NVUUEXmcyz9ywSc2w63BZ4XXCWnJFiFlUH2NkC2fNiFv S6aTeAcIWuYuHNehalUxPkY2SpzlCEq5I64fSjMYwyYBPHZ278CMQ7XNTXjOydYrsAUD OyN8kHVOD1aS/m6zeaiUgywIL00VBjIxuBt71DJuppRvWnGcHLZ+Wf6v6On3zMIbpF4F EQZQ== X-Forwarded-Encrypted: i=1; AJvYcCWBiy1uo8BIryB8ds1zP7nHYn7TXzVzTL/UndhF8R7OfglCJEyFK3SOMMuz9aW0+xWRJiheDM+ELkN2Bj8=@vger.kernel.org X-Gm-Message-State: AOJu0YzBeLk9xZYpdEj7aL0VkKahdqhErbCKirxdVOhGVIdjoYNRZD4Z R3hGY2voveg/6ORC/dPKTjwdEESD+9y8FaIy174k0+LYKRV6H/PgAWbMF/ZoBA== X-Gm-Gg: ASbGnct9nzZYDbkGmeET32KQjiItf67KYrUIozFsEw8uFSq3rDVTF2j8Bcnp4ALJldD GV0dtuDr45fXXPCCI8FPF4IUWeb6Nu7sY/l7XvTWuDqUw00njPvtWmAtuQp/YOXmyfKV3Hsfbo+ MZW2cIti17uF6g2WYSbDmeCbc6lAyne87Ag4VrcbrEjZMrEUcsTZr1x1BUeONAhfgpYnwoMbCWk lxgiw2OCJtmqYiOI6TjYszbEJz5MS+vrQqrxUFiOPUN6H+H9wVN1SreYL+Eyb+4VpuW5+rZ1qbY 4W3TeCdNwO379MV389k92EAMvyCOWJ6KFgS4wz/DLi0X2OQUGrm7tNR3NWdSqnAYUGcJqVXn1NT Y/k9FmNU5SvyR2s5xLqFFN8c4YJu+S6WO4LNvfeeuQ8XvA5Wpv9a55YyUP97HKDvrzHIfIirfon L/6m+Ai+TIFVnTlEtGug== X-Google-Smtp-Source: AGHT+IED9MOFMxvYSeb8SzBPTCp8AtkRM45d5US6WkMtf3ZGLjHaRGAjGtBn2tkqfezw7s+564T5/Q== X-Received: by 2002:a05:690e:134a:b0:640:caa5:57bf with SMTP id 956f58d0204a3-64436fab865mr2201474d50.24.1764779014070; Wed, 03 Dec 2025 08:23:34 -0800 (PST) Received: from localhost ([2601:346:0:79bd:3422:8bf9:97bc:b085]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-6433c089431sm7456743d50.10.2025.12.03.08.23.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Dec 2025 08:23:33 -0800 (PST) From: "Yury Norov (NVIDIA)" To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Andy Shevchenko , Christophe Leroy , Randy Dunlap , Ingo Molnar , Jani Nikula , Joonas Lahtinen , David Laight , Petr Pavlu , Andi Shyti , Rodrigo Vivi , Tvrtko Ursulin , Daniel Gomez , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Andrew Morton , linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: "Yury Norov (NVIDIA)" Subject: [PATCH v2 3/4] kernel.h: move VERIFY_OCTAL_PERMISSIONS() to sysfs.h Date: Wed, 3 Dec 2025 11:23:24 -0500 Message-ID: <20251203162329.280182-4-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251203162329.280182-1-yury.norov@gmail.com> References: <20251203162329.280182-1-yury.norov@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" The macro is related to sysfs, but is defined in kernel.h. Move it to the proper header, and unload the generic kernel.h. Now that the macro is removed from kernel.h, linux/moduleparam.h is decoupled, and kernel.h inclusion can be removed. Acked-by: Randy Dunlap Tested-by: Randy Dunlap Reviewed-by: Andy Shevchenko Signed-off-by: Yury Norov (NVIDIA) Reviewed-by: Petr Pavlu --- Documentation/filesystems/sysfs.rst | 2 +- include/linux/kernel.h | 12 ------------ include/linux/moduleparam.h | 2 +- include/linux/sysfs.h | 13 +++++++++++++ 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Documentation/filesystems/sysfs.rst b/Documentation/filesystem= s/sysfs.rst index 2703c04af7d0..ffcef4d6bc8d 100644 --- a/Documentation/filesystems/sysfs.rst +++ b/Documentation/filesystems/sysfs.rst @@ -120,7 +120,7 @@ is equivalent to doing:: .store =3D store_foo, }; =20 -Note as stated in include/linux/kernel.h "OTHER_WRITABLE? Generally +Note as stated in include/linux/sysfs.h "OTHER_WRITABLE? Generally considered a bad idea." so trying to set a sysfs file writable for everyone will fail reverting to RO mode for "Others". =20 diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 61d63c57bc2d..5b879bfea948 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -389,16 +389,4 @@ static inline void ftrace_dump(enum ftrace_dump_mode o= ops_dump_mode) { } # define REBUILD_DUE_TO_DYNAMIC_FTRACE #endif =20 -/* Permissions on a sysfs file: you didn't miss the 0 prefix did you? */ -#define VERIFY_OCTAL_PERMISSIONS(perms) \ - (BUILD_BUG_ON_ZERO((perms) < 0) + \ - BUILD_BUG_ON_ZERO((perms) > 0777) + \ - /* USER_READABLE >=3D GROUP_READABLE >=3D OTHER_READABLE */ \ - BUILD_BUG_ON_ZERO((((perms) >> 6) & 4) < (((perms) >> 3) & 4)) + \ - BUILD_BUG_ON_ZERO((((perms) >> 3) & 4) < ((perms) & 4)) + \ - /* USER_WRITABLE >=3D GROUP_WRITABLE */ \ - BUILD_BUG_ON_ZERO((((perms) >> 6) & 2) < (((perms) >> 3) & 2)) + \ - /* OTHER_WRITABLE? Generally considered a bad idea. */ \ - BUILD_BUG_ON_ZERO((perms) & 2) + \ - (perms)) #endif diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index ca7c8107c7c8..dd2d990b2611 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include =20 /* diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index 9a25a2911652..15ee3ef33991 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -798,4 +798,17 @@ static inline void sysfs_put(struct kernfs_node *kn) kernfs_put(kn); } =20 +/* Permissions on a sysfs file: you didn't miss the 0 prefix did you? */ +#define VERIFY_OCTAL_PERMISSIONS(perms) \ + (BUILD_BUG_ON_ZERO((perms) < 0) + \ + BUILD_BUG_ON_ZERO((perms) > 0777) + \ + /* USER_READABLE >=3D GROUP_READABLE >=3D OTHER_READABLE */ \ + BUILD_BUG_ON_ZERO((((perms) >> 6) & 4) < (((perms) >> 3) & 4)) + \ + BUILD_BUG_ON_ZERO((((perms) >> 3) & 4) < ((perms) & 4)) + \ + /* USER_WRITABLE >=3D GROUP_WRITABLE */ \ + BUILD_BUG_ON_ZERO((((perms) >> 6) & 2) < (((perms) >> 3) & 2)) + \ + /* OTHER_WRITABLE? Generally considered a bad idea. */ \ + BUILD_BUG_ON_ZERO((perms) & 2) + \ + (perms)) + #endif /* _SYSFS_H_ */ --=20 2.43.0