@@ -896,16 +896,34 @@ static int proc_taint(struct ctl_table *table, int write,
896896 return err ;
897897}
898898
899- #ifdef CONFIG_PRINTK
900- static int proc_dointvec_minmax_sysadmin (struct ctl_table * table , int write ,
899+ /**
900+ * proc_dointvec_minmax_sysadmin - read a vector of integers with min/max values
901+ * checking CAP_SYS_ADMIN on write
902+ * @table: the sysctl table
903+ * @write: %TRUE if this is a write to the sysctl file
904+ * @buffer: the user buffer
905+ * @lenp: the size of the user buffer
906+ * @ppos: file position
907+ *
908+ * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
909+ * values from/to the user buffer, treated as an ASCII string.
910+ *
911+ * This routine will ensure the values are within the range specified by
912+ * table->extra1 (min) and table->extra2 (max).
913+ *
914+ * Writing is only allowed when root has CAP_SYS_ADMIN.
915+ *
916+ * Returns 0 on success, -EPERM on permission failure or -EINVAL on write
917+ * when the range check fails.
918+ */
919+ int proc_dointvec_minmax_sysadmin (struct ctl_table * table , int write ,
901920 void * buffer , size_t * lenp , loff_t * ppos )
902921{
903922 if (write && !capable (CAP_SYS_ADMIN ))
904923 return - EPERM ;
905924
906925 return proc_dointvec_minmax (table , write , buffer , lenp , ppos );
907926}
908- #endif
909927
910928/**
911929 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
@@ -1591,6 +1609,12 @@ int proc_douintvec_minmax(struct ctl_table *table, int write,
15911609 return - ENOSYS ;
15921610}
15931611
1612+ int proc_dointvec_minmax_sysadmin (struct ctl_table * table , int write ,
1613+ void * buffer , size_t * lenp , loff_t * ppos )
1614+ {
1615+ return - ENOSYS ;
1616+ }
1617+
15941618int proc_dointvec_jiffies (struct ctl_table * table , int write ,
15951619 void * buffer , size_t * lenp , loff_t * ppos )
15961620{
@@ -3464,6 +3488,7 @@ EXPORT_SYMBOL(proc_douintvec);
34643488EXPORT_SYMBOL (proc_dointvec_jiffies );
34653489EXPORT_SYMBOL (proc_dointvec_minmax );
34663490EXPORT_SYMBOL_GPL (proc_douintvec_minmax );
3491+ EXPORT_SYMBOL (proc_dointvec_minmax_sysadmin );
34673492EXPORT_SYMBOL (proc_dointvec_userhz_jiffies );
34683493EXPORT_SYMBOL (proc_dointvec_ms_jiffies );
34693494EXPORT_SYMBOL (proc_dostring );
0 commit comments