diff mbox series

[v3,2/3] sysctl/coda: Fixes timeout bounds

Message ID 20250306123514.386434-3-nicolas.bouchinet@clip-os.org (mailing list archive)
State Handled Elsewhere
Headers show
Series Fixes multiple sysctl bound checks | expand

Commit Message

Nicolas Bouchinet March 6, 2025, 12:35 p.m. UTC
From: Nicolas Bouchinet <nicolas.bouchinet@ssi.gouv.fr>

Bound coda timeout sysctl writings between SYSCTL_ZERO
and SYSCTL_INT_MAX.

The proc_handler has thus been updated to proc_dointvec_minmax.

coda_timeout type has been updated from an unsigned long to an unsigned
int since it is typically set to some value well under a minute.

Signed-off-by: Nicolas Bouchinet <nicolas.bouchinet@ssi.gouv.fr>

---

Changes since v2:
https://lore.kernel.org/all/20250224095826.16458-4-nicolas.bouchinet@clip-os.org/

* Changed coda_timeout type from unsigned long to unsigned int as
  suggested by Joel Granados and Jan Harkes.

---
 fs/coda/coda_int.h | 2 +-
 fs/coda/sysctl.c   | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fs/coda/coda_int.h b/fs/coda/coda_int.h
index f82b59c9dd287..c7fc4c5a77d58 100644
--- a/fs/coda/coda_int.h
+++ b/fs/coda/coda_int.h
@@ -6,7 +6,7 @@  struct dentry;
 struct file;
 
 extern struct file_system_type coda_fs_type;
-extern unsigned long coda_timeout;
+extern unsigned int coda_timeout;
 extern int coda_hard;
 extern int coda_fake_statfs;
 
diff --git a/fs/coda/sysctl.c b/fs/coda/sysctl.c
index 0df46f09b6cc5..d6f8206c51575 100644
--- a/fs/coda/sysctl.c
+++ b/fs/coda/sysctl.c
@@ -20,7 +20,9 @@  static const struct ctl_table coda_table[] = {
 		.data		= &coda_timeout,
 		.maxlen		= sizeof(int),
 		.mode		= 0644,
-		.proc_handler	= proc_dointvec
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= SYSCTL_ZERO,
+		.extra2		= SYSCTL_INT_MAX,
 	},
 	{
 		.procname	= "hard",