]> git.baikalelectronics.ru Git - kernel.git/commitdiff
x86/hw_breakpoint: Prevent data breakpoints on per_cpu cpu_tss_rw
authorLai Jiangshan <laijs@linux.alibaba.com>
Fri, 29 May 2020 21:27:31 +0000 (23:27 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 11 Jun 2020 13:15:21 +0000 (15:15 +0200)
cpu_tss_rw is not directly referenced by hardware, but cpu_tss_rw is
accessed in CPU entry code, especially when #DB shifts its stacks.

If a data breakpoint would be set on cpu_tss_rw.x86_tss.ist[IST_INDEX_DB],
it would cause recursive #DB ending up in a double fault.

Add it to the list of protected items.

Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20200526014221.2119-4-laijs@linux.alibaba.com
Link: https://lkml.kernel.org/r/20200529213320.897976479@infradead.org
arch/x86/kernel/hw_breakpoint.c

index f859095c1b6c25f123a08cd006d96eec92b62675..f311bbfda1ba931f8351ff0e02efa6d3ebe5e0dc 100644 (file)
@@ -255,6 +255,15 @@ static inline bool within_cpu_entry(unsigned long addr, unsigned long end)
                if (within_area(addr, end, (unsigned long)get_cpu_gdt_rw(cpu),
                                GDT_SIZE))
                        return true;
+
+               /*
+                * cpu_tss_rw is not directly referenced by hardware, but
+                * cpu_tss_rw is also used in CPU entry code,
+                */
+               if (within_area(addr, end,
+                               (unsigned long)&per_cpu(cpu_tss_rw, cpu),
+                               sizeof(struct tss_struct)))
+                       return true;
        }
 
        return false;