History

Merge branch 'akpm' (patches from Andrew)

Merge misc fixes from Andrew Morton: "8 patches. Subsystems affected by this patch series: mm (hugetlb, pagemap, and userfaultfd), memfd, selftests, and kconfig" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: configs/debug: set CONFIG_DEBUG_INFO=y properly proc: fix documentation and description of pagemap kselftest/vm: fix tests build with old libc memfd: fix F_SEAL_WRITE after shmem huge page allocated mm: fix use-after-free when anon vma name is used after vma is freed mm: prevent vm_area_struct::anon_name refcount saturation mm: refactor vm_area_struct::anon_vma_name usage code selftests/vm: cleanup hugetlb file after mremap test

Linus Torvalds committed 4 years ago

Commit 00144042 parents f9026e1 d1eff1618 files · +194 −137Browse files

Showing the changes to kernel (3 of 18 files). Show all

Unified · Split

3 files
  1. kernel/configs/debug.config +1 −1
  2. kernel/fork.c +2 −2
  3. kernel/sys.c +12 −7
kernel/configs/debug.config+1−1
@@ -16,7 +16,7 @@ CONFIG_SYMBOLIC_ERRNAME=y · 15 unmodified lines
1616 #
1717 # Compile-time checks and compiler options
1818 #
19−CONFIG_DEBUG_INFO=y
19+CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
2020 CONFIG_DEBUG_SECTION_MISMATCH=y
2121 CONFIG_FRAME_WARN=2048
2222 CONFIG_SECTION_MISMATCH_WARN_ONLY=y
kernel/fork.c+2−2
@@ -366,14 +366,14 @@ struct vm_area_struct *vm_area_dup(struct vm_area_struct *orig) · 365 unmodified lines
366366 *new = data_race(*orig);
367367 INIT_LIST_HEAD(&new->anon_vma_chain);
368368 new->vm_next = new->vm_prev = NULL;
369− dup_vma_anon_name(orig, new);
369+ dup_anon_vma_name(orig, new);
370370 }
371371 return new;
372372 }
373373
374374 void vm_area_free(struct vm_area_struct *vma)
375375 {
376− free_vma_anon_name(vma);
376+ free_anon_vma_name(vma);
377377 kmem_cache_free(vm_area_cachep, vma);
378378 }
379379
kernel/sys.c+12−7
@@ -7,6 +7,7 @@ · 6 unmodified lines
77
88 #include <linux/export.h>
99 #include <linux/mm.h>
10+#include <linux/mm_inline.h>
1011 #include <linux/utsname.h>
1112 #include <linux/mman.h>
1213 #include <linux/reboot.h>
@@ -2286,15 +2287,16 @@ static int prctl_set_vma(unsigned long opt, unsigned long addr, · 2273 unmodified lines
22862287 {
22872288 struct mm_struct *mm = current->mm;
22882289 const char __user *uname;
2289− char *name, *pch;
2290+ struct anon_vma_name *anon_name = NULL;
22902291 int error;
22912292
22922293 switch (opt) {
22932294 case PR_SET_VMA_ANON_NAME:
22942295 uname = (const char __user *)arg;
22952296 if (uname) {
2296− name = strndup_user(uname, ANON_VMA_NAME_MAX_LEN);
2297+ char *name, *pch;
22972298
2299+ name = strndup_user(uname, ANON_VMA_NAME_MAX_LEN);
22982300 if (IS_ERR(name))
22992301 return PTR_ERR(name);
23002302
@@ -2304,15 +2306,18 @@ static int prctl_set_vma(unsigned long opt, unsigned long addr, · 3 unmodified lines
23042306 return -EINVAL;
23052307 }
23062308 }
2307− } else {
2308− /* Reset the name */
2309− name = NULL;
2309+ /* anon_vma has its own copy */
2310+ anon_name = anon_vma_name_alloc(name);
2311+ kfree(name);
2312+ if (!anon_name)
2313+ return -ENOMEM;
2314+
23102315 }
23112316
23122317 mmap_write_lock(mm);
2313− error = madvise_set_anon_name(mm, addr, size, name);
2318+ error = madvise_set_anon_name(mm, addr, size, anon_name);
23142319 mmap_write_unlock(mm);
2315− kfree(name);
2320+ anon_vma_name_put(anon_name);
23162321 break;
23172322 default:
23182323 error = -EINVAL;