Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 778f3dd5 authored by David Miller's avatar David Miller Committed by Linus Torvalds
Browse files

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: default avatarDavid S. Miller <davem@davemloft.net>
Acked-by: default avatarAlexey Dobriyan <adobriyan@sw.ru>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 040b3a2d
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -386,6 +386,19 @@ static const struct file_operations proc_reg_file_ops = {
	.release	= proc_reg_release,
};

#ifdef CONFIG_COMPAT
static const struct file_operations proc_reg_file_ops_no_compat = {
	.llseek		= proc_reg_llseek,
	.read		= proc_reg_read,
	.write		= proc_reg_write,
	.poll		= proc_reg_poll,
	.unlocked_ioctl	= proc_reg_unlocked_ioctl,
	.mmap		= proc_reg_mmap,
	.open		= proc_reg_open,
	.release	= proc_reg_release,
};
#endif

struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
				struct proc_dir_entry *de)
{
@@ -413,8 +426,15 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
		if (de->proc_iops)
			inode->i_op = de->proc_iops;
		if (de->proc_fops) {
			if (S_ISREG(inode->i_mode))
			if (S_ISREG(inode->i_mode)) {
#ifdef CONFIG_COMPAT
				if (!de->proc_fops->compat_ioctl)
					inode->i_fop =
						&proc_reg_file_ops_no_compat;
				else
#endif
					inode->i_fop = &proc_reg_file_ops;
			}
			else
				inode->i_fop = de->proc_fops;
		}