linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Joel Granados <joel.granados@kernel.org>
To: Luis Chamberlain <mcgrof@kernel.org>,
	Petr Pavlu <petr.pavlu@suse.com>,
	 Sami Tolvanen <samitolvanen@google.com>,
	 Daniel Gomez <da.gomez@samsung.com>, Kees Cook <kees@kernel.org>,
	 Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,  Will Deacon <will@kernel.org>,
	Boqun Feng <boqun.feng@gmail.com>,
	 Waiman Long <longman@redhat.com>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	 Frederic Weisbecker <frederic@kernel.org>,
	 Neeraj Upadhyay <neeraj.upadhyay@kernel.org>,
	 Joel Fernandes <joel@joelfernandes.org>,
	 Josh Triplett <josh@joshtriplett.org>,
	Uladzislau Rezki <urezki@gmail.com>,
	 Steven Rostedt <rostedt@goodmis.org>,
	 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	 Lai Jiangshan <jiangshanlai@gmail.com>,
	Zqiang <qiang.zhang1211@gmail.com>,
	 Andrew Morton <akpm@linux-foundation.org>,
	 "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	 Helge Deller <deller@gmx.de>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 Jiri Slaby <jirislaby@kernel.org>
Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-fsdevel@vger.kernel.org, rcu@vger.kernel.org,
	linux-mm@kvack.org,  linux-parisc@vger.kernel.org,
	linux-serial@vger.kernel.org,
	 Joel Granados <joel.granados@kernel.org>
Subject: [PATCH 08/12] sysctl: Move tainted ctl_table into kernel/panic.c
Date: Fri, 09 May 2025 14:54:12 +0200	[thread overview]
Message-ID: <20250509-jag-mv_ctltables_iter2-v1-8-d0ad83f5f4c3@kernel.org> (raw)
In-Reply-To: <20250509-jag-mv_ctltables_iter2-v1-0-d0ad83f5f4c3@kernel.org>

Move the ctl_table with the "tainted" proc_name into kernel/panic.c.
With it moves the proc_tainted helper function.

This is part of a greater effort to move ctl tables into their
respective subsystems which will reduce the merge conflicts in
kernel/sysctl.c.

Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
 kernel/panic.c  | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 kernel/sysctl.c | 49 -------------------------------------------------
 2 files changed, 50 insertions(+), 49 deletions(-)

diff --git a/kernel/panic.c b/kernel/panic.c
index 047ea3215312c439950c6ec4674a91572146234d..213c6c9d6a750ff3d17f3cf530b37c619cd816f4 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -84,6 +84,50 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
 EXPORT_SYMBOL(panic_notifier_list);
 
 #ifdef CONFIG_SYSCTL
+
+/*
+ * Taint values can only be increased
+ * This means we can safely use a temporary.
+ */
+static int proc_taint(const struct ctl_table *table, int write,
+			       void *buffer, size_t *lenp, loff_t *ppos)
+{
+	struct ctl_table t;
+	unsigned long tmptaint = get_taint();
+	int err;
+
+	if (write && !capable(CAP_SYS_ADMIN))
+		return -EPERM;
+
+	t = *table;
+	t.data = &tmptaint;
+	err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
+	if (err < 0)
+		return err;
+
+	if (write) {
+		int i;
+
+		/*
+		 * If we are relying on panic_on_taint not producing
+		 * false positives due to userspace input, bail out
+		 * before setting the requested taint flags.
+		 */
+		if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
+			return -EINVAL;
+
+		/*
+		 * Poor man's atomic or. Not worth adding a primitive
+		 * to everyone's atomic.h for this
+		 */
+		for (i = 0; i < TAINT_FLAGS_COUNT; i++)
+			if ((1UL << i) & tmptaint)
+				add_taint(i, LOCKDEP_STILL_OK);
+	}
+
+	return err;
+}
+
 static const struct ctl_table kern_panic_table[] = {
 #ifdef CONFIG_SMP
 	{
@@ -96,6 +140,12 @@ static const struct ctl_table kern_panic_table[] = {
 		.extra2         = SYSCTL_ONE,
 	},
 #endif
+	{
+		.procname	= "tainted",
+		.maxlen		= sizeof(long),
+		.mode		= 0644,
+		.proc_handler	= proc_taint,
+	},
 	{
 		.procname	= "panic",
 		.data		= &panic_timeout,
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index ebcc7d75acd9fecbf3c10f31480c3cb6960cb53e..9d8db9cef11122993d850ab5c753e3da1cbfb5cc 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -731,49 +731,6 @@ int proc_douintvec(const struct ctl_table *table, int write, void *buffer,
 				 do_proc_douintvec_conv, NULL);
 }
 
-/*
- * Taint values can only be increased
- * This means we can safely use a temporary.
- */
-static int proc_taint(const struct ctl_table *table, int write,
-			       void *buffer, size_t *lenp, loff_t *ppos)
-{
-	struct ctl_table t;
-	unsigned long tmptaint = get_taint();
-	int err;
-
-	if (write && !capable(CAP_SYS_ADMIN))
-		return -EPERM;
-
-	t = *table;
-	t.data = &tmptaint;
-	err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
-	if (err < 0)
-		return err;
-
-	if (write) {
-		int i;
-
-		/*
-		 * If we are relying on panic_on_taint not producing
-		 * false positives due to userspace input, bail out
-		 * before setting the requested taint flags.
-		 */
-		if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
-			return -EINVAL;
-
-		/*
-		 * Poor man's atomic or. Not worth adding a primitive
-		 * to everyone's atomic.h for this
-		 */
-		for (i = 0; i < TAINT_FLAGS_COUNT; i++)
-			if ((1UL << i) & tmptaint)
-				add_taint(i, LOCKDEP_STILL_OK);
-	}
-
-	return err;
-}
-
 /**
  * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
  * @min: pointer to minimum allowable value
@@ -1557,12 +1514,6 @@ int proc_do_static_key(const struct ctl_table *table, int write,
 
 static const struct ctl_table kern_table[] = {
 #ifdef CONFIG_PROC_SYSCTL
-	{
-		.procname	= "tainted",
-		.maxlen 	= sizeof(long),
-		.mode		= 0644,
-		.proc_handler	= proc_taint,
-	},
 	{
 		.procname	= "sysctl_writes_strict",
 		.data		= &sysctl_writes_strict,

-- 
2.47.2




  parent reply	other threads:[~2025-05-09 12:55 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-09 12:54 [PATCH 00/12] sysctl: Move sysctls to their respective subsystems (second batch) Joel Granados
2025-05-09 12:54 ` [PATCH 01/12] module: Move modprobe_path and modules_disabled ctl_tables into the module subsys Joel Granados
2025-05-09 16:09   ` Luis Chamberlain
2025-05-13  7:37     ` Joel Granados
2025-05-15  8:04   ` Petr Pavlu
2025-05-15 10:04     ` Joel Granados
2025-05-15 12:45       ` Petr Pavlu
2025-05-19 15:20         ` Joel Granados
2025-05-09 12:54 ` [PATCH 02/12] locking/rtmutex: Move max_lock_depth into rtmutex.c Joel Granados
2025-05-09 15:49   ` Waiman Long
2025-05-09 18:56   ` Kees Cook
2025-05-09 12:54 ` [PATCH 03/12] rcu: Move rcu_stall related sysctls into rcu/tree_stall.h Joel Granados
2025-05-09 13:14   ` Joel Fernandes
2025-05-09 16:17   ` Luis Chamberlain
2025-05-09 19:03   ` Kees Cook
2025-05-09 12:54 ` [PATCH 04/12] mm: move randomize_va_space into memory.c Joel Granados
2025-05-09 16:16   ` Luis Chamberlain
2025-05-09 19:02   ` Kees Cook
2025-05-09 12:54 ` [PATCH 05/12] parisc/power: Move soft-power into power.c Joel Granados
2025-05-09 16:15   ` Luis Chamberlain
2025-05-09 19:02   ` Kees Cook
2025-05-09 12:54 ` [PATCH 06/12] fork: mv threads-max into kernel/fork.c Joel Granados
2025-05-09 16:14   ` Luis Chamberlain
2025-05-09 19:01   ` Kees Cook
2025-05-09 12:54 ` [PATCH 07/12] Input: sysrq: mv sysrq into drivers/tty/sysrq.c Joel Granados
2025-05-09 14:47   ` Greg Kroah-Hartman
2025-05-09 17:10   ` Kees Cook
2025-05-13  7:49     ` Joel Granados
2025-05-09 12:54 ` Joel Granados [this message]
2025-05-09 16:12   ` [PATCH 08/12] sysctl: Move tainted ctl_table into kernel/panic.c Luis Chamberlain
2025-05-09 19:00   ` Kees Cook
2025-05-09 12:54 ` [PATCH 09/12] sysctl: move cad_pid into kernel/pid.c Joel Granados
2025-05-09 16:13   ` Luis Chamberlain
2025-05-09 19:01   ` Kees Cook
2025-05-13  7:33     ` Joel Granados
2025-05-09 12:54 ` [PATCH 10/12] sysctl: Move sysctl_panic_on_stackoverflow to kernel/panic.c Joel Granados
2025-05-09 17:04   ` Kees Cook
2025-05-09 12:54 ` [PATCH 11/12] sysctl: Remove (very) old file changelog Joel Granados
2025-05-09 16:11   ` Luis Chamberlain
2025-05-09 18:57   ` Kees Cook
2025-05-09 12:54 ` [PATCH 12/12] sysctl: Remove superfluous includes from kernel/sysctl.c Joel Granados
2025-05-09 16:12   ` Luis Chamberlain
2025-05-09 18:57   ` Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250509-jag-mv_ctltables_iter2-v1-8-d0ad83f5f4c3@kernel.org \
    --to=joel.granados@kernel.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=akpm@linux-foundation.org \
    --cc=boqun.feng@gmail.com \
    --cc=da.gomez@samsung.com \
    --cc=deller@gmx.de \
    --cc=frederic@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jiangshanlai@gmail.com \
    --cc=jirislaby@kernel.org \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=kees@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mcgrof@kernel.org \
    --cc=mingo@redhat.com \
    --cc=neeraj.upadhyay@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=petr.pavlu@suse.com \
    --cc=qiang.zhang1211@gmail.com \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=samitolvanen@google.com \
    --cc=urezki@gmail.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox