[erlang-patches] [PATCH] Fix memory corruption when reading topology information

Benjamin Herrenschmidt <>
Tue Mar 13 21:14:26 CET 2012


On Tue, 2012-03-13 at 14:50 +0100, Gustav Simonsson wrote:
> Hi Benjamin,
> 
> We discovered this error in a few other places, and will create a 
> slightly larger internal patch for this issue.
> Thank you for finding this error and reporting it!

Thanks. Any chance you can CC me on the patch ? I'd like to try to get
it included/backported in some distro as it prevents anything using
erlang from running on some setups. (Typically if you have unplugged
CPU, which is common when running KVM on POWER7 machines where the host
has to unplug the SMT threads).

Cheers,
Ben.

> Regards,
> Gustav Simonsson
> Erlang/OTP team
> 
> 
> On 2012-03-09 04:23, Benjamin Herrenschmidt wrote:
> > If the number of processors actually found while reading sysfs
> > is lower than the configured value, we realloc() the cpuinfo array
> > to the smaller size, but we then iterate it using the original
> > configured size, thus corrupting memory beyond the allocated
> > block.
> >
> > Signed-off-by: Benjamin Herrenschmidt<>
> > ---
> >
> > diff -urN otp_src_R15B.orig/erts/lib_src/common/erl_misc_utils.c otp_src_R15B/erts/lib_src/common/erl_misc_utils.c
> > --- otp_src_R15B.orig/erts/lib_src/common/erl_misc_utils.c	2011-12-14 21:22:11.000000000 +1100
> > +++ otp_src_R15B/erts/lib_src/common/erl_misc_utils.c	2012-03-08 14:40:18.111420986 +1100
> > @@ -939,7 +939,7 @@
> >
> >   	if (res>  1) {
> >   	    prev = this++;
> > -	    last =&cpuinfo->topology[cpuinfo->configured-1];
> > +	    last =&cpuinfo->topology[cpuinfo->topology_size-1];
> >
> >   	    while (1) {
> >   		this->thread = ((this->node == prev->node
> >
> >
> >
> > _______________________________________________
> > erlang-patches mailing list
> > 
> > http://erlang.org/mailman/listinfo/erlang-patches




More information about the erlang-patches mailing list