linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Unused local variable load_addr in load_elf_binary()
@ 2021-12-06 15:46 Lukas Bulwahn
  2021-12-07  0:01 ` Akira Kawata
  2021-12-07  2:04 ` Kees Cook
  0 siblings, 2 replies; 4+ messages in thread
From: Lukas Bulwahn @ 2021-12-06 15:46 UTC (permalink / raw)
  To: Akira Kawata
  Cc: Alexey Dobriyan, Alexander Viro, Eric Biederman, Kees Cook,
	Andrew Morton, linux-fsdevel, Linux Kernel Mailing List,
	kernel-janitors

Dear Akira-san,

With commit 0c9333606e30 ("fs/binfmt_elf: Fix AT_PHDR for unusual ELF
files"), you have changed load_elf_binary() in ./fs/binfmt_elf.c in a
way such that the local variable load_addr in load_elf_binary() is not
used anymore.

I had a quick look at the code and I think the following refactoring
would be good:

1. Remove the definition of load_addr and its unneeded computation of load_addr

2. Rename load_addr_set to first (or a similar name) to represent that
this variable is not linked to the non-existing load_addr, but states
that it captures the first iteration of the loop. Note that first has
the inverse meaning of load_addr_set.

The issue was reported by make clang-analyzer:

./fs/binfmt_elf.c:1167:5: warning: Value stored to 'load_addr' is
never read [clang-analyzer-deadcode.DeadStores]
                                load_addr += load_bias;
                                ^            ~~~~~~~~~


Best regards,

Lukas

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Unused local variable load_addr in load_elf_binary()
  2021-12-06 15:46 Unused local variable load_addr in load_elf_binary() Lukas Bulwahn
@ 2021-12-07  0:01 ` Akira Kawata
  2021-12-07  2:04 ` Kees Cook
  1 sibling, 0 replies; 4+ messages in thread
From: Akira Kawata @ 2021-12-07  0:01 UTC (permalink / raw)
  To: Lukas Bulwahn
  Cc: Alexey Dobriyan, Alexander Viro, Eric Biederman, Kees Cook,
	Andrew Morton, linux-fsdevel, Linux Kernel Mailing List,
	kernel-janitors

On Mon, Dec 06, 2021 at 04:46:01PM +0100, Lukas Bulwahn wrote:
> Dear Akira-san,
> 
> With commit 0c9333606e30 ("fs/binfmt_elf: Fix AT_PHDR for unusual ELF
> files"), you have changed load_elf_binary() in ./fs/binfmt_elf.c in a
> way such that the local variable load_addr in load_elf_binary() is not
> used anymore.
> 
> I had a quick look at the code and I think the following refactoring
> would be good:
> 
> 1. Remove the definition of load_addr and its unneeded computation of load_addr
> 
> 2. Rename load_addr_set to first (or a similar name) to represent that
> this variable is not linked to the non-existing load_addr, but states
> that it captures the first iteration of the loop. Note that first has
> the inverse meaning of load_addr_set.
> 
> The issue was reported by make clang-analyzer:
> 
> ./fs/binfmt_elf.c:1167:5: warning: Value stored to 'load_addr' is
> never read [clang-analyzer-deadcode.DeadStores]
>                                 load_addr += load_bias;
>                                 ^            ~~~~~~~~~
> 
> 
> Best regards,
> 
> Lukas

Thank you for your comments. Should I send a new patch, or change
the existing patch in linux-next?

Akira

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Unused local variable load_addr in load_elf_binary()
  2021-12-06 15:46 Unused local variable load_addr in load_elf_binary() Lukas Bulwahn
  2021-12-07  0:01 ` Akira Kawata
@ 2021-12-07  2:04 ` Kees Cook
  2021-12-07  3:23   ` Akira Kawata
  1 sibling, 1 reply; 4+ messages in thread
From: Kees Cook @ 2021-12-07  2:04 UTC (permalink / raw)
  To: Lukas Bulwahn
  Cc: Akira Kawata, Alexey Dobriyan, Alexander Viro, Eric Biederman,
	Andrew Morton, linux-fsdevel, Linux Kernel Mailing List,
	kernel-janitors

On Mon, Dec 06, 2021 at 04:46:01PM +0100, Lukas Bulwahn wrote:
> Dear Akira-san,
> 
> With commit 0c9333606e30 ("fs/binfmt_elf: Fix AT_PHDR for unusual ELF
> files"), you have changed load_elf_binary() in ./fs/binfmt_elf.c in a
> way such that the local variable load_addr in load_elf_binary() is not
> used anymore.

EEk! yeah, this totally broke ELF randomization. this needs to be
entirely reverted.

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Unused local variable load_addr in load_elf_binary()
  2021-12-07  2:04 ` Kees Cook
@ 2021-12-07  3:23   ` Akira Kawata
  0 siblings, 0 replies; 4+ messages in thread
From: Akira Kawata @ 2021-12-07  3:23 UTC (permalink / raw)
  To: Kees Cook
  Cc: Lukas Bulwahn, Alexey Dobriyan, Alexander Viro, Eric Biederman,
	Andrew Morton, linux-fsdevel, Linux Kernel Mailing List,
	kernel-janitors

On Mon, Dec 06, 2021 at 06:04:56PM -0800, Kees Cook wrote:
> On Mon, Dec 06, 2021 at 04:46:01PM +0100, Lukas Bulwahn wrote:
> > Dear Akira-san,
> > 
> > With commit 0c9333606e30 ("fs/binfmt_elf: Fix AT_PHDR for unusual ELF
> > files"), you have changed load_elf_binary() in ./fs/binfmt_elf.c in a
> > way such that the local variable load_addr in load_elf_binary() is not
> > used anymore.
> 
> EEk! yeah, this totally broke ELF randomization. this needs to be
> entirely reverted.
> 
> -- 
> Kees Cook

I think my patch doesn't affect on ELF randomization because it keeps
the way of load_addr calculation.


Akira Kawata

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-07  3:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-06 15:46 Unused local variable load_addr in load_elf_binary() Lukas Bulwahn
2021-12-07  0:01 ` Akira Kawata
2021-12-07  2:04 ` Kees Cook
2021-12-07  3:23   ` Akira Kawata

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).