RE: [PATCH 4.14 31/34] perf/x86/intel: Fix memory corruption

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Greg,

I was able to reproduce the kernel crash on 4.14, 4.19 and 4.20 kernels. Will apply your patches and re-test.

Thanks,
Nelson

-----Original Message-----
From: Greg Kroah-Hartman [mailto:gregkh@xxxxxxxxxxxxxxxxxxx] 
Sent: Monday, March 18, 2019 2:26 AM
To: linux-kernel@xxxxxxxxxxxxxxx
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>; stable@xxxxxxxxxxxxxxx; Tony Jones <tonyj@xxxxxxxx>; DSouza, Nelson <nelson.dsouza@xxxxxxxxx>; Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>; Thomas Gleixner <tglx@xxxxxxxxxxxxx>; eranian@xxxxxxxxxx; jolsa@xxxxxxxxxx; stable@xxxxxxxxxx
Subject: [PATCH 4.14 31/34] perf/x86/intel: Fix memory corruption

4.14-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Peter Zijlstra <peterz@xxxxxxxxxxxxx>

commit ede271b059463731cbd6dffe55ffd70d7dbe8392 upstream.

Through:

  validate_event()
    x86_pmu.get_event_constraints(.idx=-1)
      tfa_get_event_constraints()
        dyn_constraint()

cpuc->constraint_list[-1] is used, which is an obvious out-of-bound access.

In this case, simply skip the TFA constraint code, there is no event constraint with just PMC3, therefore the code will never result in the empty set.

Fixes: 400816f60c54 ("perf/x86/intel: Implement support for TSX Force Abort")
Reported-by: Tony Jones <tonyj@xxxxxxxx>
Reported-by: "DSouza, Nelson" <nelson.dsouza@xxxxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Tested-by: Tony Jones <tonyj@xxxxxxxx>
Tested-by: "DSouza, Nelson" <nelson.dsouza@xxxxxxxxx>
Cc: eranian@xxxxxxxxxx
Cc: jolsa@xxxxxxxxxx
Cc: stable@xxxxxxxxxx
Link: https://lkml.kernel.org/r/20190314130705.441549378@xxxxxxxxxxxxx
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
 arch/x86/events/intel/core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3262,7 +3262,7 @@ tfa_get_event_constraints(struct cpu_hw_
 	/*
 	 * Without TFA we must not use PMC3.
 	 */
-	if (!allow_tsx_force_abort && test_bit(3, c->idxmsk)) {
+	if (!allow_tsx_force_abort && test_bit(3, c->idxmsk) && idx >= 0) {
 		c = dyn_constraint(cpuc, c, idx);
 		c->idxmsk64 &= ~(1ULL << 3);
 		c->weight--;






[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux