Skip to content

Commit f221e72

Browse files
Alexey Dobriyantorvalds
authored andcommitted
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>
1 parent f40cbaa commit f221e72

16 files changed

Lines changed: 56 additions & 73 deletions

File tree

‎arch/frv/kernel/pm.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static int cmode_procctl(ctl_table *ctl, int write, struct file *filp,
211211
return try_set_cmode(new_cmode)?:*lenp;
212212
}
213213

214-
static int cmode_sysctl(ctl_table *table, int __user *name, int nlen,
214+
static int cmode_sysctl(ctl_table *table,
215215
void __user *oldval, size_t __user *oldlenp,
216216
void __user *newval, size_t newlen)
217217
{
@@ -314,7 +314,7 @@ static int p0_procctl(ctl_table *ctl, int write, struct file *filp,
314314
return try_set_p0(new_p0)?:*lenp;
315315
}
316316

317-
static int p0_sysctl(ctl_table *table, int __user *name, int nlen,
317+
static int p0_sysctl(ctl_table *table,
318318
void __user *oldval, size_t __user *oldlenp,
319319
void __user *newval, size_t newlen)
320320
{
@@ -358,7 +358,7 @@ static int cm_procctl(ctl_table *ctl, int write, struct file *filp,
358358
return try_set_cm(new_cm)?:*lenp;
359359
}
360360

361-
static int cm_sysctl(ctl_table *table, int __user *name, int nlen,
361+
static int cm_sysctl(ctl_table *table,
362362
void __user *oldval, size_t __user *oldlenp,
363363
void __user *newval, size_t newlen)
364364
{

‎arch/mips/lasat/sysctl.c‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,13 @@
3838
#endif
3939

4040
/* 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,
4242
void *oldval, size_t *oldlenp,
4343
void *newval, size_t newlen)
4444
{
4545
int r;
4646

47-
r = sysctl_string(table, name,
48-
nlen, oldval, oldlenp, newval, newlen);
47+
r = sysctl_string(table, oldval, oldlenp, newval, newlen);
4948
if (r < 0)
5049
return r;
5150

@@ -113,13 +112,13 @@ int proc_dolasatrtc(ctl_table *table, int write, struct file *filp,
113112
#endif
114113

115114
/* Sysctl for setting the IP addresses */
116-
int sysctl_lasat_intvec(ctl_table *table, int *name, int nlen,
115+
int sysctl_lasat_intvec(ctl_table *table,
117116
void *oldval, size_t *oldlenp,
118117
void *newval, size_t newlen)
119118
{
120119
int r;
121120

122-
r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen);
121+
r = sysctl_intvec(table, oldval, oldlenp, newval, newlen);
123122
if (r < 0)
124123
return r;
125124

@@ -131,7 +130,7 @@ int sysctl_lasat_intvec(ctl_table *table, int *name, int nlen,
131130

132131
#ifdef CONFIG_DS1603
133132
/* Same for RTC */
134-
int sysctl_lasat_rtc(ctl_table *table, int *name, int nlen,
133+
int sysctl_lasat_rtc(ctl_table *table,
135134
void *oldval, size_t *oldlenp,
136135
void *newval, size_t newlen)
137136
{
@@ -140,7 +139,7 @@ int sysctl_lasat_rtc(ctl_table *table, int *name, int nlen,
140139
rtctmp = read_persistent_clock();
141140
if (rtctmp < 0)
142141
rtctmp = 0;
143-
r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen);
142+
r = sysctl_intvec(table, oldval, oldlenp, newval, newlen);
144143
if (r < 0)
145144
return r;
146145
if (newval && newlen)
@@ -211,13 +210,13 @@ int proc_lasat_ip(ctl_table *table, int write, struct file *filp,
211210
}
212211
#endif
213212

214-
static int sysctl_lasat_prid(ctl_table *table, int *name, int nlen,
213+
static int sysctl_lasat_prid(ctl_table *table,
215214
void *oldval, size_t *oldlenp,
216215
void *newval, size_t newlen)
217216
{
218217
int r;
219218

220-
r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen);
219+
r = sysctl_intvec(table, oldval, oldlenp, newval, newlen);
221220
if (r < 0)
222221
return r;
223222
if (newval && newlen) {

‎drivers/char/random.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ static int proc_do_uuid(ctl_table *table, int write, struct file *filp,
12051205
return proc_dostring(&fake_table, write, filp, buffer, lenp, ppos);
12061206
}
12071207

1208-
static int uuid_strategy(ctl_table *table, int __user *name, int nlen,
1208+
static int uuid_strategy(ctl_table *table,
12091209
void __user *oldval, size_t __user *oldlenp,
12101210
void __user *newval, size_t newlen)
12111211
{

‎include/linux/sysctl.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ extern int sysctl_perm(struct ctl_table_root *root,
972972

973973
typedef struct ctl_table ctl_table;
974974

975-
typedef int ctl_handler (struct ctl_table *table, int __user *name, int nlen,
975+
typedef int ctl_handler (struct ctl_table *table,
976976
void __user *oldval, size_t __user *oldlenp,
977977
void __user *newval, size_t newlen);
978978

‎include/net/ip.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ extern void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 dport,
396396
int ipv4_doint_and_flush(ctl_table *ctl, int write,
397397
struct file* filp, void __user *buffer,
398398
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,
400400
void __user *oldval, size_t __user *oldlenp,
401401
void __user *newval, size_t newlen);
402402
#ifdef CONFIG_PROC_FS

‎include/net/ndisc.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,8 @@ extern int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl,
129129
void __user *buffer,
130130
size_t *lenp,
131131
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,
135134
void __user *newval, size_t newlen);
136135
#endif
137136

‎ipc/ipc_sysctl.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
131131

132132
#ifdef CONFIG_SYSCTL_SYSCALL
133133
/* 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,
135135
void __user *oldval, size_t __user *oldlenp,
136136
void __user *newval, size_t newlen)
137137
{
@@ -169,14 +169,13 @@ static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
169169
return 1;
170170
}
171171

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,
174174
void __user *newval, size_t newlen)
175175
{
176176
int rc;
177177

178-
rc = sysctl_ipc_data(table, name, nlen, oldval, oldlenp, newval,
179-
newlen);
178+
rc = sysctl_ipc_data(table, oldval, oldlenp, newval, newlen);
180179

181180
if (newval && newlen && rc > 0)
182181
/*

‎kernel/sysctl.c‎

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,6 @@ void register_sysctl_root(struct ctl_table_root *root)
15001500
/* Perform the actual read/write of a sysctl table entry. */
15011501
static int do_sysctl_strategy(struct ctl_table_root *root,
15021502
struct ctl_table *table,
1503-
int __user *name, int nlen,
15041503
void __user *oldval, size_t __user *oldlenp,
15051504
void __user *newval, size_t newlen)
15061505
{
@@ -1514,8 +1513,7 @@ static int do_sysctl_strategy(struct ctl_table_root *root,
15141513
return -EPERM;
15151514

15161515
if (table->strategy) {
1517-
rc = table->strategy(table, name, nlen, oldval, oldlenp,
1518-
newval, newlen);
1516+
rc = table->strategy(table, oldval, oldlenp, newval, newlen);
15191517
if (rc < 0)
15201518
return rc;
15211519
if (rc > 0)
@@ -1525,8 +1523,7 @@ static int do_sysctl_strategy(struct ctl_table_root *root,
15251523
/* If there is no strategy routine, or if the strategy returns
15261524
* zero, proceed with automatic r/w */
15271525
if (table->data && table->maxlen) {
1528-
rc = sysctl_data(table, name, nlen, oldval, oldlenp,
1529-
newval, newlen);
1526+
rc = sysctl_data(table, oldval, oldlenp, newval, newlen);
15301527
if (rc < 0)
15311528
return rc;
15321529
}
@@ -1558,7 +1555,7 @@ static int parse_table(int __user *name, int nlen,
15581555
table = table->child;
15591556
goto repeat;
15601557
}
1561-
error = do_sysctl_strategy(root, table, name, nlen,
1558+
error = do_sysctl_strategy(root, table,
15621559
oldval, oldlenp,
15631560
newval, newlen);
15641561
return error;
@@ -2707,7 +2704,7 @@ int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
27072704
*/
27082705

27092706
/* The generic sysctl data routine (used if no strategy routine supplied) */
2710-
int sysctl_data(struct ctl_table *table, int __user *name, int nlen,
2707+
int sysctl_data(struct ctl_table *table,
27112708
void __user *oldval, size_t __user *oldlenp,
27122709
void __user *newval, size_t newlen)
27132710
{
@@ -2741,7 +2738,7 @@ int sysctl_data(struct ctl_table *table, int __user *name, int nlen,
27412738
}
27422739

27432740
/* The generic string strategy routine: */
2744-
int sysctl_string(struct ctl_table *table, int __user *name, int nlen,
2741+
int sysctl_string(struct ctl_table *table,
27452742
void __user *oldval, size_t __user *oldlenp,
27462743
void __user *newval, size_t newlen)
27472744
{
@@ -2787,7 +2784,7 @@ int sysctl_string(struct ctl_table *table, int __user *name, int nlen,
27872784
* are between the minimum and maximum values given in the arrays
27882785
* table->extra1 and table->extra2, respectively.
27892786
*/
2790-
int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen,
2787+
int sysctl_intvec(struct ctl_table *table,
27912788
void __user *oldval, size_t __user *oldlenp,
27922789
void __user *newval, size_t newlen)
27932790
{
@@ -2823,7 +2820,7 @@ int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen,
28232820
}
28242821

28252822
/* Strategy function to convert jiffies to seconds */
2826-
int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen,
2823+
int sysctl_jiffies(struct ctl_table *table,
28272824
void __user *oldval, size_t __user *oldlenp,
28282825
void __user *newval, size_t newlen)
28292826
{
@@ -2857,7 +2854,7 @@ int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen,
28572854
}
28582855

28592856
/* Strategy function to convert jiffies to seconds */
2860-
int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen,
2857+
int sysctl_ms_jiffies(struct ctl_table *table,
28612858
void __user *oldval, size_t __user *oldlenp,
28622859
void __user *newval, size_t newlen)
28632860
{
@@ -2912,35 +2909,35 @@ asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
29122909
return error;
29132910
}
29142911

2915-
int sysctl_data(struct ctl_table *table, int __user *name, int nlen,
2912+
int sysctl_data(struct ctl_table *table,
29162913
void __user *oldval, size_t __user *oldlenp,
29172914
void __user *newval, size_t newlen)
29182915
{
29192916
return -ENOSYS;
29202917
}
29212918

2922-
int sysctl_string(struct ctl_table *table, int __user *name, int nlen,
2919+
int sysctl_string(struct ctl_table *table,
29232920
void __user *oldval, size_t __user *oldlenp,
29242921
void __user *newval, size_t newlen)
29252922
{
29262923
return -ENOSYS;
29272924
}
29282925

2929-
int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen,
2926+
int sysctl_intvec(struct ctl_table *table,
29302927
void __user *oldval, size_t __user *oldlenp,
29312928
void __user *newval, size_t newlen)
29322929
{
29332930
return -ENOSYS;
29342931
}
29352932

2936-
int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen,
2933+
int sysctl_jiffies(struct ctl_table *table,
29372934
void __user *oldval, size_t __user *oldlenp,
29382935
void __user *newval, size_t newlen)
29392936
{
29402937
return -ENOSYS;
29412938
}
29422939

2943-
int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen,
2940+
int sysctl_ms_jiffies(struct ctl_table *table,
29442941
void __user *oldval, size_t __user *oldlenp,
29452942
void __user *newval, size_t newlen)
29462943
{

‎kernel/utsname_sysctl.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
6060

6161
#ifdef CONFIG_SYSCTL_SYSCALL
6262
/* 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,
6464
void __user *oldval, size_t __user *oldlenp,
6565
void __user *newval, size_t newlen)
6666
{
@@ -69,8 +69,7 @@ static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
6969
write = newval && newlen;
7070
memcpy(&uts_table, table, sizeof(uts_table));
7171
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);
7473
put_uts(table, write, uts_table.data);
7574
return r;
7675
}

‎net/decnet/dn_dev.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static int max_priority[] = { 127 }; /* From DECnet spec */
166166

167167
static int dn_forwarding_proc(ctl_table *, int, struct file *,
168168
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,
170170
void __user *oldval, size_t __user *oldlenp,
171171
void __user *newval, size_t newlen);
172172

@@ -318,7 +318,7 @@ static int dn_forwarding_proc(ctl_table *table, int write,
318318
#endif
319319
}
320320

321-
static int dn_forwarding_sysctl(ctl_table *table, int __user *name, int nlen,
321+
static int dn_forwarding_sysctl(ctl_table *table,
322322
void __user *oldval, size_t __user *oldlenp,
323323
void __user *newval, size_t newlen)
324324
{

0 commit comments

Comments
 (0)