71 lines
2.5 KiB
Diff
71 lines
2.5 KiB
Diff
From 92b90ac11baf215ba73cb94e5aebf0576f1966a0 Mon Sep 17 00:00:00 2001
|
|
From: Michal Kubecek <mkubecek@suse.cz>
|
|
Date: Sat, 5 Jan 2019 01:54:57 +0100
|
|
Subject: [PATCH 5/5] modules: handle access_ok() with two arguments
|
|
|
|
Since commit 96d4f267e40f ("Remove 'type' argument from access_ok()
|
|
function") in v5.0-rc1, the type argument of access_ok() was dropped.
|
|
The same commit also dropped macros VERIFY_READ and VERIFY_WRITE so check
|
|
for their existence on pre-5.0 kernels to allow build against kernels with
|
|
this change backported.
|
|
---
|
|
vmmon-only/linux/hostif.c | 8 +++++++-
|
|
vmnet-only/userif.c | 8 +++++++-
|
|
2 files changed, 14 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/vmmon-only/linux/hostif.c b/vmmon-only/linux/hostif.c
|
|
index cf4197b..ef88a22 100644
|
|
--- a/vmmon-only/linux/hostif.c
|
|
+++ b/vmmon-only/linux/hostif.c
|
|
@@ -203,6 +203,12 @@ static void do_gettimeofday(struct timeval *tv)
|
|
}
|
|
#endif
|
|
|
|
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) && defined(VERIFY_WRITE)
|
|
+ #define write_access_ok(addr, size) access_ok(VERIFY_WRITE, addr, size)
|
|
+#else
|
|
+ #define write_access_ok(addr, size) access_ok(addr, size)
|
|
+#endif
|
|
+
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
@@ -3419,7 +3425,7 @@ HostIF_MapUserMem(VA addr, // IN: User memory virtual address
|
|
|
|
ASSERT(handle);
|
|
|
|
- if (!access_ok(VERIFY_WRITE, p, size)) {
|
|
+ if (!write_access_ok(p, size)) {
|
|
printk(KERN_ERR "%s: Couldn't verify write to uva 0x%p with size %"
|
|
FMTSZ"u\n", __func__, p, size);
|
|
|
|
diff --git a/vmnet-only/userif.c b/vmnet-only/userif.c
|
|
index acc6ca6..5d935ee 100644
|
|
--- a/vmnet-only/userif.c
|
|
+++ b/vmnet-only/userif.c
|
|
@@ -85,6 +85,12 @@ extern unsigned int vnet_max_qlen;
|
|
# define compat_kunmap(page) kunmap((page).p)
|
|
#endif
|
|
|
|
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) && defined(VERIFY_WRITE)
|
|
+ #define write_access_ok(addr, size) access_ok(VERIFY_WRITE, addr, size)
|
|
+#else
|
|
+ #define write_access_ok(addr, size) access_ok(addr, size)
|
|
+#endif
|
|
+
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
@@ -142,7 +148,7 @@ VNetUserIfMapPtr(VA uAddr, // IN: pointer to user memory
|
|
struct page **p, // OUT: locked page
|
|
void **ptr) // OUT: kernel mapped pointer
|
|
{
|
|
- if (!access_ok(VERIFY_WRITE, (void *)uAddr, size) ||
|
|
+ if (!write_access_ok((void *)uAddr, size) ||
|
|
(((uAddr + size - 1) & ~(PAGE_SIZE - 1)) !=
|
|
(uAddr & ~(PAGE_SIZE - 1)))) {
|
|
return -EINVAL;
|
|
--
|
|
2.21.0
|
|
|