@@ -896,16 +896,34 @@ static int proc_taint(struct ctl_table *table, int write,
896
896
return err ;
897
897
}
898
898
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 ,
901
920
void * buffer , size_t * lenp , loff_t * ppos )
902
921
{
903
922
if (write && !capable (CAP_SYS_ADMIN ))
904
923
return - EPERM ;
905
924
906
925
return proc_dointvec_minmax (table , write , buffer , lenp , ppos );
907
926
}
908
- #endif
909
927
910
928
/**
911
929
* 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,
1591
1609
return - ENOSYS ;
1592
1610
}
1593
1611
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
+
1594
1618
int proc_dointvec_jiffies (struct ctl_table * table , int write ,
1595
1619
void * buffer , size_t * lenp , loff_t * ppos )
1596
1620
{
@@ -3464,6 +3488,7 @@ EXPORT_SYMBOL(proc_douintvec);
3464
3488
EXPORT_SYMBOL (proc_dointvec_jiffies );
3465
3489
EXPORT_SYMBOL (proc_dointvec_minmax );
3466
3490
EXPORT_SYMBOL_GPL (proc_douintvec_minmax );
3491
+ EXPORT_SYMBOL (proc_dointvec_minmax_sysadmin );
3467
3492
EXPORT_SYMBOL (proc_dointvec_userhz_jiffies );
3468
3493
EXPORT_SYMBOL (proc_dointvec_ms_jiffies );
3469
3494
EXPORT_SYMBOL (proc_dostring );
0 commit comments