Skip to content

Commit 778f3dd

Browse files
davem330Linus Torvalds
authored andcommitted
Fix procfs compat_ioctl regression
It is important to only provide the compat_ioctl method if the downstream de->proc_fops does too, otherwise this utterly confuses the logic in fs/compat_ioctl.c and we end up doing the wrong thing. Signed-off-by: David S. Miller <davem@davemloft.net> Acked-by: Alexey Dobriyan <adobriyan@sw.ru> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 040b3a2 commit 778f3dd

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

fs/proc/inode.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,19 @@ static const struct file_operations proc_reg_file_ops = {
386386
.release = proc_reg_release,
387387
};
388388

389+
#ifdef CONFIG_COMPAT
390+
static const struct file_operations proc_reg_file_ops_no_compat = {
391+
.llseek = proc_reg_llseek,
392+
.read = proc_reg_read,
393+
.write = proc_reg_write,
394+
.poll = proc_reg_poll,
395+
.unlocked_ioctl = proc_reg_unlocked_ioctl,
396+
.mmap = proc_reg_mmap,
397+
.open = proc_reg_open,
398+
.release = proc_reg_release,
399+
};
400+
#endif
401+
389402
struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
390403
struct proc_dir_entry *de)
391404
{
@@ -413,8 +426,15 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
413426
if (de->proc_iops)
414427
inode->i_op = de->proc_iops;
415428
if (de->proc_fops) {
416-
if (S_ISREG(inode->i_mode))
417-
inode->i_fop = &proc_reg_file_ops;
429+
if (S_ISREG(inode->i_mode)) {
430+
#ifdef CONFIG_COMPAT
431+
if (!de->proc_fops->compat_ioctl)
432+
inode->i_fop =
433+
&proc_reg_file_ops_no_compat;
434+
else
435+
#endif
436+
inode->i_fop = &proc_reg_file_ops;
437+
}
418438
else
419439
inode->i_fop = de->proc_fops;
420440
}

0 commit comments

Comments
 (0)