Compile fixes for kernel >= 5.8

With the commit 64fe66e8a95e in the Linux kernel, the member "mmap_sem" in the
struct mm_struct was renamed to "mmap_lock". This patch fixes the resulting
compile errors.
This commit is contained in:
Christian Hoff 2021-03-08 20:44:14 +01:00
parent 4af9d5d591
commit 443f984b1a
1 changed files with 15 additions and 0 deletions

View File

@ -46,6 +46,9 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/pid_namespace.h> #include <linux/pid_namespace.h>
#include <linux/security.h> #include <linux/security.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
#include <linux/mmap_lock.h>
#endif
#ifdef CONFIG_ANDROID_BINDER_IPC_32BIT #ifdef CONFIG_ANDROID_BINDER_IPC_32BIT
#define BINDER_IPC_32BIT 1 #define BINDER_IPC_32BIT 1
@ -630,7 +633,11 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate,
mm = get_task_mm(proc->tsk); mm = get_task_mm(proc->tsk);
if (mm) { if (mm) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
mmap_write_lock(mm);
#else
down_write(&mm->mmap_sem); down_write(&mm->mmap_sem);
#endif
vma = proc->vma; vma = proc->vma;
if (vma && mm != proc->vma_vm_mm) { if (vma && mm != proc->vma_vm_mm) {
pr_err("%d: vma mm and task mm mismatch\n", pr_err("%d: vma mm and task mm mismatch\n",
@ -680,7 +687,11 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate,
/* vm_insert_page does not seem to increment the refcount */ /* vm_insert_page does not seem to increment the refcount */
} }
if (mm) { if (mm) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
mmap_write_unlock(mm);
#else
up_write(&mm->mmap_sem); up_write(&mm->mmap_sem);
#endif
mmput(mm); mmput(mm);
} }
return 0; return 0;
@ -707,7 +718,11 @@ err_alloc_page_failed:
} }
err_no_vma: err_no_vma:
if (mm) { if (mm) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
mmap_write_unlock(mm);
#else
up_write(&mm->mmap_sem); up_write(&mm->mmap_sem);
#endif
mmput(mm); mmput(mm);
} }
return -ENOMEM; return -ENOMEM;