From: wen.yang@linux.dev
To: Joel Granados <joel.granados@kernel.org>
Cc: Wen Yang <wen.yang@linux.dev>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 36/39] parport: move device sysctl context to priv
Date: Thu, 29 Oct 2026 00:35:15 +0800 [thread overview]
Message-ID: <99e864dc88f931ba5f065717bb5a9cb950b05eb7.1793204511.git.wen.yang@linux.dev> (raw)
In-Reply-To: <cover.1793204511.git.wen.yang@linux.dev>
From: Wen Yang <wen.yang@linux.dev>
The per-port table uses extra1 for both the spintime minimum and the
port context of the active and hardware entries. During registration,
the loop also assigns the port pointer to vars[0].extra1, overwriting
the minimum. A spintime write can consequently be checked against data
from struct parport instead of the intended minimum.
Move the port context to priv and use numeric bounds for spintime.
Keep probe_info in data and set priv only for the entries that need the
port. Separating context from bounds prevents this overwrite.
The spintime bug exists in the base tree and can also be fixed separately;
this RFC does not depend on that fix.
Signed-off-by: Wen Yang <wen.yang@linux.dev>
---
drivers/parport/procfs.c | 51 +++++++++++++++-------------------------
1 file changed, 19 insertions(+), 32 deletions(-)
diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
index 1bfafc2a5724..6f6d96c37a93 100644
--- a/drivers/parport/procfs.c
+++ b/drivers/parport/procfs.c
@@ -36,7 +36,7 @@
static int do_active_device(const struct ctl_table *table, int write,
void *result, size_t *lenp, loff_t *ppos)
{
- struct parport *port = (struct parport *)table->extra1;
+ struct parport *port = table->priv;
char buffer[256];
struct pardevice *dev;
int len = 0;
@@ -73,7 +73,7 @@ static int do_active_device(const struct ctl_table *table, int write,
static int do_autoprobe(const struct ctl_table *table, int write,
void *result, size_t *lenp, loff_t *ppos)
{
- struct parport_device_info *info = table->extra2;
+ struct parport_device_info *info = table->data;
const char *str;
char buffer[256];
int len = 0;
@@ -116,7 +116,7 @@ static int do_autoprobe(const struct ctl_table *table, int write,
static int do_hardware_base_addr(const struct ctl_table *table, int write,
void *result, size_t *lenp, loff_t *ppos)
{
- struct parport *port = (struct parport *)table->extra1;
+ struct parport *port = table->priv;
char buffer[64];
int len = 0;
@@ -143,7 +143,7 @@ static int do_hardware_base_addr(const struct ctl_table *table, int write,
static int do_hardware_irq(const struct ctl_table *table, int write,
void *result, size_t *lenp, loff_t *ppos)
{
- struct parport *port = (struct parport *)table->extra1;
+ struct parport *port = table->priv;
char buffer[20];
int len = 0;
@@ -170,7 +170,7 @@ static int do_hardware_irq(const struct ctl_table *table, int write,
static int do_hardware_dma(const struct ctl_table *table, int write,
void *result, size_t *lenp, loff_t *ppos)
{
- struct parport *port = (struct parport *)table->extra1;
+ struct parport *port = table->priv;
char buffer[20];
int len = 0;
@@ -197,7 +197,7 @@ static int do_hardware_dma(const struct ctl_table *table, int write,
static int do_hardware_modes(const struct ctl_table *table, int write,
void *result, size_t *lenp, loff_t *ppos)
{
- struct parport *port = (struct parport *)table->extra1;
+ struct parport *port = table->priv;
char buffer[40];
int len = 0;
@@ -236,19 +236,6 @@ do { \
return 0;
}
-static const unsigned long parport_min_timeslice_value =
-PARPORT_MIN_TIMESLICE_VALUE;
-
-static const unsigned long parport_max_timeslice_value =
-PARPORT_MAX_TIMESLICE_VALUE;
-
-static const int parport_min_spintime_value =
-PARPORT_MIN_SPINTIME_VALUE;
-
-static const int parport_max_spintime_value =
-PARPORT_MAX_SPINTIME_VALUE;
-
-
struct parport_sysctl_table {
struct ctl_table_header *port_header;
struct ctl_table_header *devices_header;
@@ -270,8 +257,8 @@ static const struct parport_sysctl_table parport_sysctl_template = {
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
- .extra1 = (void*) &parport_min_spintime_value,
- .extra2 = (void*) &parport_max_spintime_value
+ .min = PARPORT_MIN_SPINTIME_VALUE,
+ .max = PARPORT_MAX_SPINTIME_VALUE,
},
{
.procname = "base-addr",
@@ -367,8 +354,8 @@ parport_device_sysctl_template = {
.maxlen = sizeof(unsigned long),
.mode = 0644,
.proc_handler = proc_doulongvec_ms_jiffies_minmax,
- .extra1 = (void*) &parport_min_timeslice_value,
- .extra2 = (void*) &parport_max_timeslice_value
+ .min = PARPORT_MIN_TIMESLICE_VALUE,
+ .max = PARPORT_MAX_TIMESLICE_VALUE,
},
},
{
@@ -397,8 +384,8 @@ parport_default_sysctl_table = {
.maxlen = sizeof(parport_default_timeslice),
.mode = 0644,
.proc_handler = proc_doulongvec_ms_jiffies_minmax,
- .extra1 = (void*) &parport_min_timeslice_value,
- .extra2 = (void*) &parport_max_timeslice_value
+ .min = PARPORT_MIN_TIMESLICE_VALUE,
+ .max = PARPORT_MAX_TIMESLICE_VALUE,
},
{
.procname = "spintime",
@@ -406,8 +393,8 @@ parport_default_sysctl_table = {
.maxlen = sizeof(parport_default_spintime),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
- .extra1 = (void*) &parport_min_spintime_value,
- .extra2 = (void*) &parport_max_spintime_value
+ .min = PARPORT_MIN_SPINTIME_VALUE,
+ .max = PARPORT_MAX_SPINTIME_VALUE,
},
}
};
@@ -422,15 +409,15 @@ int parport_proc_register(struct parport *port)
if (t == NULL)
return -ENOMEM;
- t->device_dir[0].extra1 = port;
+ t->device_dir[0].priv = port;
t->vars[0].data = &port->spintime;
- for (i = 0; i < 5; i++) {
- t->vars[i].extra1 = port;
+ for (i = 1; i < 5; i++)
+ t->vars[i].priv = port;
#ifdef CONFIG_PARPORT_1284
- t->vars[5 + i].extra2 = &port->probe_info[i];
+ for (i = 0; i < 5; i++)
+ t->vars[5 + i].data = &port->probe_info[i];
#endif /* IEEE 1284 support */
- }
tmp_dir_path = kasprintf(GFP_KERNEL, "dev/parport/%s/devices", port->name);
if (!tmp_dir_path) {
--
2.25.1
next prev parent reply other threads:[~2026-10-28 16:38 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 16:34 [RFC PATCH 00/39] sysctl: replace overloaded extra pointers with typed bounds and context wen.yang
2026-10-28 16:34 ` [RFC PATCH 01/39] " wen.yang
2026-10-28 21:09 ` David Laight
2026-10-28 16:34 ` [RFC PATCH 02/39] test_sysctl: convert bounds to numeric values wen.yang
2026-10-28 16:34 ` [RFC PATCH 03/39] sysctl: add KUnit coverage for numeric bounds and handlers wen.yang
2026-10-28 16:34 ` [RFC PATCH 04/39] sysctl: cover runtime ranges and context lifecycles in KUnit wen.yang
2026-10-28 16:34 ` [RFC PATCH 05/39] sysctl: cover priv in KUnit and the debug test module wen.yang
2026-10-28 16:34 ` [RFC PATCH 06/39] sysctl: convert core table bounds to numeric values wen.yang
2026-10-28 16:34 ` [RFC PATCH 07/39] sysctl: store architecture sysctl bounds by value wen.yang
2026-10-28 16:34 ` [RFC PATCH 08/39] sysctl: store crypto " wen.yang
2026-10-28 16:34 ` [RFC PATCH 09/39] sysctl: store device " wen.yang
2026-10-28 16:34 ` [RFC PATCH 10/39] sysctl: store filesystem " wen.yang
2026-10-28 16:34 ` [RFC PATCH 11/39] sysctl: store message-queue " wen.yang
2026-10-28 16:34 ` [RFC PATCH 12/39] sysctl: store kernel " wen.yang
2026-10-28 16:34 ` [RFC PATCH 13/39] sysctl: store memory-management " wen.yang
2026-10-28 16:34 ` [RFC PATCH 14/39] sysctl: store IPv6 scalar " wen.yang
2026-10-28 16:34 ` [RFC PATCH 15/39] sysctl: store netfilter " wen.yang
2026-10-28 16:34 ` [RFC PATCH 16/39] sysctl: store RPC " wen.yang
2026-10-28 16:34 ` [RFC PATCH 17/39] sysctl: store remaining network " wen.yang
2026-10-28 16:34 ` [RFC PATCH 18/39] sysctl: store security " wen.yang
2026-10-28 16:34 ` [RFC PATCH 19/39] io_uring: store its " wen.yang
2026-10-28 16:34 ` [RFC PATCH 20/39] sysctl: refresh dynamic scheduler and PID bounds per call wen.yang
2026-10-28 16:35 ` [RFC PATCH 21/39] sysctl: refresh device-dependent " wen.yang
2026-10-28 16:35 ` [RFC PATCH 22/39] sysctl: refresh namespace IPC " wen.yang
2026-10-28 16:35 ` [RFC PATCH 23/39] yama: preserve scope locking with numeric sysctl bounds wen.yang
2026-10-28 16:35 ` [RFC PATCH 24/39] net: refresh core sysctl limits without bound pointers wen.yang
2026-10-28 16:35 ` [RFC PATCH 25/39] sctp: resolve numeric ranges from the current namespace wen.yang
2026-10-28 16:35 ` [RFC PATCH 26/39] rds: preserve live reconnect limits with numeric bounds wen.yang
2026-10-28 16:35 ` [RFC PATCH 27/39] ipv4: preserve live and vector bounds with numeric sysctls wen.yang
2026-10-28 16:35 ` [RFC PATCH 28/39] net: refresh fragment and remaining dynamic sysctl bounds wen.yang
2026-10-28 16:35 ` [RFC PATCH 29/39] neighbour: derive sysctl ownership independently of bounds wen.yang
2026-10-28 16:35 ` [RFC PATCH 30/39] net: resolve sysctl owners from their backing data wen.yang
2026-10-28 16:35 ` [RFC PATCH 31/39] ipvs: derive sysctl ownership from numeric storage wen.yang
2026-10-28 16:35 ` [RFC PATCH 32/39] sysctl: remove obsolete nr_open bound variables wen.yang
2026-10-28 16:35 ` [RFC PATCH 33/39] ipv6: move address sysctl context to priv wen.yang
2026-10-28 16:35 ` [RFC PATCH 34/39] ipv4: move device " wen.yang
2026-10-28 16:35 ` [RFC PATCH 35/39] netfilter: move logger " wen.yang
2026-10-28 16:35 ` wen.yang [this message]
2026-10-28 16:35 ` [RFC PATCH 37/39] net: move namespace " wen.yang
2026-10-28 16:35 ` [RFC PATCH 38/39] arm64: move vector-length " wen.yang
2026-10-28 16:35 ` [RFC PATCH 39/39] sysctl: remove the extra pointers and the compatibility bounds read wen.yang
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=99e864dc88f931ba5f065717bb5a9cb950b05eb7.1793204511.git.wen.yang@linux.dev \
--to=wen.yang@linux.dev \
--cc=joel.granados@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.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
all inboxes | Powered by JetHome®