]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - arch/x86/kernel/hw_breakpoint.c
x86/hw_breakpoint: Prevent data breakpoints on user_pcid_flush_mask
[mirror_ubuntu-jammy-kernel.git] / arch / x86 / kernel / hw_breakpoint.c
index f311bbfda1ba931f8351ff0e02efa6d3ebe5e0dc..fc1743a2b0e9595dcd1fae20ea2a0d9e3f4e0208 100644 (file)
@@ -33,6 +33,7 @@
 #include <asm/debugreg.h>
 #include <asm/user.h>
 #include <asm/desc.h>
+#include <asm/tlbflush.h>
 
 /* Per cpu debug control register value */
 DEFINE_PER_CPU(unsigned long, cpu_dr7);
@@ -264,6 +265,16 @@ static inline bool within_cpu_entry(unsigned long addr, unsigned long end)
                                (unsigned long)&per_cpu(cpu_tss_rw, cpu),
                                sizeof(struct tss_struct)))
                        return true;
+
+               /*
+                * cpu_tlbstate.user_pcid_flush_mask is used for CPU entry.
+                * If a data breakpoint on it, it will cause an unwanted #DB.
+                * Protect the full cpu_tlbstate structure to be sure.
+                */
+               if (within_area(addr, end,
+                               (unsigned long)&per_cpu(cpu_tlbstate, cpu),
+                               sizeof(struct tlb_state)))
+                       return true;
        }
 
        return false;