summaryrefslogtreecommitdiffstats
path: root/arch/sparc
diff options
context:
space:
mode:
authorCorentin Labbe <clabbe@baylibre.com>2020-06-10 09:55:19 +0200
committerDavid S. Miller <davem@davemloft.net>2020-06-23 00:44:44 +0200
commit5124b31c1e90797e26710377d04eb005759494a0 (patch)
tree11718a328be41b541e8b3141f34e2dbd4ea3a5d0 /arch/sparc
parentsparc64: viohs: Use struct_size() helper (diff)
downloadlinux-5124b31c1e90797e26710377d04eb005759494a0.tar.xz
linux-5124b31c1e90797e26710377d04eb005759494a0.zip
sparc: piggyback: handle invalid image
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> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc')
-rw-r--r--arch/sparc/boot/piggyback.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/sparc/boot/piggyback.c b/arch/sparc/boot/piggyback.c
index a7a38fb4ece0..6d74064add0a 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)