All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sparc: piggyback: handle invalid image
@ 2020-06-10  7:55 Corentin Labbe
  2020-06-22 22:44   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Corentin Labbe @ 2020-06-10  7:55 UTC (permalink / raw)
  To: davem; +Cc: linux-kernel, sparclinux, Corentin Labbe

With an old elftoaout, the generation of tftpboot.img fail with "lseek:
invalid argument".
This is due to offset being negative.

Instead of printing this error message, let's print a better one.

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
 arch/sparc/boot/piggyback.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/sparc/boot/piggyback.c b/arch/sparc/boot/piggyback.c
index a7a38fb4ece0..613e23a1016e 100644
--- a/arch/sparc/boot/piggyback.c
+++ b/arch/sparc/boot/piggyback.c
@@ -154,6 +154,10 @@ static off_t get_hdrs_offset(int kernelfd, const char *filename)
 		offset -= LOOKBACK;
 		/* skip a.out header */
 		offset += AOUT_TEXT_OFFSET;
+		if (offset < 0) {
+			errno = -EINVAL;
+			die("Calculated a negative offset, probably elftoaout generated an invalid image. Did you use a recent elftoaout ?");
+		}
 		if (lseek(kernelfd, offset, SEEK_SET) < 0)
 			die("lseek");
 		if (read(kernelfd, buffer, BUFSIZE) != BUFSIZE)
-- 
2.26.2


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

* Re: [PATCH] sparc: piggyback: handle invalid image
  2020-06-10  7:55 [PATCH] sparc: piggyback: handle invalid image Corentin Labbe
@ 2020-06-22 22:44   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2020-06-22 22:44 UTC (permalink / raw)
  To: clabbe; +Cc: linux-kernel, sparclinux

From: Corentin Labbe <clabbe@baylibre.com>
Date: Wed, 10 Jun 2020 07:55:19 +0000

> With an old elftoaout, the generation of tftpboot.img fail with "lseek:
> invalid argument".
> This is due to offset being negative.
> 
> Instead of printing this error message, let's print a better one.
> 
> Signed-off-by: Corentin Labbe <clabbe@baylibre.com>

Applied, thank you.

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

* Re: [PATCH] sparc: piggyback: handle invalid image
@ 2020-06-22 22:44   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2020-06-22 22:44 UTC (permalink / raw)
  To: clabbe; +Cc: linux-kernel, sparclinux

From: Corentin Labbe <clabbe@baylibre.com>
Date: Wed, 10 Jun 2020 07:55:19 +0000

> With an old elftoaout, the generation of tftpboot.img fail with "lseek:
> invalid argument".
> This is due to offset being negative.
> 
> Instead of printing this error message, let's print a better one.
> 
> Signed-off-by: Corentin Labbe <clabbe@baylibre.com>

Applied, thank you.

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

end of thread, other threads:[~2020-06-22 22:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-10  7:55 [PATCH] sparc: piggyback: handle invalid image Corentin Labbe
2020-06-22 22:44 ` David Miller
2020-06-22 22:44   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.