]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - fs/proc/kcore.c
Merge tag 'fsdax-fix-5.1-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm...
[linux.git] / fs / proc / kcore.c
index bbcc185062bb5c8198f7cefbc85520c5adeac0e2..f5834488b67d564d91b5534c210fc7fcd8e95969 100644 (file)
@@ -54,6 +54,28 @@ static LIST_HEAD(kclist_head);
 static DECLARE_RWSEM(kclist_lock);
 static int kcore_need_update = 1;
 
+/*
+ * Returns > 0 for RAM pages, 0 for non-RAM pages, < 0 on error
+ * Same as oldmem_pfn_is_ram in vmcore
+ */
+static int (*mem_pfn_is_ram)(unsigned long pfn);
+
+int __init register_mem_pfn_is_ram(int (*fn)(unsigned long pfn))
+{
+       if (mem_pfn_is_ram)
+               return -EBUSY;
+       mem_pfn_is_ram = fn;
+       return 0;
+}
+
+static int pfn_is_ram(unsigned long pfn)
+{
+       if (mem_pfn_is_ram)
+               return mem_pfn_is_ram(pfn);
+       else
+               return 1;
+}
+
 /* This doesn't grab kclist_lock, so it should only be used at init time. */
 void __init kclist_add(struct kcore_list *new, void *addr, size_t size,
                       int type)
@@ -465,6 +487,11 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
                                goto out;
                        }
                        m = NULL;       /* skip the list anchor */
+               } else if (!pfn_is_ram(__pa(start) >> PAGE_SHIFT)) {
+                       if (clear_user(buffer, tsz)) {
+                               ret = -EFAULT;
+                               goto out;
+                       }
                } else if (m->type == KCORE_VMALLOC) {
                        vread(buf, (char *)start, tsz);
                        /* we have to zero-fill user buffer even if no read */
@@ -588,7 +615,7 @@ static void __init proc_kcore_text_init(void)
 /*
  * MODULES_VADDR has no intersection with VMALLOC_ADDR.
  */
-struct kcore_list kcore_modules;
+static struct kcore_list kcore_modules;
 static void __init add_modules_range(void)
 {
        if (MODULES_VADDR != VMALLOC_START && MODULES_END != VMALLOC_END) {