Skip to contentSkip to conversation

binfmt_flat: fix sparse annotation ordering

PATCH In review Niklas Cassel 4 participants 7 messages Apr 18, 2022 – Apr 20, 2022

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

PATCH 1/1 binfmt_flat: fix sparse annotation ordering

From: Niklas Cassel <[email protected]>

The sparse annotation ordering inside the function call is swapped.

Fix the ordering so that we silence the following sparse warnings:
fs/binfmt_flat.c:816:39: warning: incorrect type in argument 1 (different address spaces)
fs/binfmt_flat.c:816:39: expected unsigned int [noderef] [usertype] __user *rp
fs/binfmt_flat.c:816:39: got unsigned int [usertype] *[noderef] __user

No functional change as sparse annotations are ignored by the compiler.

Fixes a767e6fd68d2 ("binfmt_flat: do not stop relocating GOT entries prematurely on riscv")

---
Hello Kees,

Sorry about this.
Feel free to squash it with the existing patch if you so like.

 fs/binfmt_flat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/binfmt_flat.c +1 -1
index e5e2a03b39c1..dca0b6875f9c 100644
@@ -813,7 +813,7 @@ static int load_flat_file(struct linux_binprm *bprm,
 	 * image.
 	 */
 	if (flags & FLAT_FLAG_GOTPIC) {
-		rp = skip_got_header((u32 * __user) datapos);
+		rp = skip_got_header((u32 __user *) datapos);
 		for (; ; rp++) {
 			u32 addr, rp_val;
 			if (get_user(rp_val, rp))
Signature · 1 line
2.35.1
#1 lore raw
Quoted 15 lines · Niklas Cassel

From: Niklas Cassel <[email protected]>

The sparse annotation ordering inside the function call is swapped.

Fix the ordering so that we silence the following sparse warnings:
fs/binfmt_flat.c:816:39: warning: incorrect type in argument 1 (different address spaces)
fs/binfmt_flat.c:816:39: expected unsigned int [noderef] [usertype] __user *rp
fs/binfmt_flat.c:816:39: got unsigned int [usertype] *[noderef] __user

No functional change as sparse annotations are ignored by the compiler.

Fixes a767e6fd68d2 ("binfmt_flat: do not stop relocating GOT entries prematurely on riscv")
Quoted 5 lines

---
Hello Kees,

Sorry about this.
Feel free to squash it with the existing patch if you so like.

Ah-ha! Thanks; I was just looking at the sparse email. :)

-Kees

Quoted 19 lines
 fs/binfmt_flat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/binfmt_flat.c +1 -1
index e5e2a03b39c1..dca0b6875f9c 100644
@@ -813,7 +813,7 @@ static int load_flat_file(struct linux_binprm *bprm,
 	 * image.
 	 */
 	if (flags & FLAT_FLAG_GOTPIC) {
-		rp = skip_got_header((u32 * __user) datapos);
+		rp = skip_got_header((u32 __user *) datapos);
 		for (; ; rp++) {
 			u32 addr, rp_val;
 			if (get_user(rp_val, rp))
Signature · 1 line
2.35.1
Signature · 1 line
Kees Cook
#2 lore raw

PATCH 1/1 binfmt_flat; Drop vestigates of coredump support

There is the briefest start of coredump support in binfmt_flat. It is actually a pain to maintain as binfmt_flat is not built on most architectures so it is easy to overlook.

Since the support does not do anything remove it.

---

Apologies for hijacking this thread but it looks like we have people who are actively using binfmt_flat on it.

Does anyone have any objections to simply removing what little there is of coredump support from binfmt_flat?

Eric

 fs/binfmt_flat.c | 22 ----------------------
 1 file changed, 22 deletions(-)
fs/binfmt_flat.c +0 -22
index 626898150011..0ad2c7bbaddd 100644
@@ -37,7 +37,6 @@
 #include <linux/flat.h>
 #include <linux/uaccess.h>
 #include <linux/vmalloc.h>
-#include <linux/coredump.h>
 
 #include <asm/byteorder.h>
 #include <asm/unaligned.h>
@@ -98,33 +97,12 @@ static int load_flat_shared_library(int id, struct lib_info *p);
 #endif
 
 static int load_flat_binary(struct linux_binprm *);
-#ifdef CONFIG_COREDUMP
-static int flat_core_dump(struct coredump_params *cprm);
-#endif
 
 static struct linux_binfmt flat_format = {
 	.module		= THIS_MODULE,
 	.load_binary	= load_flat_binary,
-#ifdef CONFIG_COREDUMP
-	.core_dump	= flat_core_dump,
-	.min_coredump	= PAGE_SIZE
-#endif
 };
 
-/****************************************************************************/
-/*
- * Routine writes a core dump image in the current directory.
- * Currently only a stub-function.
- */
-
-#ifdef CONFIG_COREDUMP
-static int flat_core_dump(struct coredump_params *cprm)
-{
-	pr_warn("Process %s:%d received signr %d and should have core dumped\n",
-		current->comm, current->pid, cprm->siginfo->si_signo);
-	return 1;
-}
-#endif
 
 /****************************************************************************/
 /*
Signature · 1 line
2.35.3
author Reviewed-by on v1 1/1
#3 lore raw

Re: [PATCH] binfmt_flat; Drop vestigates of coredump support

Quoted 54 lines · Eric W. Biederman

There is the briefest start of coredump support in binfmt_flat. It is actually a pain to maintain as binfmt_flat is not built on most architectures so it is easy to overlook.

Since the support does not do anything remove it.

---

Apologies for hijacking this thread but it looks like we have people who are actively using binfmt_flat on it.

Does anyone have any objections to simply removing what little there is of coredump support from binfmt_flat?

Eric

 fs/binfmt_flat.c | 22 ----------------------
 1 file changed, 22 deletions(-)
fs/binfmt_flat.c +0 -12
index 626898150011..0ad2c7bbaddd 100644
@@ -37,7 +37,6 @@
 #include <linux/flat.h>
 #include <linux/uaccess.h>
 #include <linux/vmalloc.h>
-#include <linux/coredump.h>
 
 #include <asm/byteorder.h>
 #include <asm/unaligned.h>
@@ -98,33 +97,12 @@ static int load_flat_shared_library(int id, struct lib_info *p);
 #endif
 
 static int load_flat_binary(struct linux_binprm *);
-#ifdef CONFIG_COREDUMP
-static int flat_core_dump(struct coredump_params *cprm);
-#endif
 
 static struct linux_binfmt flat_format = {
 	.module		= THIS_MODULE,
 	.load_binary	= load_flat_binary,
-#ifdef CONFIG_COREDUMP
-	.core_dump	= flat_core_dump,
-	.min_coredump	= PAGE_SIZE
-#endif
 };
 
-/****************************************************************************/
-/*
- * Routine writes a core dump image in the current directory.
- * Currently only a stub-function.

fs/binfmt_flat.c static int load_flat_shared_library(int id, struct lib_info *p); · line 127

Quoted 10 lines
fs/binfmt_flat.c +0 -10
- */
-
-#ifdef CONFIG_COREDUMP
-static int flat_core_dump(struct coredump_params *cprm)
-{
-	pr_warn("Process %s:%d received signr %d and should have core dumped\n",
-		current->comm, current->pid, cprm->siginfo->si_signo);
-	return 1;
-}
-#endif

Since this only prints a warning that the process "should have core dumped", I agree, I don't really see the point of keeping this code.

nit: $subject: "binfmt_flat; Drop vestigates of coredump support" s/;/:/

Other than that:

Applied
#4 lore raw

Re: (subset) [PATCH] binfmt_flat; Drop vestigates of coredump support

In reply to Eric W. Biederman
Quoted 8 lines · Eric W. Biederman

There is the briefest start of coredump support in binfmt_flat. It is actually a pain to maintain as binfmt_flat is not built on most architectures so it is easy to overlook.

Since the support does not do anything remove it.

[...]

Applied to for-next/execve, thanks! (With typo nits fixed.)

[1/1] binfmt_flat; Drop vestigates of coredump support

      https://git.kernel.org/kees/c/6e1a873cefd1
Signature · 1 line
Kees Cook
#5 lore raw

Re: (subset) [PATCH] binfmt_flat; Drop vestigates of coredump support

Quoted 8 lines · Kees Cook
Quoted 7 lines · Eric W. Biederman

There is the briefest start of coredump support in binfmt_flat. It is actually a pain to maintain as binfmt_flat is not built on most architectures so it is easy to overlook.

Since the support does not do anything remove it.

Quoted 6 lines
Quoted 1 line

[...]

Applied to for-next/execve, thanks! (With typo nits fixed.)

[1/1] binfmt_flat; Drop vestigates of coredump support

      https://git.kernel.org/kees/c/6e1a873cefd1

Thanks,
Eric

Acked-by on v1 1/1
#6 lore raw

Re: [PATCH] binfmt_flat; Drop vestigates of coredump support

In reply to Eric W. Biederman
Quoted 6 lines · Eric W. Biederman

There is the briefest start of coredump support in binfmt_flat. It is actually a pain to maintain as binfmt_flat is not built on most architectures so it is easy to overlook.

Since the support does not do anything remove it.

Quoted 8 lines

---

Apologies for hijacking this thread but it looks like we have people who are actively using binfmt_flat on it.

Does anyone have any objections to simply removing what little there is of coredump support from binfmt_flat?

No objections from me.

Quoted 51 lines

Eric

  fs/binfmt_flat.c | 22 ----------------------
  1 file changed, 22 deletions(-)
fs/binfmt_flat.c +0 -22
index 626898150011..0ad2c7bbaddd 100644
@@ -37,7 +37,6 @@
  #include <linux/flat.h>
  #include <linux/uaccess.h>
  #include <linux/vmalloc.h>
-#include <linux/coredump.h>
 
  #include <asm/byteorder.h>
  #include <asm/unaligned.h>
@@ -98,33 +97,12 @@ static int load_flat_shared_library(int id, struct lib_info *p);
  #endif
 
  static int load_flat_binary(struct linux_binprm *);
-#ifdef CONFIG_COREDUMP
-static int flat_core_dump(struct coredump_params *cprm);
-#endif
 
  static struct linux_binfmt flat_format = {
  	.module		= THIS_MODULE,
  	.load_binary	= load_flat_binary,
-#ifdef CONFIG_COREDUMP
-	.core_dump	= flat_core_dump,
-	.min_coredump	= PAGE_SIZE
-#endif
  };
 
-/****************************************************************************/
-/*
- * Routine writes a core dump image in the current directory.
- * Currently only a stub-function.
- */
-
-#ifdef CONFIG_COREDUMP
-static int flat_core_dump(struct coredump_params *cprm)
-{
-	pr_warn("Process %s:%d received signr %d and should have core dumped\n",
-		current->comm, current->pid, cprm->siginfo->si_signo);
-	return 1;
-}
-#endif
 
  /****************************************************************************/
  /*