[v3] kni: fix ioctl signature

Message ID 20211203071907.58032-1-markus.theil@tu-ilmenau.de (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v3] kni: fix ioctl signature |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS

Commit Message

Markus Theil Dec. 3, 2021, 7:19 a.m. UTC
From: Markus Theil <markus.theil@secunet.com>

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>
---
v3: adapt to suggestions from Stephen Hemminger (use unsigned int)
v2: adapt to suggestions from Ferruh Yigit

 kernel/linux/kni/kni_misc.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
  

Comments

Stephen Hemminger Dec. 3, 2021, 4:28 p.m. UTC | #1
On Fri,  3 Dec 2021 08:19:07 +0100
Markus Theil <markus.theil@tu-ilmenau.de> wrote:

> From: Markus Theil <markus.theil@secunet.com>
> 
> 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>
> ---

Thanks for fixing.

Acked-by: Stephen Hemminger <stephen@networkplumber.org>
  
Thomas Monjalon Feb. 2, 2022, 7:59 p.m. UTC | #2
03/12/2021 17:28, Stephen Hemminger:
> On Fri,  3 Dec 2021 08:19:07 +0100
> Markus Theil <markus.theil@tu-ilmenau.de> wrote:
> 
> > From: Markus Theil <markus.theil@secunet.com>
> > 
> > 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>
> > ---
> 
> Thanks for fixing.
> 
> Acked-by: Stephen Hemminger <stephen@networkplumber.org>

Applied, thanks
  

Patch

diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c
index f10dcd069d..cc5172fefc 100644
--- a/kernel/linux/kni/kni_misc.c
+++ b/kernel/linux/kni/kni_misc.c
@@ -482,10 +482,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);
@@ -511,8 +511,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 */
@@ -525,8 +525,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 = {