Skip to content

Commit

Permalink
Ensure kernel module is compatible with Linux <5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hsadok committed Dec 6, 2023
1 parent 1375ef7 commit f192cd0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions software/kernel/linux/intel_fpga_pcie_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,23 @@ long intel_fpga_pcie_unlocked_ioctl(struct file *filp, unsigned int cmd,
return -ENOTTY;
}

// Linux 5.0 changed access_ok.
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
retval = !access_ok((void __user *)uarg, _IOC_SIZE(cmd));
#else
/*
* The direction is a bitmask, and VERIFY_WRITE catches R/W transfers.
* `Type' is user-oriented, while access_ok is kernel-oriented, so the
* concept of "read" and "write" is reversed.
*/
if (_IOC_DIR(cmd) & _IOC_READ) {
// Note: VERIFY_WRITE is a superset of VERIFY_READ
retval = !access_ok((void __user *)uarg, _IOC_SIZE(cmd));
retval = !access_ok(VERIFY_WRITE, (void __user *)uarg, _IOC_SIZE(cmd));
} else if (_IOC_DIR(cmd) & _IOC_WRITE) {
retval = !access_ok((void __user *)uarg, _IOC_SIZE(cmd));
retval = !access_ok(VERIFY_READ, (void __user *)uarg, _IOC_SIZE(cmd));
}
#endif

if (unlikely(retval)) {
INTEL_FPGA_PCIE_DEBUG("ioctl access violation.");
return -EFAULT;
Expand Down

0 comments on commit f192cd0

Please sign in to comment.
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy