aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sysctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sysctl.c')
-rw-r--r--kernel/sysctl.c198
1 files changed, 0 insertions, 198 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 6a642d7ffa85..f82e955875c9 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2835,201 +2835,6 @@ int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2835 2835
2836#endif /* CONFIG_PROC_FS */ 2836#endif /* CONFIG_PROC_FS */
2837 2837
2838
2839#ifdef CONFIG_SYSCTL_SYSCALL
2840/*
2841 * General sysctl support routines
2842 */
2843
2844/* The generic sysctl data routine (used if no strategy routine supplied) */
2845int sysctl_data(struct ctl_table *table,
2846 void __user *oldval, size_t __user *oldlenp,
2847 void __user *newval, size_t newlen)
2848{
2849 size_t len;
2850
2851 /* Get out of I don't have a variable */
2852 if (!table->data || !table->maxlen)
2853 return -ENOTDIR;
2854
2855 if (oldval && oldlenp) {
2856 if (get_user(len, oldlenp))
2857 return -EFAULT;
2858 if (len) {
2859 if (len > table->maxlen)
2860 len = table->maxlen;
2861 if (copy_to_user(oldval, table->data, len))
2862 return -EFAULT;
2863 if (put_user(len, oldlenp))
2864 return -EFAULT;
2865 }
2866 }
2867
2868 if (newval && newlen) {
2869 if (newlen > table->maxlen)
2870 newlen = table->maxlen;
2871
2872 if (copy_from_user(table->data, newval, newlen))
2873 return -EFAULT;
2874 }
2875 return 1;
2876}
2877
2878/* The generic string strategy routine: */
2879int sysctl_string(struct ctl_table *table,
2880 void __user *oldval, size_t __user *oldlenp,
2881 void __user *newval, size_t newlen)
2882{
2883 if (!table->data || !table->maxlen)
2884 return -ENOTDIR;
2885
2886 if (oldval && oldlenp) {
2887 size_t bufsize;
2888 if (get_user(bufsize, oldlenp))
2889 return -EFAULT;
2890 if (bufsize) {
2891 size_t len = strlen(table->data), copied;
2892
2893 /* This shouldn't trigger for a well-formed sysctl */
2894 if (len > table->maxlen)
2895 len = table->maxlen;
2896
2897 /* Copy up to a max of bufsize-1 bytes of the string */
2898 copied = (len >= bufsize) ? bufsize - 1 : len;
2899
2900 if (copy_to_user(oldval, table->data, copied) ||
2901 put_user(0, (char __user *)(oldval + copied)))
2902 return -EFAULT;
2903 if (put_user(len, oldlenp))
2904 return -EFAULT;
2905 }
2906 }
2907 if (newval && newlen) {
2908 size_t len = newlen;
2909 if (len > table->maxlen)
2910 len = table->maxlen;
2911 if(copy_from_user(table->data, newval, len))
2912 return -EFAULT;
2913 if (len == table->maxlen)
2914 len--;
2915 ((char *) table->data)[len] = 0;
2916 }
2917 return 1;
2918}
2919
2920/*
2921 * This function makes sure that all of the integers in the vector
2922 * are between the minimum and maximum values given in the arrays
2923 * table->extra1 and table->extra2, respectively.
2924 */
2925int sysctl_intvec(struct ctl_table *table,
2926 void __user *oldval, size_t __user *oldlenp,
2927 void __user *newval, size_t newlen)
2928{
2929
2930 if (newval && newlen) {
2931 int __user *vec = (int __user *) newval;
2932 int *min = (int *) table->extra1;
2933 int *max = (int *) table->extra2;
2934 size_t length;
2935 int i;
2936
2937 if (newlen % sizeof(int) != 0)
2938 return -EINVAL;
2939
2940 if (!table->extra1 && !table->extra2)
2941 return 0;
2942
2943 if (newlen > table->maxlen)
2944 newlen = table->maxlen;
2945 length = newlen / sizeof(int);
2946
2947 for (i = 0; i < length; i++) {
2948 int value;
2949 if (get_user(value, vec + i))
2950 return -EFAULT;
2951 if (min && value < min[i])
2952 return -EINVAL;
2953 if (max && value > max[i])
2954 return -EINVAL;
2955 }
2956 }
2957 return 0;
2958}
2959
2960/* Strategy function to convert jiffies to seconds */
2961int sysctl_jiffies(struct ctl_table *table,
2962 void __user *oldval, size_t __user *oldlenp,
2963 void __user *newval, size_t newlen)
2964{
2965 if (oldval && oldlenp) {
2966 size_t olen;
2967
2968 if (get_user(olen, oldlenp))
2969 return -EFAULT;
2970 if (olen) {
2971 int val;
2972
2973 if (olen < sizeof(int))
2974 return -EINVAL;
2975
2976 val = *(int *)(table->data) / HZ;
2977 if (put_user(val, (int __user *)oldval))
2978 return -EFAULT;
2979 if (put_user(sizeof(int), oldlenp))
2980 return -EFAULT;
2981 }
2982 }
2983 if (newval && newlen) {
2984 int new;
2985 if (newlen != sizeof(int))
2986 return -EINVAL;
2987 if (get_user(new, (int __user *)newval))
2988 return -EFAULT;
2989 *(int *)(table->data) = new*HZ;
2990 }
2991 return 1;
2992}
2993
2994/* Strategy function to convert jiffies to seconds */
2995int sysctl_ms_jiffies(struct ctl_table *table,
2996 void __user *oldval, size_t __user *oldlenp,
2997 void __user *newval, size_t newlen)
2998{
2999 if (oldval && oldlenp) {
3000 size_t olen;
3001
3002 if (get_user(olen, oldlenp))
3003 return -EFAULT;
3004 if (olen) {
3005 int val;
3006
3007 if (olen < sizeof(int))
3008 return -EINVAL;
3009
3010 val = jiffies_to_msecs(*(int *)(table->data));
3011 if (put_user(val, (int __user *)oldval))
3012 return -EFAULT;
3013 if (put_user(sizeof(int), oldlenp))
3014 return -EFAULT;
3015 }
3016 }
3017 if (newval && newlen) {
3018 int new;
3019 if (newlen != sizeof(int))
3020 return -EINVAL;
3021 if (get_user(new, (int __user *)newval))
3022 return -EFAULT;
3023 *(int *)(table->data) = msecs_to_jiffies(new);
3024 }
3025 return 1;
3026}
3027
3028
3029
3030#else /* CONFIG_SYSCTL_SYSCALL */
3031
3032
3033int sysctl_data(struct ctl_table *table, 2838int sysctl_data(struct ctl_table *table,
3034 void __user *oldval, size_t __user *oldlenp, 2839 void __user *oldval, size_t __user *oldlenp,
3035 void __user *newval, size_t newlen) 2840 void __user *newval, size_t newlen)
@@ -3065,9 +2870,6 @@ int sysctl_ms_jiffies(struct ctl_table *table,
3065 return -ENOSYS; 2870 return -ENOSYS;
3066} 2871}
3067 2872
3068#endif /* CONFIG_SYSCTL_SYSCALL */
3069
3070
3071/* 2873/*
3072 * No sense putting this after each symbol definition, twice, 2874 * No sense putting this after each symbol definition, twice,
3073 * exception granted :-) 2875 * exception granted :-)