Skip to contentSkip to conversation

linux-next: build failure after merge of the akpm-current tree

PATCH Stephen Rothwell 3 participants 6 messages Apr 17, 2019 – Apr 21, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi Andrew,

After merging the akpm-current tree, today's linux-next build (arm multi_v7_defconfig) failed like this:

fs/binfmt_elf.c: In function 'load_elf_binary':
fs/binfmt_elf.c:1140:7: error: 'elf_interpreter' undeclared (first use in this function); did you mean 'interpreter'?
if (!elf_interpreter)

       ^~~~~~~~~~~~~~~
       interpreter

Caused by commit

3ebf0dd657ce ("fs/binfmt_elf.c: move brk out of mmap when doing direct loader exec")

interacting with commit

a34f642bccf1 ("fs/binfmt_elf.c: free PT_INTERP filename ASAP")

I have applied the following patch for today.

From: Stephen Rothwell <[email protected]>
Date: Wed, 17 Apr 2019 16:48:29 +1000
Subject: [PATCH] fix "fs/binfmt_elf.c: move brk out of mmap when doing direct loader exec"

---
 fs/binfmt_elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/binfmt_elf.c +1 -1
index b3bbe6bca499..fe5668a1bbaa 100644
@@ -1137,7 +1137,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
 	 * collide early with the stack growing down), and into the unused
 	 * ELF_ET_DYN_BASE region.
 	 */
-	if (!elf_interpreter)
+	if (!interpreter)
 		current->mm->brk = current->mm->start_brk = ELF_ET_DYN_BASE;
 
 	if ((current->flags & PF_RANDOMIZE) && (randomize_va_space > 1)) {
Signature · 5 lines
2.20.1

-- 
Cheers,
Stephen Rothwell
#1 lore raw
Quoted 11 lines · Stephen Rothwell

Hi Andrew,

After merging the akpm-current tree, today's linux-next build (arm multi_v7_defconfig) failed like this:

fs/binfmt_elf.c: In function 'load_elf_binary':
fs/binfmt_elf.c:1140:7: error: 'elf_interpreter' undeclared (first use in this function); did you mean 'interpreter'?
if (!elf_interpreter)

       ^~~~~~~~~~~~~~~
       interpreter

static int load_elf_binary(struct linux_binprm *bprm) {
...

        char * elf_interpreter = NULL;

This is _absolutely_ a valid variable.

Quoted 26 lines

Caused by commit

3ebf0dd657ce ("fs/binfmt_elf.c: move brk out of mmap when doing direct loader exec")

interacting with commit

a34f642bccf1 ("fs/binfmt_elf.c: free PT_INTERP filename ASAP")

I have applied the following patch for today.

From: Stephen Rothwell <[email protected]>
Date: Wed, 17 Apr 2019 16:48:29 +1000
Subject: [PATCH] fix "fs/binfmt_elf.c: move brk out of mmap when doing direct loader exec"

---
 fs/binfmt_elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/binfmt_elf.c +0 -0
index b3bbe6bca499..fe5668a1bbaa 100644

fs/binfmt_elf.c static int load_elf_binary(struct linux_binprm *bprm) · line 1140

Quoted 5 lines
fs/binfmt_elf.c +1 -1
@@ -1137,7 +1137,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
         * collide early with the stack growing down), and into the unused
         * ELF_ET_DYN_BASE region.
         */
-       if (!elf_interpreter)
+       if (!interpreter)

No, this is very wrong and will, I think, cause all PIE binaries to fail to run.

Quoted 9 lines
fs/binfmt_elf.c +0 -1
                current->mm->brk = current->mm->start_brk = ELF_ET_DYN_BASE;
 
        if ((current->flags & PF_RANDOMIZE) && (randomize_va_space > 1)) {
--

2.20.1

--
Cheers,
Stephen Rothwell

Signature · 1 line
Kees Cook
#2 lore raw
Quoted 14 lines · Kees Cook
Quoted 11 lines · Stephen Rothwell

Hi Andrew,

After merging the akpm-current tree, today's linux-next build (arm multi_v7_defconfig) failed like this:

fs/binfmt_elf.c: In function 'load_elf_binary':
fs/binfmt_elf.c:1140:7: error: 'elf_interpreter' undeclared (first use in this function); did you mean 'interpreter'?
if (!elf_interpreter)

       ^~~~~~~~~~~~~~~
       interpreter
Quoted 6 lines

static int load_elf_binary(struct linux_binprm *bprm) {
...

        char * elf_interpreter = NULL;

This is _absolutely_ a valid variable.

I saw a 0day report[1] as well on MIPS for this. Neither have I been able to reproduce, though. I'm wondering if, due to the misplaced kfree() that has existed for a while, if some kind of weird scoping is happening.

What compiler are you using?

[1] https://lists.01.org/pipermail/kbuild-all/2019-April/060058.html

Quoted 22 lines
Quoted 22 lines

Caused by commit

3ebf0dd657ce ("fs/binfmt_elf.c: move brk out of mmap when doing direct loader exec")

interacting with commit

a34f642bccf1 ("fs/binfmt_elf.c: free PT_INTERP filename ASAP")

I have applied the following patch for today.

From: Stephen Rothwell <[email protected]>
Date: Wed, 17 Apr 2019 16:48:29 +1000
Subject: [PATCH] fix "fs/binfmt_elf.c: move brk out of mmap when doing direct loader exec"

---
 fs/binfmt_elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

fs/binfmt_elf.c static int load_elf_binary(struct linux_binprm *bprm) · line 1140

Quoted 10 lines
fs/binfmt_elf.c +1 -1
index b3bbe6bca499..fe5668a1bbaa 100644
@@ -1137,7 +1137,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
         * collide early with the stack growing down), and into the unused
         * ELF_ET_DYN_BASE region.
         */
-       if (!elf_interpreter)
+       if (!interpreter)

No, this is very wrong and will, I think, cause all PIE binaries to fail to run.

I may be wrong: I think this will cause all static binaries to see their brk moved very unexpectedly. All static PIE binaries will fail?

--
Kees Cook

#3 lore raw
Quoted 4 lines · Kees Cook
Quoted 2 lines · Kees Cook

On Wed, Apr 17, 2019 at 1:53 AM Stephen Rothwell <[email protected]> wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

[...]
Caused by commit

3ebf0dd657ce ("fs/binfmt_elf.c: move brk out of mmap when doing direct loader exec")

interacting with commit

a34f642bccf1 ("fs/binfmt_elf.c: free PT_INTERP filename ASAP")

I should read more closely! I see now this is the patch where elf_interpreter got moved. :)

And, yes, your fix is correct. *sigh* I will go find a brown paper bag now...

Signature · 1 line
Kees Cook
#4 lore raw
In reply to Kees Cook

Hi Kees,

Quoted 16 lines · On Wed, 17 Apr 2019 17:28:39 -0500 Kees Cook <[email protected]> wrote:
Quoted 14 lines · Kees Cook
Quoted 11 lines · Stephen Rothwell

Hi Andrew,

After merging the akpm-current tree, today's linux-next build (arm multi_v7_defconfig) failed like this:

fs/binfmt_elf.c: In function 'load_elf_binary':
fs/binfmt_elf.c:1140:7: error: 'elf_interpreter' undeclared (first use in this function); did you mean 'interpreter'?
if (!elf_interpreter)

       ^~~~~~~~~~~~~~~
       interpreter  
Quoted 6 lines
Quoted 6 lines

static int load_elf_binary(struct linux_binprm *bprm) {
...

        char * elf_interpreter = NULL;

This is _absolutely_ a valid variable.

It was. However commit a34f642bccf1 from Andrew's tree changes its scope.

So there is nothing wrong with commit 3ebf0dd657ce, it is the incorrect rebase of it on top of a34f642bccf1 that causes the build problem.

Quoted 32 lines
Quoted 19 lines
Quoted 19 lines

Caused by commit

3ebf0dd657ce ("fs/binfmt_elf.c: move brk out of mmap when doing direct loader exec")

interacting with commit

a34f642bccf1 ("fs/binfmt_elf.c: free PT_INTERP filename ASAP")

I have applied the following patch for today.

From: Stephen Rothwell <[email protected]>
Date: Wed, 17 Apr 2019 16:48:29 +1000
Subject: [PATCH] fix "fs/binfmt_elf.c: move brk out of mmap when doing direct loader exec"

---
 fs/binfmt_elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

fs/binfmt_elf.c static int load_elf_binary(struct linux_binprm *bprm) · line 1140

Quoted 10 lines
fs/binfmt_elf.c +1 -1
index b3bbe6bca499..fe5668a1bbaa 100644
@@ -1137,7 +1137,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
         * collide early with the stack growing down), and into the unused
         * ELF_ET_DYN_BASE region.
         */
-       if (!elf_interpreter)
+       if (!interpreter)  

No, this is very wrong and will, I think, cause all PIE binaries to fail to run.

Quoted 2 lines

I may be wrong: I think this will cause all static binaries to see their brk moved very unexpectedly. All static PIE binaries will fail?

Are you sure that elf_interpreter == NULL is not equivalent to interpreter == NULL by this point in the code? Earlier if elf_intpreter is not NULL, we have set interpreter (using open_exec) and errored out if that fails.

Signature · 2 lines
Cheers,
Stephen Rothwell
#5 lore raw
Quoted 63 lines · Stephen Rothwell

Hi Kees,

Quoted 16 lines · On Wed, 17 Apr 2019 17:28:39 -0500 Kees Cook <[email protected]> wrote:
Quoted 14 lines · Kees Cook
Quoted 11 lines · Stephen Rothwell

Hi Andrew,

After merging the akpm-current tree, today's linux-next build (arm multi_v7_defconfig) failed like this:

fs/binfmt_elf.c: In function 'load_elf_binary':
fs/binfmt_elf.c:1140:7: error: 'elf_interpreter' undeclared (first use in this function); did you mean 'interpreter'?
if (!elf_interpreter)

       ^~~~~~~~~~~~~~~
       interpreter  
Quoted 6 lines
Quoted 6 lines

static int load_elf_binary(struct linux_binprm *bprm) {
...

        char * elf_interpreter = NULL;

This is _absolutely_ a valid variable.

It was. However commit a34f642bccf1 from Andrew's tree changes its scope.

So there is nothing wrong with commit 3ebf0dd657ce, it is the incorrect rebase of it on top of a34f642bccf1 that causes the build problem.

Quoted 32 lines
Quoted 31 lines
Quoted 24 lines

Caused by commit

3ebf0dd657ce ("fs/binfmt_elf.c: move brk out of mmap when doing direct loader exec")

interacting with commit

a34f642bccf1 ("fs/binfmt_elf.c: free PT_INTERP filename ASAP")

I have applied the following patch for today.

From: Stephen Rothwell <[email protected]>
Date: Wed, 17 Apr 2019 16:48:29 +1000
Subject: [PATCH] fix "fs/binfmt_elf.c: move brk out of mmap when doing direct loader exec"

---
 fs/binfmt_elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/binfmt_elf.c +0 -0
index b3bbe6bca499..fe5668a1bbaa 100644

fs/binfmt_elf.c static int load_elf_binary(struct linux_binprm *bprm) · line 1140

Quoted 5 lines
fs/binfmt_elf.c +1 -1
@@ -1137,7 +1137,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
         * collide early with the stack growing down), and into the unused
         * ELF_ET_DYN_BASE region.
         */
-       if (!elf_interpreter)
+       if (!interpreter)  

No, this is very wrong and will, I think, cause all PIE binaries to fail to run.

Quoted 7 lines
Quoted 2 lines

I may be wrong: I think this will cause all static binaries to see their brk moved very unexpectedly. All static PIE binaries will fail?

Are you sure that elf_interpreter == NULL is not equivalent to interpreter == NULL by this point in the code? Earlier if elf_intpreter is not NULL, we have set interpreter (using open_exec) and errored out if that fails.

My patch was done based on this very observation: if interpreter has been opened then its filename has been allocated before otherwise how do you know which interpreter to open? Just like with pathname resolution, once lookup is done and inode has been fished out, pathname becomes irrelevant.