Skip to content

Commit

Permalink
pps: add ioctl_compat function to correct ioctl definitions
Browse files Browse the repository at this point in the history
ioctl definitions use the pointer size of the architecture which
is fine when userspace and kernel are the same bitsize. This
patchset workarounds an issue with mixed bitsize kernel + userspace
by rewriting the cmd to the kernelspace architecture pointer size.

Acked-by: Rodolfo Giometti <[email protected]>
Signed-off-by: Matt Ranostay <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
mranostay authored and gregkh committed Mar 17, 2017
1 parent 48a5e6b commit 2ac6665
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions drivers/pps/pps.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,18 @@ static long pps_cdev_ioctl(struct file *file,
return 0;
}

#ifdef CONFIG_COMPAT
static long pps_cdev_compat_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
cmd = _IOC(_IOC_DIR(cmd), _IOC_TYPE(cmd), _IOC_NR(cmd), sizeof(void *));

return pps_cdev_ioctl(file, cmd, arg);
}
#else
#define pps_cdev_compat_ioctl NULL
#endif

static int pps_cdev_open(struct inode *inode, struct file *file)
{
struct pps_device *pps = container_of(inode->i_cdev,
Expand All @@ -268,6 +280,7 @@ static const struct file_operations pps_cdev_fops = {
.llseek = no_llseek,
.poll = pps_cdev_poll,
.fasync = pps_cdev_fasync,
.compat_ioctl = pps_cdev_compat_ioctl,
.unlocked_ioctl = pps_cdev_ioctl,
.open = pps_cdev_open,
.release = pps_cdev_release,
Expand Down

0 comments on commit 2ac6665

Please sign in to comment.