lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABPqkBT=rEg_q6vmtsVc4YKC_5Y=T7-PZkj7VZNTZ5iDcFFrKQ@mail.gmail.com>
Date:	Thu, 10 Sep 2015 01:54:18 -0700
From:	Stephane Eranian <eranian@...gle.com>
To:	Sasha Levin <sasha.levin@...cle.com>
Cc:	Peter Zijlstra <peterz@...radead.org>,
	Ingo Molnar <mingo@...nel.org>,
	Vince Weaver <vincent.weaver@...ne.edu>,
	Jiri Olsa <jolsa@...hat.com>,
	"Liang, Kan" <kan.liang@...el.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Andrew Hunter <ahh@...gle.com>,
	Maria Dimakopoulou <maria.n.dimakopoulou@...il.com>
Subject: Re: [PATCH 01/10] perf,x86: Fix event/group validation

On Fri, Aug 21, 2015 at 1:31 PM, Sasha Levin <sasha.levin@...cle.com> wrote:
>
> On 05/21/2015 07:17 AM, Peter Zijlstra wrote:
> > --- a/arch/x86/kernel/cpu/perf_event_intel.c
> > +++ b/arch/x86/kernel/cpu/perf_event_intel.c
> > @@ -2106,7 +2106,7 @@ static struct event_constraint *
> >  intel_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
> >                           struct perf_event *event)
> >  {
> > -     struct event_constraint *c1 = event->hw.constraint;
> > +     struct event_constraint *c1 = cpuc->event_constraint[idx];
> >       struct event_constraint *c2;
>
> Hey Peter,
>
> I was chasing a memory corruption in this area and I think I found
> a possible culprit:
>
> After this patch, In the code above, we'd access "cpuc->event_constraint[idx]"
> and read/change memory.
>
> The problem is that a valid value for idx is also -1, which isn't checked
> here, so we end up accessing and possibly corrupting memory that isn't ours.
>
>
I believe your analysis is correct, the following path will create the problem:

   validate_group()
         validate_event()
             x86_pmu.get_event_constraints(fake_cpuc, -1, event)
             intel_get_event_constraints(cpuc, idx, event)
                 struct event_constraints *c1  = cpuc->event_constraints[idx];

here idx = -1, and the kernel is accessing an invalid memory location.

If think the code could be changed to:

   struct event_constraint *c1 = NULL;
   if (idx > -1)
       c1 = cpuc->event_constraints[idx];

idx is not used in the __intel_get_event_constraints() path if I read
the code correctly.

Peter?



>
> Thanks,
> Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ