Compare
cf20e7f96ae688dd8611dd6dce8cb4a036fecc72..23a38e7bb2f9ad99c317a9f4e4c349054de9dfff
Merge tag 'x86-urgent-2026-10-18' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fix from Ingo Molnar: - Fix kCFI decoding bug on CONFIG_FINEIBT=y kernels running in kCFI mode (Kees Cook) * tag 'x86-urgent-2026-10-18' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/kcfi: Decode the kCFI check from the trap address
Linus Torvalds <torvalds@linux-foundation.org> · 2026-10-18 17:38 UTC
6 files changed,
+51
−44
- arch/x86/events/intel/uncore_snbep.c
- arch/x86/kernel/cfi.c
- include/linux/sched/user.h
- kernel/events/core.c
- kernel/sched/core.c
- kernel/sched/fair.c
modified arch/x86/events/intel/uncore_snbep.c
| @@ -474,6 +474,9 @@ | |||
| 474 | 474 | /* DMR */ | |
| 475 | 475 | #define DMR_IMH1_HIOP_MMIO_BASE 0x1ffff6ae7000 | |
| 476 | 476 | #define DMR_HIOP_MMIO_SIZE 0x8000 | |
| 477 | + | #define DMR_CXLCM_PMON_CTL_INVERT BIT(21) | |
| 478 | + | #define DMR_CXLCM_PMON_RAW_EVENT_MASK (GENERIC_PMON_RAW_EVENT_MASK | \ | |
| 479 | + | DMR_CXLCM_PMON_CTL_INVERT) | |
| 477 | 480 | #define DMR_CXLCM_EVENT_MASK_EXT 0xf | |
| 478 | 481 | #define DMR_HAMVF_EVENT_MASK_EXT 0xffffffff | |
| 479 | 482 | #define DMR_PCIE4_EVENT_MASK_EXT 0xffffff | |
| @@ -6696,7 +6699,7 @@ static struct event_constraint dmr_uncore_cxlcm_constraints[] = { | |||
| 6696 | 6699 | ||
| 6697 | 6700 | static struct intel_uncore_type dmr_uncore_cxlcm = { | |
| 6698 | 6701 | .name = "cxlcm", | |
| 6699 | - | .event_mask = GENERIC_PMON_RAW_EVENT_MASK, | |
| 6702 | + | .event_mask = DMR_CXLCM_PMON_RAW_EVENT_MASK, | |
| 6700 | 6703 | .event_mask_ext = DMR_CXLCM_EVENT_MASK_EXT, | |
| 6701 | 6704 | .constraints = dmr_uncore_cxlcm_constraints, | |
| 6702 | 6705 | .format_group = &dmr_cxlcm_uncore_format_group, | |
modified arch/x86/kernel/cfi.c
| @@ -10,11 +10,11 @@ | |||
| 10 | 10 | #include <asm/insn-eval.h> | |
| 11 | 11 | ||
| 12 | 12 | /* | |
| 13 | - | * Returns the target address and the expected type when regs->ip points | |
| 13 | + | * Returns the target address and the expected type when addr points | |
| 14 | 14 | * to a compiler-generated CFI trap. | |
| 15 | 15 | */ | |
| 16 | - | static bool decode_cfi_insn(struct pt_regs *regs, unsigned long *target, | |
| 17 | - | u32 *type) | |
| 16 | + | static bool decode_cfi_insn(struct pt_regs *regs, unsigned long addr, | |
| 17 | + | unsigned long *target, u32 *type) | |
| 18 | 18 | { | |
| 19 | 19 | char buffer[MAX_INSN_SIZE]; | |
| 20 | 20 | struct insn insn; | |
| @@ -29,13 +29,13 @@ static bool decode_cfi_insn(struct pt_regs *regs, unsigned long *target, | |||
| 29 | 29 | * movl -<id>, %r10d ; 6 bytes | |
| 30 | 30 | * addl -<pos>(%reg), %r10d; 4 bytes | |
| 31 | 31 | * je .Ltmp1 ; 2 bytes | |
| 32 | - | * ud2 ; <- regs->ip | |
| 32 | + | * ud2 ; <- addr | |
| 33 | 33 | * .Ltmp1: | |
| 34 | 34 | * | |
| 35 | 35 | * We can decode the expected type and the target address from the | |
| 36 | 36 | * movl/addl instructions. | |
| 37 | 37 | */ | |
| 38 | - | if (copy_from_kernel_nofault(buffer, (void *)regs->ip - 12, MAX_INSN_SIZE)) | |
| 38 | + | if (copy_from_kernel_nofault(buffer, (void *)addr - 12, MAX_INSN_SIZE)) | |
| 39 | 39 | return false; | |
| 40 | 40 | if (insn_decode_kernel(&insn, &buffer[offset])) | |
| 41 | 41 | return false; | |
| @@ -44,7 +44,7 @@ static bool decode_cfi_insn(struct pt_regs *regs, unsigned long *target, | |||
| 44 | 44 | ||
| 45 | 45 | *type = -(u32)insn.immediate.value; | |
| 46 | 46 | ||
| 47 | - | if (copy_from_kernel_nofault(buffer, (void *)regs->ip - 6, MAX_INSN_SIZE)) | |
| 47 | + | if (copy_from_kernel_nofault(buffer, (void *)addr - 6, MAX_INSN_SIZE)) | |
| 48 | 48 | return false; | |
| 49 | 49 | if (insn_decode_kernel(&insn, &buffer[offset])) | |
| 50 | 50 | return false; | |
| @@ -82,7 +82,7 @@ enum bug_trap_type handle_cfi_failure(struct pt_regs *regs) | |||
| 82 | 82 | return BUG_TRAP_TYPE_NONE; | |
| 83 | 83 | } | |
| 84 | 84 | ||
| 85 | - | if (!decode_cfi_insn(regs, &target, &type)) | |
| 85 | + | if (!decode_cfi_insn(regs, addr, &target, &type)) | |
| 86 | 86 | return report_cfi_failure_noaddr(regs, addr); | |
| 87 | 87 | ||
| 88 | 88 | break; | |
modified include/linux/sched/user.h
| @@ -23,11 +23,13 @@ struct user_struct { | |||
| 23 | 23 | struct hlist_node uidhash_node; | |
| 24 | 24 | kuid_t uid; | |
| 25 | 25 | ||
| 26 | - | #if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL) || \ | |
| 27 | - | defined(CONFIG_NET) || defined(CONFIG_IO_URING) || \ | |
| 26 | + | #if defined(CONFIG_NET) || defined(CONFIG_IO_URING) || \ | |
| 28 | 27 | defined(CONFIG_VFIO_PCI_ZDEV_KVM) || IS_ENABLED(CONFIG_IOMMUFD) || \ | |
| 29 | 28 | defined(CONFIG_SECRETMEM) | |
| 30 | - | atomic_long_t locked_vm; | |
| 29 | + | atomic_long_t locked_vm; /* pinned pages charged to RLIMIT_MEMLOCK */ | |
| 30 | + | #endif | |
| 31 | + | #ifdef CONFIG_PERF_EVENTS | |
| 32 | + | atomic_long_t perf_mlock; /* perf buffer pages within perf_event_mlock_kb */ | |
| 31 | 33 | #endif | |
| 32 | 34 | #ifdef CONFIG_WATCH_QUEUE | |
| 33 | 35 | atomic_t nr_watches; /* The number of watches this user currently has */ | |
modified kernel/events/core.c
| @@ -4639,6 +4639,7 @@ static bool perf_rotate_context(struct perf_cpu_pmu_context *cpc) | |||
| 4639 | 4639 | ||
| 4640 | 4640 | if (cpu_event) { | |
| 4641 | 4641 | update_context_time(&cpuctx->ctx); | |
| 4642 | + | update_cgrp_time_from_cpuctx(cpuctx, false); | |
| 4642 | 4643 | __pmu_ctx_sched_out(cpu_epc, EVENT_FLEXIBLE); | |
| 4643 | 4644 | rotate_ctx(&cpuctx->ctx, cpu_event); | |
| 4644 | 4645 | __pmu_ctx_sched_in(cpu_epc, EVENT_FLEXIBLE); | |
| @@ -7059,7 +7060,7 @@ static void perf_mmap_close(struct vm_area_struct *vma) | |||
| 7059 | 7060 | perf_pmu_output_stop(event); | |
| 7060 | 7061 | ||
| 7061 | 7062 | /* now it's safe to free the pages */ | |
| 7062 | - | atomic_long_sub(rb->aux_nr_pages - rb->aux_mmap_locked, &mmap_user->locked_vm); | |
| 7063 | + | atomic_long_sub(rb->aux_nr_pages - rb->aux_mmap_locked, &mmap_user->perf_mlock); | |
| 7063 | 7064 | atomic64_sub(rb->aux_mmap_locked, &vma->vm_mm->pinned_vm); | |
| 7064 | 7065 | ||
| 7065 | 7066 | /* this has to be the last one */ | |
| @@ -7242,11 +7243,11 @@ static bool perf_mmap_calc_limits(struct vm_area_struct *vma, long *user_extra, | |||
| 7242 | 7243 | /* Increase the limit linearly with more CPUs */ | |
| 7243 | 7244 | user_lock_limit *= num_online_cpus(); | |
| 7244 | 7245 | ||
| 7245 | - | user_locked = atomic_long_read(&user->locked_vm); | |
| 7246 | + | user_locked = atomic_long_read(&user->perf_mlock); | |
| 7246 | 7247 | ||
| 7247 | 7248 | /* | |
| 7248 | 7249 | * sysctl_perf_event_mlock may have changed, so that | |
| 7249 | - | * user->locked_vm > user_lock_limit | |
| 7250 | + | * user->perf_mlock > user_lock_limit | |
| 7250 | 7251 | */ | |
| 7251 | 7252 | if (user_locked > user_lock_limit) | |
| 7252 | 7253 | user_locked = user_lock_limit; | |
| @@ -7254,7 +7255,7 @@ static bool perf_mmap_calc_limits(struct vm_area_struct *vma, long *user_extra, | |||
| 7254 | 7255 | ||
| 7255 | 7256 | if (user_locked > user_lock_limit) { | |
| 7256 | 7257 | /* | |
| 7257 | - | * charge locked_vm until it hits user_lock_limit; | |
| 7258 | + | * charge perf_mlock until it hits user_lock_limit; | |
| 7258 | 7259 | * charge the rest from pinned_vm | |
| 7259 | 7260 | */ | |
| 7260 | 7261 | *extra = user_locked - user_lock_limit; | |
| @@ -7272,7 +7273,7 @@ static void perf_mmap_account(struct vm_area_struct *vma, long user_extra, long | |||
| 7272 | 7273 | { | |
| 7273 | 7274 | struct user_struct *user = current_user(); | |
| 7274 | 7275 | ||
| 7275 | - | atomic_long_add(user_extra, &user->locked_vm); | |
| 7276 | + | atomic_long_add(user_extra, &user->perf_mlock); | |
| 7276 | 7277 | atomic64_add(extra, &vma->vm_mm->pinned_vm); | |
| 7277 | 7278 | } | |
| 7278 | 7279 | ||
| @@ -7281,7 +7282,7 @@ static void perf_mmap_unaccount(struct vm_area_struct *vma, struct perf_buffer * | |||
| 7281 | 7282 | struct user_struct *user = rb->mmap_user; | |
| 7282 | 7283 | ||
| 7283 | 7284 | atomic_long_sub((perf_data_size(rb) >> PAGE_SHIFT) + 1 - rb->mmap_locked, | |
| 7284 | - | &user->locked_vm); | |
| 7285 | + | &user->perf_mlock); | |
| 7285 | 7286 | atomic64_sub(rb->mmap_locked, &vma->vm_mm->pinned_vm); | |
| 7286 | 7287 | } | |
| 7287 | 7288 | ||
| @@ -14394,23 +14395,18 @@ err: | |||
| 14394 | 14395 | } | |
| 14395 | 14396 | EXPORT_SYMBOL_GPL(perf_event_create_kernel_counter); | |
| 14396 | 14397 | ||
| 14397 | - | static void __perf_pmu_remove(struct perf_event_context *ctx, | |
| 14398 | - | int cpu, struct pmu *pmu, | |
| 14399 | - | struct perf_event_groups *groups, | |
| 14398 | + | static void __perf_pmu_remove(struct perf_event_context *ctx, struct pmu *pmu, | |
| 14400 | 14399 | struct list_head *events) | |
| 14401 | 14400 | { | |
| 14402 | - | struct perf_event *event, *sibling; | |
| 14401 | + | struct perf_event *event, *tmp; | |
| 14402 | + | ||
| 14403 | + | list_for_each_entry_safe(event, tmp, &ctx->event_list, event_entry) { | |
| 14404 | + | if (event->pmu_ctx->pmu != pmu) | |
| 14405 | + | continue; | |
| 14403 | 14406 | ||
| 14404 | - | perf_event_groups_for_cpu_pmu(event, groups, cpu, pmu) { | |
| 14405 | 14407 | perf_remove_from_context(event, 0); | |
| 14406 | 14408 | put_pmu_ctx(event->pmu_ctx); | |
| 14407 | 14409 | list_add(&event->migrate_entry, events); | |
| 14408 | - | ||
| 14409 | - | for_each_sibling_event(sibling, event) { | |
| 14410 | - | perf_remove_from_context(sibling, 0); | |
| 14411 | - | put_pmu_ctx(sibling->pmu_ctx); | |
| 14412 | - | list_add(&sibling->migrate_entry, events); | |
| 14413 | - | } | |
| 14414 | 14410 | } | |
| 14415 | 14411 | } | |
| 14416 | 14412 | ||
| @@ -14486,8 +14482,7 @@ void perf_pmu_migrate_context(struct pmu *pmu, int src_cpu, int dst_cpu) | |||
| 14486 | 14482 | */ | |
| 14487 | 14483 | mutex_lock_double(&src_ctx->mutex, &dst_ctx->mutex); | |
| 14488 | 14484 | ||
| 14489 | - | __perf_pmu_remove(src_ctx, src_cpu, pmu, &src_ctx->pinned_groups, &events); | |
| 14490 | - | __perf_pmu_remove(src_ctx, src_cpu, pmu, &src_ctx->flexible_groups, &events); | |
| 14485 | + | __perf_pmu_remove(src_ctx, pmu, &events); | |
| 14491 | 14486 | ||
| 14492 | 14487 | if (!list_empty(&events)) { | |
| 14493 | 14488 | /* | |
modified kernel/sched/core.c
| @@ -11327,17 +11327,16 @@ void sched_change_end(struct sched_change_ctx *ctx) | |||
| 11327 | 11327 | if (p->sched_class->switched_to) | |
| 11328 | 11328 | p->sched_class->switched_to(rq, p); | |
| 11329 | 11329 | ||
| 11330 | + | /* | |
| 11331 | + | * Check if the task can preempt the current in case the class | |
| 11332 | + | * was upgraded. Note that none of the switch*_from() methods | |
| 11333 | + | * know the new class and none of the switch*_to() methods know | |
| 11334 | + | * the old class so we must resched here. | |
| 11335 | + | */ | |
| 11336 | + | if (ctx->queued) | |
| 11337 | + | wakeup_preempt(rq, p, 0); | |
| 11338 | + | ||
| 11330 | 11339 | if (ctx->running) { | |
| 11331 | - | /* | |
| 11332 | - | * If this was a class promotion; let the old class | |
| 11333 | - | * know it got preempted. Note that none of the | |
| 11334 | - | * switch*_from() methods know the new class and none | |
| 11335 | - | * of the switch*_to() methods know the old class. | |
| 11336 | - | */ | |
| 11337 | - | if (sched_class_above(p->sched_class, ctx->class)) { | |
| 11338 | - | rq->next_class->wakeup_preempt(rq, p, 0); | |
| 11339 | - | rq->next_class = p->sched_class; | |
| 11340 | - | } | |
| 11341 | 11340 | /* | |
| 11342 | 11341 | * If this was a degradation in class; make sure to | |
| 11343 | 11342 | * reschedule. | |
modified kernel/sched/fair.c
| @@ -6463,12 +6463,20 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) | |||
| 6463 | 6463 | load = cfs_rq->sum_weight; | |
| 6464 | 6464 | if (curr && curr->on_rq) | |
| 6465 | 6465 | load += avg_vruntime_weight(cfs_rq, curr->h_load.weight); | |
| 6466 | - | ||
| 6467 | - | weight = avg_vruntime_weight(cfs_rq, se->h_load.weight); | |
| 6468 | - | lag *= load + weight; | |
| 6469 | 6466 | if (WARN_ON_ONCE(!load)) | |
| 6470 | 6467 | load = 1; | |
| 6471 | - | lag = div64_long(lag, load); | |
| 6468 | + | ||
| 6469 | + | weight = avg_vruntime_weight(cfs_rq, se->h_load.weight); | |
| 6470 | + | ||
| 6471 | + | /* | |
| 6472 | + | * Rewrite, because the product (W + w_i)*vl'_i might | |
| 6473 | + | * overflow s64: | |
| 6474 | + | * | |
| 6475 | + | * vl_i = (W + w_i)*vl'_i / W | |
| 6476 | + | * = (W*vl'_i + w_i*vl'_i) / W | |
| 6477 | + | * = vl'_i + w_i*vl'_i/W | |
| 6478 | + | */ | |
| 6479 | + | lag += div64_long(lag * weight, load); | |
| 6472 | 6480 | ||
| 6473 | 6481 | /* | |
| 6474 | 6482 | * A heavy entity (relative to the tree) will pull the | |