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: <20230628172659.6qwbswgz4ki24wyv@lion.mk-sys.cz>
Date:   Wed, 28 Jun 2023 19:26:59 +0200
From:   Michal Kubecek <mkubecek@...e.cz>
To:     Josh Poimboeuf <jpoimboe@...nel.org>
Cc:     Peter Zijlstra <peterz@...radead.org>, linux-kernel@...r.kernel.org
Subject: Re: build failure after commit eb0481bbc4ce ("objtool: Fix
 reloc_hash size")

On Wed, Jun 28, 2023 at 10:05:30AM -0700, Josh Poimboeuf wrote:
> On Wed, Jun 28, 2023 at 06:45:54PM +0200, Michal Kubecek wrote:
> > On Wed, Jun 28, 2023 at 06:06:31PM +0200, Michal Kubecek wrote:
> > > On Wed, Jun 28, 2023 at 05:44:32PM +0200, Michal Kubecek wrote:
> > > > On Wed, Jun 28, 2023 at 08:16:54AM -0700, Josh Poimboeuf wrote:
> > > > > Interesting.  Can you add the below patch and also do:
> > > > > 
> > > > >   make net/ipv4/netfilter/iptable_nat.o OBJTOOL_ARGS="--stats"
> > > > > 
> > > > > and report the output?
> > > > 
> > > > With these, I get
> > > > 
> > > >     ...
> > > >       CC [M]  net/ipv4/netfilter/iptable_nat.o
> > > >     nr_sections: 40
> > > >     section_bits: 10
> > > >     nr_symbols: 41
> > > >     symbol_bits: 10
> > > >     mmap reloc: Invalid argument
> > > >     make[1]: Leaving directory '/srv/ram/kobj'
> > > 
> > > Not sure if it's of any use but I also tried to run it under strace and
> > > the failed mmap() call seems to be
> > > 
> > >   18761 mmap(NULL, 0, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 EINVAL (Invalid argument)
> > > 
> > > Perhaps the problem could be that elf->num_relocs may be zero?
> > 
> > I added a printf() and got
> > 
> >   size = -4991471925827290382 = 0xbababababababaf2
> > 
> > for the elf_alloc_hash() invocation resulting in failed mmap().
> 
> Wut.  Can you share the .o file?

It is at http://www.mk-sys.cz/tmp/iptable_nat.o

I digged some more and my guess is that the problem is that
elf_open_read() does

	memset(elf, 0, offsetof(struct elf, sections));

but commit eb0481bbc4ce ("objtool: Fix reloc_hash size") added
num_relocs after sections so that it is not zeroed (0xbabababababababa
is probably some kind of poison).

So I tried

------------------------------------------------------------------------
--- a/tools/objtool/include/objtool/elf.h
+++ b/tools/objtool/include/objtool/elf.h
@@ -84,8 +84,8 @@ struct elf {
 	bool changed;
 	char *name;
 	unsigned int num_files;
-	struct list_head sections;
 	unsigned long num_relocs;
+	struct list_head sections;
 
 	int symbol_bits;
 	int symbol_name_bits;
------------------------------------------------------------------------

and the build succeeds now. But I cannot say if it's enough.

Michal

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ