[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK7LNARV34onaXiZA-UAvKZdwnfX_D3g=k0a8EJkD4HzEWRo-Q@mail.gmail.com>
Date: Tue, 11 Feb 2020 23:46:38 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: Justin Capella <justincapella@...il.com>
Cc: Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>,
youling257 <youling257@...il.com>, Pavel Machek <pavel@....cz>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] scripts/kallsyms: fix memory corruption caused by write over-run
Hi.
On Tue, Feb 11, 2020 at 11:36 AM Justin Capella <justincapella@...il.com> wrote:
>
> Looks like len is already +1, maybe it shouldn't be?
This increment is for storing one more character, 'type'.
sym->sym[0] = type;
> > len = strlen(name) + 1;
> >
> > - sym = malloc(sizeof(*sym) + len);
> > + sym = malloc(sizeof(*sym) + len + 1);
This increment is for the '\0' termination.
So, malloc() needs to allocate:
sizeof(*sym) + strlen(name) + 2.
>
>
> Maybe strlcpy or if len wasn't incremented?
>
> >
> > - memcpy(sym_name(sym), name, len);
> > + strcpy(sym_name(sym), name);
> >
--
Best Regards
Masahiro Yamada
Powered by blists - more mailing lists