android_kernel_samsung_msm8976/include
Andrey Ryabinin 76d87f2b22 kasan, module, vmalloc: rework shadow allocation for modules
Current approach in handling shadow memory for modules is broken.

Shadow memory could be freed only after memory shadow corresponds it is no
longer used.  vfree() called from interrupt context could use memory its
freeing to store 'struct llist_node' in it:

    void vfree(const void *addr)
    {
    ...
        if (unlikely(in_interrupt())) {
            struct vfree_deferred *p = this_cpu_ptr(&vfree_deferred);
            if (llist_add((struct llist_node *)addr, &p->list))
                    schedule_work(&p->wq);

Later this list node used in free_work() which actually frees memory.
Currently module_memfree() called in interrupt context will free shadow
before freeing module's memory which could provoke kernel crash.

So shadow memory should be freed after module's memory.  However, such
deallocation order could race with kasan_module_alloc() in module_alloc().

Free shadow right before releasing vm area.  At this point vfree()'d
memory is not used anymore and yet not available for other allocations.
New VM_KASAN flag used to indicate that vm area has dynamically allocated
shadow memory so kasan frees shadow only if it was previously allocated.

Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[dkeitel@codeaurora.org: resolved trivial merge conflicts]
Git-commit: a5af5aa8b67dfdba36c853b70564fd2dfe73d478
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
Change-Id: I9e2cca957a8dfda65ff9ad01cb13c89904abf8e4
2015-05-04 14:03:58 -07:00
..
acpi
asm-generic syscall_get_arch: remove useless function arguments 2015-03-19 14:52:43 -07:00
clocksource
crypto
drm This is the 3.10.67 stable release 2015-04-24 18:04:40 -07:00
dt-bindings Merge "qcom: clk: Configure wakeup cycles and sleep cycles for gmem clock" 2015-04-30 23:29:25 -07:00
keys
kvm
linux kasan, module, vmalloc: rework shadow allocation for modules 2015-05-04 14:03:58 -07:00
math-emu
media msm: cpp: Add stripe parameters to pproc header 2015-05-03 22:17:32 -07:00
memory
misc
net Merge "Merge tmp-068b055 into msm-3.10" 2015-04-28 06:29:36 -07:00
pcmcia
ras
rdma
rxrpc
scsi
soc/qcom Update target name references for 8976 2015-04-29 15:07:39 +05:30
sound Merge "ASoC: msm: qdsp6v2: fix wma gapless failure" 2015-05-04 00:57:48 -07:00
target
trace mm: process reclaim: vmpressure based process reclaim 2015-04-16 11:00:47 -07:00
uapi net: msm_rmnet: extend SET_INGRESS_DATA_FORMAT to include AGG data 2015-05-02 00:14:49 -07:00
video msm: add display bridge abstraction driver 2015-04-21 20:08:09 -07:00
xen
Kbuild