Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sysctl: simplify ->strategy

name and nlen parameters passed to ->strategy hook are unused, remove
them. In general ->strategy hook should know what it's doing, and don't
do something tricky for which, say, pointer to original userspace array
may be needed (name).

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Acked-by: David S. Miller <davem@davemloft.net> [ networking bits ]
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Matt Mackall <mpm@selenic.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexey Dobriyan and committed by
Linus Torvalds
f221e726 f40cbaa5

+56 -73
+3 -3
arch/frv/kernel/pm.c
··· 211 211 return try_set_cmode(new_cmode)?:*lenp; 212 212 } 213 213 214 - static int cmode_sysctl(ctl_table *table, int __user *name, int nlen, 214 + static int cmode_sysctl(ctl_table *table, 215 215 void __user *oldval, size_t __user *oldlenp, 216 216 void __user *newval, size_t newlen) 217 217 { ··· 314 314 return try_set_p0(new_p0)?:*lenp; 315 315 } 316 316 317 - static int p0_sysctl(ctl_table *table, int __user *name, int nlen, 317 + static int p0_sysctl(ctl_table *table, 318 318 void __user *oldval, size_t __user *oldlenp, 319 319 void __user *newval, size_t newlen) 320 320 { ··· 358 358 return try_set_cm(new_cm)?:*lenp; 359 359 } 360 360 361 - static int cm_sysctl(ctl_table *table, int __user *name, int nlen, 361 + static int cm_sysctl(ctl_table *table, 362 362 void __user *oldval, size_t __user *oldlenp, 363 363 void __user *newval, size_t newlen) 364 364 {
+8 -9
arch/mips/lasat/sysctl.c
··· 38 38 #endif 39 39 40 40 /* Strategy function to write EEPROM after changing string entry */ 41 - int sysctl_lasatstring(ctl_table *table, int *name, int nlen, 41 + int sysctl_lasatstring(ctl_table *table, 42 42 void *oldval, size_t *oldlenp, 43 43 void *newval, size_t newlen) 44 44 { 45 45 int r; 46 46 47 - r = sysctl_string(table, name, 48 - nlen, oldval, oldlenp, newval, newlen); 47 + r = sysctl_string(table, oldval, oldlenp, newval, newlen); 49 48 if (r < 0) 50 49 return r; 51 50 ··· 112 113 #endif 113 114 114 115 /* Sysctl for setting the IP addresses */ 115 - int sysctl_lasat_intvec(ctl_table *table, int *name, int nlen, 116 + int sysctl_lasat_intvec(ctl_table *table, 116 117 void *oldval, size_t *oldlenp, 117 118 void *newval, size_t newlen) 118 119 { 119 120 int r; 120 121 121 - r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen); 122 + r = sysctl_intvec(table, oldval, oldlenp, newval, newlen); 122 123 if (r < 0) 123 124 return r; 124 125 ··· 130 131 131 132 #ifdef CONFIG_DS1603 132 133 /* Same for RTC */ 133 - int sysctl_lasat_rtc(ctl_table *table, int *name, int nlen, 134 + int sysctl_lasat_rtc(ctl_table *table, 134 135 void *oldval, size_t *oldlenp, 135 136 void *newval, size_t newlen) 136 137 { ··· 139 140 rtctmp = read_persistent_clock(); 140 141 if (rtctmp < 0) 141 142 rtctmp = 0; 142 - r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen); 143 + r = sysctl_intvec(table, oldval, oldlenp, newval, newlen); 143 144 if (r < 0) 144 145 return r; 145 146 if (newval && newlen) ··· 210 211 } 211 212 #endif 212 213 213 - static int sysctl_lasat_prid(ctl_table *table, int *name, int nlen, 214 + static int sysctl_lasat_prid(ctl_table *table, 214 215 void *oldval, size_t *oldlenp, 215 216 void *newval, size_t newlen) 216 217 { 217 218 int r; 218 219 219 - r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen); 220 + r = sysctl_intvec(table, oldval, oldlenp, newval, newlen); 220 221 if (r < 0) 221 222 return r; 222 223 if (newval && newlen) {
+1 -1
drivers/char/random.c
··· 1205 1205 return proc_dostring(&fake_table, write, filp, buffer, lenp, ppos); 1206 1206 } 1207 1207 1208 - static int uuid_strategy(ctl_table *table, int __user *name, int nlen, 1208 + static int uuid_strategy(ctl_table *table, 1209 1209 void __user *oldval, size_t __user *oldlenp, 1210 1210 void __user *newval, size_t newlen) 1211 1211 {
+1 -1
include/linux/sysctl.h
··· 972 972 973 973 typedef struct ctl_table ctl_table; 974 974 975 - typedef int ctl_handler (struct ctl_table *table, int __user *name, int nlen, 975 + typedef int ctl_handler (struct ctl_table *table, 976 976 void __user *oldval, size_t __user *oldlenp, 977 977 void __user *newval, size_t newlen); 978 978
+1 -1
include/net/ip.h
··· 396 396 int ipv4_doint_and_flush(ctl_table *ctl, int write, 397 397 struct file* filp, void __user *buffer, 398 398 size_t *lenp, loff_t *ppos); 399 - int ipv4_doint_and_flush_strategy(ctl_table *table, int __user *name, int nlen, 399 + int ipv4_doint_and_flush_strategy(ctl_table *table, 400 400 void __user *oldval, size_t __user *oldlenp, 401 401 void __user *newval, size_t newlen); 402 402 #ifdef CONFIG_PROC_FS
+2 -3
include/net/ndisc.h
··· 129 129 void __user *buffer, 130 130 size_t *lenp, 131 131 loff_t *ppos); 132 - int ndisc_ifinfo_sysctl_strategy(ctl_table *ctl, int __user *name, 133 - int nlen, void __user *oldval, 134 - size_t __user *oldlenp, 132 + int ndisc_ifinfo_sysctl_strategy(ctl_table *ctl, 133 + void __user *oldval, size_t __user *oldlenp, 135 134 void __user *newval, size_t newlen); 136 135 #endif 137 136
+4 -5
ipc/ipc_sysctl.c
··· 131 131 132 132 #ifdef CONFIG_SYSCTL_SYSCALL 133 133 /* The generic sysctl ipc data routine. */ 134 - static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen, 134 + static int sysctl_ipc_data(ctl_table *table, 135 135 void __user *oldval, size_t __user *oldlenp, 136 136 void __user *newval, size_t newlen) 137 137 { ··· 169 169 return 1; 170 170 } 171 171 172 - static int sysctl_ipc_registered_data(ctl_table *table, int __user *name, 173 - int nlen, void __user *oldval, size_t __user *oldlenp, 172 + static int sysctl_ipc_registered_data(ctl_table *table, 173 + void __user *oldval, size_t __user *oldlenp, 174 174 void __user *newval, size_t newlen) 175 175 { 176 176 int rc; 177 177 178 - rc = sysctl_ipc_data(table, name, nlen, oldval, oldlenp, newval, 179 - newlen); 178 + rc = sysctl_ipc_data(table, oldval, oldlenp, newval, newlen); 180 179 181 180 if (newval && newlen && rc > 0) 182 181 /*
+13 -16
kernel/sysctl.c
··· 1500 1500 /* Perform the actual read/write of a sysctl table entry. */ 1501 1501 static int do_sysctl_strategy(struct ctl_table_root *root, 1502 1502 struct ctl_table *table, 1503 - int __user *name, int nlen, 1504 1503 void __user *oldval, size_t __user *oldlenp, 1505 1504 void __user *newval, size_t newlen) 1506 1505 { ··· 1513 1514 return -EPERM; 1514 1515 1515 1516 if (table->strategy) { 1516 - rc = table->strategy(table, name, nlen, oldval, oldlenp, 1517 - newval, newlen); 1517 + rc = table->strategy(table, oldval, oldlenp, newval, newlen); 1518 1518 if (rc < 0) 1519 1519 return rc; 1520 1520 if (rc > 0) ··· 1523 1525 /* If there is no strategy routine, or if the strategy returns 1524 1526 * zero, proceed with automatic r/w */ 1525 1527 if (table->data && table->maxlen) { 1526 - rc = sysctl_data(table, name, nlen, oldval, oldlenp, 1527 - newval, newlen); 1528 + rc = sysctl_data(table, oldval, oldlenp, newval, newlen); 1528 1529 if (rc < 0) 1529 1530 return rc; 1530 1531 } ··· 1555 1558 table = table->child; 1556 1559 goto repeat; 1557 1560 } 1558 - error = do_sysctl_strategy(root, table, name, nlen, 1561 + error = do_sysctl_strategy(root, table, 1559 1562 oldval, oldlenp, 1560 1563 newval, newlen); 1561 1564 return error; ··· 2704 2707 */ 2705 2708 2706 2709 /* The generic sysctl data routine (used if no strategy routine supplied) */ 2707 - int sysctl_data(struct ctl_table *table, int __user *name, int nlen, 2710 + int sysctl_data(struct ctl_table *table, 2708 2711 void __user *oldval, size_t __user *oldlenp, 2709 2712 void __user *newval, size_t newlen) 2710 2713 { ··· 2738 2741 } 2739 2742 2740 2743 /* The generic string strategy routine: */ 2741 - int sysctl_string(struct ctl_table *table, int __user *name, int nlen, 2744 + int sysctl_string(struct ctl_table *table, 2742 2745 void __user *oldval, size_t __user *oldlenp, 2743 2746 void __user *newval, size_t newlen) 2744 2747 { ··· 2784 2787 * are between the minimum and maximum values given in the arrays 2785 2788 * table->extra1 and table->extra2, respectively. 2786 2789 */ 2787 - int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen, 2790 + int sysctl_intvec(struct ctl_table *table, 2788 2791 void __user *oldval, size_t __user *oldlenp, 2789 2792 void __user *newval, size_t newlen) 2790 2793 { ··· 2820 2823 } 2821 2824 2822 2825 /* Strategy function to convert jiffies to seconds */ 2823 - int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen, 2826 + int sysctl_jiffies(struct ctl_table *table, 2824 2827 void __user *oldval, size_t __user *oldlenp, 2825 2828 void __user *newval, size_t newlen) 2826 2829 { ··· 2854 2857 } 2855 2858 2856 2859 /* Strategy function to convert jiffies to seconds */ 2857 - int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen, 2860 + int sysctl_ms_jiffies(struct ctl_table *table, 2858 2861 void __user *oldval, size_t __user *oldlenp, 2859 2862 void __user *newval, size_t newlen) 2860 2863 { ··· 2909 2912 return error; 2910 2913 } 2911 2914 2912 - int sysctl_data(struct ctl_table *table, int __user *name, int nlen, 2915 + int sysctl_data(struct ctl_table *table, 2913 2916 void __user *oldval, size_t __user *oldlenp, 2914 2917 void __user *newval, size_t newlen) 2915 2918 { 2916 2919 return -ENOSYS; 2917 2920 } 2918 2921 2919 - int sysctl_string(struct ctl_table *table, int __user *name, int nlen, 2922 + int sysctl_string(struct ctl_table *table, 2920 2923 void __user *oldval, size_t __user *oldlenp, 2921 2924 void __user *newval, size_t newlen) 2922 2925 { 2923 2926 return -ENOSYS; 2924 2927 } 2925 2928 2926 - int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen, 2929 + int sysctl_intvec(struct ctl_table *table, 2927 2930 void __user *oldval, size_t __user *oldlenp, 2928 2931 void __user *newval, size_t newlen) 2929 2932 { 2930 2933 return -ENOSYS; 2931 2934 } 2932 2935 2933 - int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen, 2936 + int sysctl_jiffies(struct ctl_table *table, 2934 2937 void __user *oldval, size_t __user *oldlenp, 2935 2938 void __user *newval, size_t newlen) 2936 2939 { 2937 2940 return -ENOSYS; 2938 2941 } 2939 2942 2940 - int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen, 2943 + int sysctl_ms_jiffies(struct ctl_table *table, 2941 2944 void __user *oldval, size_t __user *oldlenp, 2942 2945 void __user *newval, size_t newlen) 2943 2946 {
+2 -3
kernel/utsname_sysctl.c
··· 60 60 61 61 #ifdef CONFIG_SYSCTL_SYSCALL 62 62 /* The generic string strategy routine: */ 63 - static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen, 63 + static int sysctl_uts_string(ctl_table *table, 64 64 void __user *oldval, size_t __user *oldlenp, 65 65 void __user *newval, size_t newlen) 66 66 { ··· 69 69 write = newval && newlen; 70 70 memcpy(&uts_table, table, sizeof(uts_table)); 71 71 uts_table.data = get_uts(table, write); 72 - r = sysctl_string(&uts_table, name, nlen, 73 - oldval, oldlenp, newval, newlen); 72 + r = sysctl_string(&uts_table, oldval, oldlenp, newval, newlen); 74 73 put_uts(table, write, uts_table.data); 75 74 return r; 76 75 }
+2 -2
net/decnet/dn_dev.c
··· 166 166 167 167 static int dn_forwarding_proc(ctl_table *, int, struct file *, 168 168 void __user *, size_t *, loff_t *); 169 - static int dn_forwarding_sysctl(ctl_table *table, int __user *name, int nlen, 169 + static int dn_forwarding_sysctl(ctl_table *table, 170 170 void __user *oldval, size_t __user *oldlenp, 171 171 void __user *newval, size_t newlen); 172 172 ··· 318 318 #endif 319 319 } 320 320 321 - static int dn_forwarding_sysctl(ctl_table *table, int __user *name, int nlen, 321 + static int dn_forwarding_sysctl(ctl_table *table, 322 322 void __user *oldval, size_t __user *oldlenp, 323 323 void __user *newval, size_t newlen) 324 324 {
+2 -2
net/decnet/sysctl_net_decnet.c
··· 132 132 } 133 133 134 134 135 - static int dn_node_address_strategy(ctl_table *table, int __user *name, int nlen, 135 + static int dn_node_address_strategy(ctl_table *table, 136 136 void __user *oldval, size_t __user *oldlenp, 137 137 void __user *newval, size_t newlen) 138 138 { ··· 217 217 } 218 218 219 219 220 - static int dn_def_dev_strategy(ctl_table *table, int __user *name, int nlen, 220 + static int dn_def_dev_strategy(ctl_table *table, 221 221 void __user *oldval, size_t __user *oldlenp, 222 222 void __user *newval, size_t newlen) 223 223 {
+3 -4
net/ipv4/devinet.c
··· 1283 1283 return ret; 1284 1284 } 1285 1285 1286 - static int devinet_conf_sysctl(ctl_table *table, int __user *name, int nlen, 1286 + static int devinet_conf_sysctl(ctl_table *table, 1287 1287 void __user *oldval, size_t __user *oldlenp, 1288 1288 void __user *newval, size_t newlen) 1289 1289 { ··· 1379 1379 return ret; 1380 1380 } 1381 1381 1382 - int ipv4_doint_and_flush_strategy(ctl_table *table, int __user *name, int nlen, 1382 + int ipv4_doint_and_flush_strategy(ctl_table *table, 1383 1383 void __user *oldval, size_t __user *oldlenp, 1384 1384 void __user *newval, size_t newlen) 1385 1385 { 1386 - int ret = devinet_conf_sysctl(table, name, nlen, oldval, oldlenp, 1387 - newval, newlen); 1386 + int ret = devinet_conf_sysctl(table, oldval, oldlenp, newval, newlen); 1388 1387 struct net *net = table->extra2; 1389 1388 1390 1389 if (ret == 1)
+1 -6
net/ipv4/route.c
··· 2908 2908 } 2909 2909 2910 2910 static int ipv4_sysctl_rtcache_flush_strategy(ctl_table *table, 2911 - int __user *name, 2912 - int nlen, 2913 2911 void __user *oldval, 2914 2912 size_t __user *oldlenp, 2915 2913 void __user *newval, ··· 2970 2972 } 2971 2973 2972 2974 static int ipv4_sysctl_rt_secret_interval_strategy(ctl_table *table, 2973 - int __user *name, 2974 - int nlen, 2975 2975 void __user *oldval, 2976 2976 size_t __user *oldlenp, 2977 2977 void __user *newval, 2978 2978 size_t newlen) 2979 2979 { 2980 2980 int old = ip_rt_secret_interval; 2981 - int ret = sysctl_jiffies(table, name, nlen, oldval, oldlenp, newval, 2982 - newlen); 2981 + int ret = sysctl_jiffies(table, oldval, oldlenp, newval, newlen); 2983 2982 2984 2983 rt_secret_reschedule(old); 2985 2984
+9 -9
net/ipv4/sysctl_net_ipv4.c
··· 64 64 } 65 65 66 66 /* Validate changes from sysctl interface. */ 67 - static int ipv4_sysctl_local_port_range(ctl_table *table, int __user *name, 68 - int nlen, void __user *oldval, 67 + static int ipv4_sysctl_local_port_range(ctl_table *table, 68 + void __user *oldval, 69 69 size_t __user *oldlenp, 70 70 void __user *newval, size_t newlen) 71 71 { ··· 80 80 }; 81 81 82 82 inet_get_local_port_range(range, range + 1); 83 - ret = sysctl_intvec(&tmp, name, nlen, oldval, oldlenp, newval, newlen); 83 + ret = sysctl_intvec(&tmp, oldval, oldlenp, newval, newlen); 84 84 if (ret == 0 && newval && newlen) { 85 85 if (range[1] < range[0]) 86 86 ret = -EINVAL; ··· 109 109 return ret; 110 110 } 111 111 112 - static int sysctl_tcp_congestion_control(ctl_table *table, int __user *name, 113 - int nlen, void __user *oldval, 112 + static int sysctl_tcp_congestion_control(ctl_table *table, 113 + void __user *oldval, 114 114 size_t __user *oldlenp, 115 115 void __user *newval, size_t newlen) 116 116 { ··· 122 122 int ret; 123 123 124 124 tcp_get_default_congestion_control(val); 125 - ret = sysctl_string(&tbl, name, nlen, oldval, oldlenp, newval, newlen); 125 + ret = sysctl_string(&tbl, oldval, oldlenp, newval, newlen); 126 126 if (ret == 1 && newval && newlen) 127 127 ret = tcp_set_default_congestion_control(val); 128 128 return ret; ··· 165 165 return ret; 166 166 } 167 167 168 - static int strategy_allowed_congestion_control(ctl_table *table, int __user *name, 169 - int nlen, void __user *oldval, 168 + static int strategy_allowed_congestion_control(ctl_table *table, 169 + void __user *oldval, 170 170 size_t __user *oldlenp, 171 171 void __user *newval, 172 172 size_t newlen) ··· 179 179 return -ENOMEM; 180 180 181 181 tcp_get_available_congestion_control(tbl.data, tbl.maxlen); 182 - ret = sysctl_string(&tbl, name, nlen, oldval, oldlenp, newval, newlen); 182 + ret = sysctl_string(&tbl, oldval, oldlenp, newval, newlen); 183 183 if (ret == 1 && newval && newlen) 184 184 ret = tcp_set_allowed_congestion_control(tbl.data); 185 185 kfree(tbl.data);
-1
net/ipv6/addrconf.c
··· 3982 3982 } 3983 3983 3984 3984 static int addrconf_sysctl_forward_strategy(ctl_table *table, 3985 - int __user *name, int nlen, 3986 3985 void __user *oldval, 3987 3986 size_t __user *oldlenp, 3988 3987 void __user *newval, size_t newlen)
+4 -7
net/ipv6/ndisc.c
··· 1730 1730 return ret; 1731 1731 } 1732 1732 1733 - int ndisc_ifinfo_sysctl_strategy(ctl_table *ctl, int __user *name, 1734 - int nlen, void __user *oldval, 1735 - size_t __user *oldlenp, 1733 + int ndisc_ifinfo_sysctl_strategy(ctl_table *ctl, 1734 + void __user *oldval, size_t __user *oldlenp, 1736 1735 void __user *newval, size_t newlen) 1737 1736 { 1738 1737 struct net_device *dev = ctl->extra1; ··· 1744 1745 1745 1746 switch (ctl->ctl_name) { 1746 1747 case NET_NEIGH_REACHABLE_TIME: 1747 - ret = sysctl_jiffies(ctl, name, nlen, 1748 - oldval, oldlenp, newval, newlen); 1748 + ret = sysctl_jiffies(ctl, oldval, oldlenp, newval, newlen); 1749 1749 break; 1750 1750 case NET_NEIGH_RETRANS_TIME_MS: 1751 1751 case NET_NEIGH_REACHABLE_TIME_MS: 1752 - ret = sysctl_ms_jiffies(ctl, name, nlen, 1753 - oldval, oldlenp, newval, newlen); 1752 + ret = sysctl_ms_jiffies(ctl, oldval, oldlenp, newval, newlen); 1754 1753 break; 1755 1754 default: 1756 1755 ret = 0;