mirror of
https://github.com/hardkernel/linux.git
synced 2026-04-01 10:42:58 +09:00
PD#SWPL-17246 Problem: sync the code from mainline. Solution: sync the code from mainline. 7c03859983c2 OSS vulnerability found in [boot.img]:[linux_kernel] (CVE-2018-12232) Risk:[] [1/1] ba89a3d9c791 OSS vulnerability found in [boot.img]:[linux_kernel] (CVE-2019-8912) Risk:[] [1/1] c434d0530610 Android Security Bulletin - November 2019-11 - Kernel components binder driver - CVE-2019-2214 [1/1] ff8d9012fbd4 Android Security Bulletin - November 2019-11 - Kernel components ext4 filesystem - CVE-2019-11833 [1/1] 3c52e964495e cec: store msg after bootup from st [1/2] 94198a56ee10 lcd: support tcon vac and demura data [2/2] 1add1a008a03 vout: spi: porting lcd driver and SPI to Linux [1/1] 3e8d7b0e5f97 hdmirx: add hpd recovery logic when input clk is unstable [1/1] f92e7ba21c62 ppmgr: Add 10bit, dolby and HDR video rotation. [1/1] dab2cc37cd95 dvb: fix dmx2 interrupt bug [1/1] 9d31efae4a55 dv: add dv target output mode [1/1] e86eb9d1b5c5 hdmirx: add rx phy tdr enable control [1/1] 8ea66f645bf6 dts: enable spi for gva [1/1] baf6e74528ef drm: add drm support for tm2 [1/1] Verify: verify by newton Change-Id: I9415060a4b39895b5d624117271a72fc6a1fd187 Signed-off-by: Luan Yuan <luan.yuan@amlogic.com>
97 lines
2.1 KiB
C
97 lines
2.1 KiB
C
/*
|
|
* Copyright (C) 2014 Davidlohr Bueso.
|
|
*/
|
|
#include <linux/sched.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/vmacache.h>
|
|
|
|
/*
|
|
* This task may be accessing a foreign mm via (for example)
|
|
* get_user_pages()->find_vma(). The vmacache is task-local and this
|
|
* task's vmacache pertains to a different mm (ie, its own). There is
|
|
* nothing we can do here.
|
|
*
|
|
* Also handle the case where a kernel thread has adopted this mm via use_mm().
|
|
* That kernel thread's vmacache is not applicable to this mm.
|
|
*/
|
|
static inline bool vmacache_valid_mm(struct mm_struct *mm)
|
|
{
|
|
return current->mm == mm && !(current->flags & PF_KTHREAD);
|
|
}
|
|
|
|
void vmacache_update(unsigned long addr, struct vm_area_struct *newvma)
|
|
{
|
|
if (vmacache_valid_mm(newvma->vm_mm))
|
|
current->vmacache[VMACACHE_HASH(addr)] = newvma;
|
|
}
|
|
|
|
static bool vmacache_valid(struct mm_struct *mm)
|
|
{
|
|
struct task_struct *curr;
|
|
|
|
if (!vmacache_valid_mm(mm))
|
|
return false;
|
|
|
|
curr = current;
|
|
if (mm->vmacache_seqnum != curr->vmacache_seqnum) {
|
|
/*
|
|
* First attempt will always be invalid, initialize
|
|
* the new cache for this task here.
|
|
*/
|
|
curr->vmacache_seqnum = mm->vmacache_seqnum;
|
|
vmacache_flush(curr);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
struct vm_area_struct *vmacache_find(struct mm_struct *mm, unsigned long addr)
|
|
{
|
|
int i;
|
|
|
|
count_vm_vmacache_event(VMACACHE_FIND_CALLS);
|
|
|
|
if (!vmacache_valid(mm))
|
|
return NULL;
|
|
|
|
for (i = 0; i < VMACACHE_SIZE; i++) {
|
|
struct vm_area_struct *vma = current->vmacache[i];
|
|
|
|
if (!vma)
|
|
continue;
|
|
if (WARN_ON_ONCE(vma->vm_mm != mm))
|
|
break;
|
|
if (vma->vm_start <= addr && vma->vm_end > addr) {
|
|
count_vm_vmacache_event(VMACACHE_FIND_HITS);
|
|
return vma;
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
#ifndef CONFIG_MMU
|
|
struct vm_area_struct *vmacache_find_exact(struct mm_struct *mm,
|
|
unsigned long start,
|
|
unsigned long end)
|
|
{
|
|
int i;
|
|
|
|
count_vm_vmacache_event(VMACACHE_FIND_CALLS);
|
|
|
|
if (!vmacache_valid(mm))
|
|
return NULL;
|
|
|
|
for (i = 0; i < VMACACHE_SIZE; i++) {
|
|
struct vm_area_struct *vma = current->vmacache[i];
|
|
|
|
if (vma && vma->vm_start == start && vma->vm_end == end) {
|
|
count_vm_vmacache_event(VMACACHE_FIND_HITS);
|
|
return vma;
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
#endif
|