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]
Date:	Mon, 20 Jul 2015 12:50:26 -0500
From:	Josh Poimboeuf <jpoimboe@...hat.com>
To:	Namhyung Kim <namhyung@...il.com>
Cc:	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	"H. Peter Anvin" <hpa@...or.com>, Michal Marek <mmarek@...e.cz>,
	Peter Zijlstra <peterz@...radead.org>,
	Andy Lutomirski <luto@...nel.org>,
	Borislav Petkov <bp@...en8.de>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Andi Kleen <andi@...stfloor.org>,
	Pedro Alves <palves@...hat.com>, x86@...nel.org,
	live-patching@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v7 2/4] x86/stackvalidate: Compile-time stack validation

On Tue, Jul 21, 2015 at 01:53:25AM +0900, Namhyung Kim wrote:
> Hi,
> 
> Just nitpicks below..

Hi Namhyung, thanks for the review!

> On Wed, Jul 15, 2015 at 2:14 AM, Josh Poimboeuf <jpoimboe@...hat.com> wrote:
> > +void elf_close(struct elf *elf)
> > +{
> > +       struct section *sec, *tmpsec;
> > +       struct symbol *sym, *tmpsym;
> > +
> > +       list_for_each_entry_safe(sec, tmpsec, &elf->sections, list) {
> > +               list_for_each_entry_safe(sym, tmpsym, &sec->symbols, list) {
> > +                       list_del(&sym->list);
> > +                       free(sym);
> > +               }
> 
> It seems that it needs to free entries in sec->relas too here.

I must confess that this program has some known memory leaks.  I
actually have a comment at the top of the file attempting to explain
why, but I'll try to improve the comment a little bit.

Many of the leaks are actually intentional, since it's a short running
program that needs to run fast (though I haven't yet optimized it for
speed).  And most of the data structures are needed until it exits
anyway.

It's perhaps distasteful, but it improves performance.  And I'm a
pragmatist at heart ;-)

That said, I will make your suggested change here, since maybe the elf.c
code might someday be reused elsewhere, and freeing memory is actually
the goal of this function.

> > +int main(int argc, char *argv[])
> > +{
> > +       struct elf *elf;
> > +       int ret = 0, warnings = 0;
> > +
> > +       argp_parse(&argp, argc, argv, 0, 0, &args);
> > +
> > +       elf = elf_open(args.args[0]);
> > +       if (!elf) {
> > +               fprintf(stderr, "error reading elf file %s\n", args.args[0]);
> > +               return 1;
> > +       }
> > +
> > +       ret = decode_sections(elf);
> > +       if (ret < 0)
> > +               goto out;
> > +       warnings += ret;
> > +
> > +       ret = validate_functions(elf);
> > +       if (ret < 0)
> > +               goto out;
> > +       warnings += ret;
> > +
> > +       ret = validate_uncallable_instructions(elf);
> > +       if (ret < 0)
> > +               goto out;
> > +       warnings += ret;
> > +
> > +out:
> 
> elf_close(elf);  ??

I intentionally left out the call to elf_close() here, since this is the
exit path and the kernel will free the memory anyway.

-- 
Josh
--
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