Skip to content

Commit 98c89cd

Browse files
committed
Merge branch 'bkl/procfs' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing
* 'bkl/procfs' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing: sunrpc: Include missing smp_lock.h procfs: Kill the bkl in ioctl procfs: Push down the bkl from ioctl procfs: Use generic_file_llseek in /proc/vmcore procfs: Use generic_file_llseek in /proc/kmsg procfs: Use generic_file_llseek in /proc/kcore procfs: Kill BKL in llseek on proc base
2 parents 164d44f + 99df95a commit 98c89cd

File tree

8 files changed

+55
-16
lines changed

8 files changed

+55
-16
lines changed

drivers/char/i8k.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/seq_file.h>
2424
#include <linux/dmi.h>
2525
#include <linux/capability.h>
26+
#include <linux/smp_lock.h>
2627
#include <asm/uaccess.h>
2728
#include <asm/io.h>
2829

@@ -82,16 +83,15 @@ module_param(fan_mult, int, 0);
8283
MODULE_PARM_DESC(fan_mult, "Factor to multiply fan speed with");
8384

8485
static int i8k_open_fs(struct inode *inode, struct file *file);
85-
static int i8k_ioctl(struct inode *, struct file *, unsigned int,
86-
unsigned long);
86+
static long i8k_ioctl(struct file *, unsigned int, unsigned long);
8787

8888
static const struct file_operations i8k_fops = {
8989
.owner = THIS_MODULE,
9090
.open = i8k_open_fs,
9191
.read = seq_read,
9292
.llseek = seq_lseek,
9393
.release = single_release,
94-
.ioctl = i8k_ioctl,
94+
.unlocked_ioctl = i8k_ioctl,
9595
};
9696

9797
struct smm_regs {
@@ -307,8 +307,8 @@ static int i8k_get_dell_signature(int req_fn)
307307
return regs.eax == 1145651527 && regs.edx == 1145392204 ? 0 : -1;
308308
}
309309

310-
static int i8k_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
311-
unsigned long arg)
310+
static int
311+
i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg)
312312
{
313313
int val = 0;
314314
int speed;
@@ -395,6 +395,17 @@ static int i8k_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
395395
return 0;
396396
}
397397

398+
static long i8k_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
399+
{
400+
long ret;
401+
402+
lock_kernel();
403+
ret = i8k_ioctl_unlocked(fp, cmd, arg);
404+
unlock_kernel();
405+
406+
return ret;
407+
}
408+
398409
/*
399410
* Print the information for /proc/i8k.
400411
*/

drivers/isdn/divert/divert_procfs.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/sched.h>
2121
#include <linux/isdnif.h>
2222
#include <net/net_namespace.h>
23+
#include <linux/smp_lock.h>
2324
#include "isdn_divert.h"
2425

2526

@@ -177,9 +178,7 @@ isdn_divert_close(struct inode *ino, struct file *filep)
177178
/*********/
178179
/* IOCTL */
179180
/*********/
180-
static int
181-
isdn_divert_ioctl(struct inode *inode, struct file *file,
182-
uint cmd, ulong arg)
181+
static int isdn_divert_ioctl_unlocked(struct file *file, uint cmd, ulong arg)
183182
{
184183
divert_ioctl dioctl;
185184
int i;
@@ -258,14 +257,25 @@ isdn_divert_ioctl(struct inode *inode, struct file *file,
258257
return copy_to_user((void __user *)arg, &dioctl, sizeof(dioctl)) ? -EFAULT : 0;
259258
} /* isdn_divert_ioctl */
260259

260+
static long isdn_divert_ioctl(struct file *file, uint cmd, ulong arg)
261+
{
262+
long ret;
263+
264+
lock_kernel();
265+
ret = isdn_divert_ioctl_unlocked(file, cmd, arg);
266+
unlock_kernel();
267+
268+
return ret;
269+
}
270+
261271
static const struct file_operations isdn_fops =
262272
{
263273
.owner = THIS_MODULE,
264274
.llseek = no_llseek,
265275
.read = isdn_divert_read,
266276
.write = isdn_divert_write,
267277
.poll = isdn_divert_poll,
268-
.ioctl = isdn_divert_ioctl,
278+
.unlocked_ioctl = isdn_divert_ioctl,
269279
.open = isdn_divert_open,
270280
.release = isdn_divert_close,
271281
};

fs/proc/base.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ static ssize_t proc_info_read(struct file * file, char __user * buf,
730730

731731
static const struct file_operations proc_info_file_operations = {
732732
.read = proc_info_read,
733+
.llseek = generic_file_llseek,
733734
};
734735

735736
static int proc_single_show(struct seq_file *m, void *v)
@@ -987,6 +988,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
987988

988989
static const struct file_operations proc_environ_operations = {
989990
.read = environ_read,
991+
.llseek = generic_file_llseek,
990992
};
991993

992994
static ssize_t oom_adjust_read(struct file *file, char __user *buf,
@@ -1060,6 +1062,7 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
10601062
static const struct file_operations proc_oom_adjust_operations = {
10611063
.read = oom_adjust_read,
10621064
.write = oom_adjust_write,
1065+
.llseek = generic_file_llseek,
10631066
};
10641067

10651068
#ifdef CONFIG_AUDITSYSCALL
@@ -1131,6 +1134,7 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
11311134
static const struct file_operations proc_loginuid_operations = {
11321135
.read = proc_loginuid_read,
11331136
.write = proc_loginuid_write,
1137+
.llseek = generic_file_llseek,
11341138
};
11351139

11361140
static ssize_t proc_sessionid_read(struct file * file, char __user * buf,
@@ -1151,6 +1155,7 @@ static ssize_t proc_sessionid_read(struct file * file, char __user * buf,
11511155

11521156
static const struct file_operations proc_sessionid_operations = {
11531157
.read = proc_sessionid_read,
1158+
.llseek = generic_file_llseek,
11541159
};
11551160
#endif
11561161

@@ -1202,6 +1207,7 @@ static ssize_t proc_fault_inject_write(struct file * file,
12021207
static const struct file_operations proc_fault_inject_operations = {
12031208
.read = proc_fault_inject_read,
12041209
.write = proc_fault_inject_write,
1210+
.llseek = generic_file_llseek,
12051211
};
12061212
#endif
12071213

@@ -1943,7 +1949,7 @@ static ssize_t proc_fdinfo_read(struct file *file, char __user *buf,
19431949
}
19441950

19451951
static const struct file_operations proc_fdinfo_file_operations = {
1946-
.open = nonseekable_open,
1952+
.open = nonseekable_open,
19471953
.read = proc_fdinfo_read,
19481954
};
19491955

@@ -2227,6 +2233,7 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
22272233
static const struct file_operations proc_pid_attr_operations = {
22282234
.read = proc_pid_attr_read,
22292235
.write = proc_pid_attr_write,
2236+
.llseek = generic_file_llseek,
22302237
};
22312238

22322239
static const struct pid_entry attr_dir_stuff[] = {
@@ -2347,6 +2354,7 @@ static ssize_t proc_coredump_filter_write(struct file *file,
23472354
static const struct file_operations proc_coredump_filter_operations = {
23482355
.read = proc_coredump_filter_read,
23492356
.write = proc_coredump_filter_write,
2357+
.llseek = generic_file_llseek,
23502358
};
23512359
#endif
23522360

fs/proc/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,9 @@ static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigne
232232
if (rv == -ENOIOCTLCMD)
233233
rv = -EINVAL;
234234
} else if (ioctl) {
235-
lock_kernel();
235+
WARN_ONCE(1, "Procfs ioctl handlers must use unlocked_ioctl, "
236+
"%pf will be called without the Bkl held\n", ioctl);
236237
rv = ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
237-
unlock_kernel();
238238
}
239239

240240
pde_users_dec(pde);

fs/proc/kcore.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ static int open_kcore(struct inode *inode, struct file *filp)
558558
static const struct file_operations proc_kcore_operations = {
559559
.read = read_kcore,
560560
.open = open_kcore,
561+
.llseek = generic_file_llseek,
561562
};
562563

563564
#ifdef CONFIG_MEMORY_HOTPLUG

fs/proc/kmsg.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ static const struct file_operations proc_kmsg_operations = {
5353
.poll = kmsg_poll,
5454
.open = kmsg_open,
5555
.release = kmsg_release,
56+
.llseek = generic_file_llseek,
5657
};
5758

5859
static int __init proc_kmsg_init(void)

fs/proc/vmcore.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
163163

164164
static const struct file_operations proc_vmcore_operations = {
165165
.read = read_vmcore,
166+
.llseek = generic_file_llseek,
166167
};
167168

168169
static struct vmcore* __init get_new_element(void)

net/sunrpc/cache.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/workqueue.h>
2929
#include <linux/mutex.h>
3030
#include <linux/pagemap.h>
31+
#include <linux/smp_lock.h>
3132
#include <asm/ioctls.h>
3233
#include <linux/sunrpc/types.h>
3334
#include <linux/sunrpc/cache.h>
@@ -1331,12 +1332,18 @@ static unsigned int cache_poll_procfs(struct file *filp, poll_table *wait)
13311332
return cache_poll(filp, wait, cd);
13321333
}
13331334

1334-
static int cache_ioctl_procfs(struct inode *inode, struct file *filp,
1335-
unsigned int cmd, unsigned long arg)
1335+
static long cache_ioctl_procfs(struct file *filp,
1336+
unsigned int cmd, unsigned long arg)
13361337
{
1338+
long ret;
1339+
struct inode *inode = filp->f_path.dentry->d_inode;
13371340
struct cache_detail *cd = PDE(inode)->data;
13381341

1339-
return cache_ioctl(inode, filp, cmd, arg, cd);
1342+
lock_kernel();
1343+
ret = cache_ioctl(inode, filp, cmd, arg, cd);
1344+
unlock_kernel();
1345+
1346+
return ret;
13401347
}
13411348

13421349
static int cache_open_procfs(struct inode *inode, struct file *filp)
@@ -1359,7 +1366,7 @@ static const struct file_operations cache_file_operations_procfs = {
13591366
.read = cache_read_procfs,
13601367
.write = cache_write_procfs,
13611368
.poll = cache_poll_procfs,
1362-
.ioctl = cache_ioctl_procfs, /* for FIONREAD */
1369+
.unlocked_ioctl = cache_ioctl_procfs, /* for FIONREAD */
13631370
.open = cache_open_procfs,
13641371
.release = cache_release_procfs,
13651372
};

0 commit comments

Comments
 (0)