Commit e18aca02 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 fixes from Thomas Gleixner:
 "Fixlets for x86:

   - Prevent kexec crash when KASLR is enabled, which was caused by an
     address calculation bug

   - Restore the freeing of PUDs on memory hot remove

   - Correct a negated pointer check in the intel uncore performance
     monitoring driver

   - Plug a memory leak in an error exit path in the RDT code"

* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/intel_rdt: Fix memory leak on mount failure
  x86/boot/KASLR: Fix kexec crash due to 'virt_addr' calculation bug
  x86/boot/KASLR: Add checking for the offset of kernel virtual address randomization
  perf/x86/intel/uncore: Fix wrong box pointer check
  x86/mm/hotplug: Fix BUG_ON() after hot-remove by not freeing PUD
parents a527bf61 79298acc
...@@ -564,9 +564,6 @@ void choose_random_location(unsigned long input, ...@@ -564,9 +564,6 @@ void choose_random_location(unsigned long input,
{ {
unsigned long random_addr, min_addr; unsigned long random_addr, min_addr;
/* By default, keep output position unchanged. */
*virt_addr = *output;
if (cmdline_find_option_bool("nokaslr")) { if (cmdline_find_option_bool("nokaslr")) {
warn("KASLR disabled: 'nokaslr' on cmdline."); warn("KASLR disabled: 'nokaslr' on cmdline.");
return; return;
......
...@@ -338,7 +338,7 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap, ...@@ -338,7 +338,7 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,
unsigned long output_len) unsigned long output_len)
{ {
const unsigned long kernel_total_size = VO__end - VO__text; const unsigned long kernel_total_size = VO__end - VO__text;
unsigned long virt_addr = (unsigned long)output; unsigned long virt_addr = LOAD_PHYSICAL_ADDR;
/* Retain x86 boot parameters pointer passed from startup_32/64. */ /* Retain x86 boot parameters pointer passed from startup_32/64. */
boot_params = rmode; boot_params = rmode;
...@@ -390,6 +390,8 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap, ...@@ -390,6 +390,8 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
if (heap > 0x3fffffffffffUL) if (heap > 0x3fffffffffffUL)
error("Destination address too large"); error("Destination address too large");
if (virt_addr + max(output_len, kernel_total_size) > KERNEL_IMAGE_SIZE)
error("Destination virtual address is beyond the kernel mapping area");
#else #else
if (heap > ((-__PAGE_OFFSET-(128<<20)-1) & 0x7fffffff)) if (heap > ((-__PAGE_OFFSET-(128<<20)-1) & 0x7fffffff))
error("Destination address too large"); error("Destination address too large");
...@@ -397,7 +399,7 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap, ...@@ -397,7 +399,7 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,
#ifndef CONFIG_RELOCATABLE #ifndef CONFIG_RELOCATABLE
if ((unsigned long)output != LOAD_PHYSICAL_ADDR) if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
error("Destination address does not match LOAD_PHYSICAL_ADDR"); error("Destination address does not match LOAD_PHYSICAL_ADDR");
if ((unsigned long)output != virt_addr) if (virt_addr != LOAD_PHYSICAL_ADDR)
error("Destination virtual address changed when not relocatable"); error("Destination virtual address changed when not relocatable");
#endif #endif
......
...@@ -81,8 +81,6 @@ static inline void choose_random_location(unsigned long input, ...@@ -81,8 +81,6 @@ static inline void choose_random_location(unsigned long input,
unsigned long output_size, unsigned long output_size,
unsigned long *virt_addr) unsigned long *virt_addr)
{ {
/* No change from existing output location. */
*virt_addr = *output;
} }
#endif #endif
......
...@@ -1170,7 +1170,7 @@ static int uncore_event_cpu_online(unsigned int cpu) ...@@ -1170,7 +1170,7 @@ static int uncore_event_cpu_online(unsigned int cpu)
pmu = type->pmus; pmu = type->pmus;
for (i = 0; i < type->num_boxes; i++, pmu++) { for (i = 0; i < type->num_boxes; i++, pmu++) {
box = pmu->boxes[pkg]; box = pmu->boxes[pkg];
if (!box && atomic_inc_return(&box->refcnt) == 1) if (box && atomic_inc_return(&box->refcnt) == 1)
uncore_box_init(box); uncore_box_init(box);
} }
} }
......
...@@ -856,11 +856,13 @@ static struct dentry *rdt_mount(struct file_system_type *fs_type, ...@@ -856,11 +856,13 @@ static struct dentry *rdt_mount(struct file_system_type *fs_type,
dentry = kernfs_mount(fs_type, flags, rdt_root, dentry = kernfs_mount(fs_type, flags, rdt_root,
RDTGROUP_SUPER_MAGIC, NULL); RDTGROUP_SUPER_MAGIC, NULL);
if (IS_ERR(dentry)) if (IS_ERR(dentry))
goto out_cdp; goto out_destroy;
static_branch_enable(&rdt_enable_key); static_branch_enable(&rdt_enable_key);
goto out; goto out;
out_destroy:
kernfs_remove(kn_info);
out_cdp: out_cdp:
cdp_disable(); cdp_disable();
out: out:
......
...@@ -990,7 +990,13 @@ remove_p4d_table(p4d_t *p4d_start, unsigned long addr, unsigned long end, ...@@ -990,7 +990,13 @@ remove_p4d_table(p4d_t *p4d_start, unsigned long addr, unsigned long end,
pud_base = pud_offset(p4d, 0); pud_base = pud_offset(p4d, 0);
remove_pud_table(pud_base, addr, next, direct); remove_pud_table(pud_base, addr, next, direct);
free_pud_table(pud_base, p4d); /*
* For 4-level page tables we do not want to free PUDs, but in the
* 5-level case we should free them. This code will have to change
* to adapt for boot-time switching between 4 and 5 level page tables.
*/
if (CONFIG_PGTABLE_LEVELS == 5)
free_pud_table(pud_base, p4d);
} }
if (direct) if (direct)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment