struct pagemapread {
int pos, len; /* units: PM_ENTRY_BYTES, not bytes */
pagemap_entry_t *buffer;
+ bool show_pfn;
};
#define PAGEMAP_WALK_SIZE (PMD_SIZE)
struct page *page = NULL;
if (pte_present(pte)) {
- frame = pte_pfn(pte);
+ if (pm->show_pfn)
+ frame = pte_pfn(pte);
flags |= PM_PRESENT;
page = vm_normal_page(vma, addr, pte);
if (pte_soft_dirty(pte))
*/
if (pmd_present(pmd)) {
flags |= PM_PRESENT;
- frame = pmd_pfn(pmd) +
- ((addr & ~PMD_MASK) >> PAGE_SHIFT);
+ if (pm->show_pfn)
+ frame = pmd_pfn(pmd) +
+ ((addr & ~PMD_MASK) >> PAGE_SHIFT);
}
for (; addr != end; addr += PAGE_SIZE) {
err = add_to_pagemap(addr, &pme, pm);
if (err)
break;
- if (flags & PM_PRESENT)
+ if (pm->show_pfn && (flags & PM_PRESENT))
frame++;
}
spin_unlock(ptl);
flags |= PM_FILE;
flags |= PM_PRESENT;
- frame = pte_pfn(pte) +
- ((addr & ~hmask) >> PAGE_SHIFT);
+ if (pm->show_pfn)
+ frame = pte_pfn(pte) +
+ ((addr & ~hmask) >> PAGE_SHIFT);
}
for (; addr != end; addr += PAGE_SIZE) {
err = add_to_pagemap(addr, &pme, pm);
if (err)
return err;
- if (flags & PM_PRESENT)
+ if (pm->show_pfn && (flags & PM_PRESENT))
frame++;
}
if (!count)
goto out_mm;
+ /* do not disclose physical addresses: attack vector */
+ pm.show_pfn = file_ns_capable(file, &init_user_ns, CAP_SYS_ADMIN);
+
pm.len = (PAGEMAP_WALK_SIZE >> PAGE_SHIFT);
pm.buffer = kmalloc(pm.len * PM_ENTRY_BYTES, GFP_TEMPORARY);
ret = -ENOMEM;
{
struct mm_struct *mm;
- /* do not disclose physical addresses: attack vector */
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
mm = proc_mem_open(inode, PTRACE_MODE_READ);
if (IS_ERR(mm))
return PTR_ERR(mm);