Skip to content

Commit

Permalink
kni: fix ioctl signature
Browse files Browse the repository at this point in the history
[ upstream commit f1b2991 ]

Fix kni's ioctl signature to correctly match the kernel's
structs. This shaves off the (void*) casts and uses struct file*
instead of struct inode*. With the correct signature, control flow
integrity checkers are no longer confused at this point.

Signed-off-by: Markus Theil <markus.theil@secunet.com>
Tested-by: Michael Pfeiffer <michael.pfeiffer@tu-ilmenau.de>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
  • Loading branch information
Markus Theil authored and bluca committed Feb 17, 2022
1 parent 04a29bf commit 1b61157
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions kernel/linux/kni/kni_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,10 @@ kni_ioctl_release(struct net *net, uint32_t ioctl_num,
return ret;
}

static int
kni_ioctl(struct inode *inode, uint32_t ioctl_num, unsigned long ioctl_param)
static long
kni_ioctl(struct file *file, unsigned int ioctl_num, unsigned long ioctl_param)
{
int ret = -EINVAL;
long ret = -EINVAL;
struct net *net = current->nsproxy->net_ns;

pr_debug("IOCTL num=0x%0x param=0x%0lx\n", ioctl_num, ioctl_param);
Expand All @@ -514,8 +514,8 @@ kni_ioctl(struct inode *inode, uint32_t ioctl_num, unsigned long ioctl_param)
return ret;
}

static int
kni_compat_ioctl(struct inode *inode, uint32_t ioctl_num,
static long
kni_compat_ioctl(struct file *file, unsigned int ioctl_num,
unsigned long ioctl_param)
{
/* 32 bits app on 64 bits OS to be supported later */
Expand All @@ -528,8 +528,8 @@ static const struct file_operations kni_fops = {
.owner = THIS_MODULE,
.open = kni_open,
.release = kni_release,
.unlocked_ioctl = (void *)kni_ioctl,
.compat_ioctl = (void *)kni_compat_ioctl,
.unlocked_ioctl = kni_ioctl,
.compat_ioctl = kni_compat_ioctl,
};

static struct miscdevice kni_misc = {
Expand Down

0 comments on commit 1b61157

Please sign in to comment.