diff options
author | Christoph Hellwig <hch@lst.de> | 2017-09-01 11:39:13 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2017-09-04 19:05:15 -0400 |
commit | bdd1d2d3d251c65b74ac4493e08db18971c09240 (patch) | |
tree | 71df247eeb367203c59a26eed8a384398c2d8131 /fs/binfmt_elf.c | |
parent | c41fbad015dabb0a40ecca50c3ff5658eb6471ff (diff) |
fs: fix kernel_read prototype
Use proper ssize_t and size_t types for the return value and count
argument, move the offset last and make it an in/out argument like
all other read/write helpers, and make the buf argument a void pointer
to get rid of lots of casts in the callers.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/binfmt_elf.c')
-rw-r--r-- | fs/binfmt_elf.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 6466153f2bf0..2f928b87c90e 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -409,6 +409,7 @@ static struct elf_phdr *load_elf_phdrs(struct elfhdr *elf_ex, | |||
409 | { | 409 | { |
410 | struct elf_phdr *elf_phdata = NULL; | 410 | struct elf_phdr *elf_phdata = NULL; |
411 | int retval, size, err = -1; | 411 | int retval, size, err = -1; |
412 | loff_t pos = elf_ex->e_phoff; | ||
412 | 413 | ||
413 | /* | 414 | /* |
414 | * If the size of this structure has changed, then punt, since | 415 | * If the size of this structure has changed, then punt, since |
@@ -432,8 +433,7 @@ static struct elf_phdr *load_elf_phdrs(struct elfhdr *elf_ex, | |||
432 | goto out; | 433 | goto out; |
433 | 434 | ||
434 | /* Read in the program headers */ | 435 | /* Read in the program headers */ |
435 | retval = kernel_read(elf_file, elf_ex->e_phoff, | 436 | retval = kernel_read(elf_file, elf_phdata, size, &pos); |
436 | (char *)elf_phdata, size); | ||
437 | if (retval != size) { | 437 | if (retval != size) { |
438 | err = (retval < 0) ? retval : -EIO; | 438 | err = (retval < 0) ? retval : -EIO; |
439 | goto out; | 439 | goto out; |
@@ -698,6 +698,7 @@ static int load_elf_binary(struct linux_binprm *bprm) | |||
698 | struct elfhdr interp_elf_ex; | 698 | struct elfhdr interp_elf_ex; |
699 | } *loc; | 699 | } *loc; |
700 | struct arch_elf_state arch_state = INIT_ARCH_ELF_STATE; | 700 | struct arch_elf_state arch_state = INIT_ARCH_ELF_STATE; |
701 | loff_t pos; | ||
701 | 702 | ||
702 | loc = kmalloc(sizeof(*loc), GFP_KERNEL); | 703 | loc = kmalloc(sizeof(*loc), GFP_KERNEL); |
703 | if (!loc) { | 704 | if (!loc) { |
@@ -750,9 +751,9 @@ static int load_elf_binary(struct linux_binprm *bprm) | |||
750 | if (!elf_interpreter) | 751 | if (!elf_interpreter) |
751 | goto out_free_ph; | 752 | goto out_free_ph; |
752 | 753 | ||
753 | retval = kernel_read(bprm->file, elf_ppnt->p_offset, | 754 | pos = elf_ppnt->p_offset; |
754 | elf_interpreter, | 755 | retval = kernel_read(bprm->file, elf_interpreter, |
755 | elf_ppnt->p_filesz); | 756 | elf_ppnt->p_filesz, &pos); |
756 | if (retval != elf_ppnt->p_filesz) { | 757 | if (retval != elf_ppnt->p_filesz) { |
757 | if (retval >= 0) | 758 | if (retval >= 0) |
758 | retval = -EIO; | 759 | retval = -EIO; |
@@ -776,9 +777,9 @@ static int load_elf_binary(struct linux_binprm *bprm) | |||
776 | would_dump(bprm, interpreter); | 777 | would_dump(bprm, interpreter); |
777 | 778 | ||
778 | /* Get the exec headers */ | 779 | /* Get the exec headers */ |
779 | retval = kernel_read(interpreter, 0, | 780 | pos = 0; |
780 | (void *)&loc->interp_elf_ex, | 781 | retval = kernel_read(interpreter, &loc->interp_elf_ex, |
781 | sizeof(loc->interp_elf_ex)); | 782 | sizeof(loc->interp_elf_ex), &pos); |
782 | if (retval != sizeof(loc->interp_elf_ex)) { | 783 | if (retval != sizeof(loc->interp_elf_ex)) { |
783 | if (retval >= 0) | 784 | if (retval >= 0) |
784 | retval = -EIO; | 785 | retval = -EIO; |
@@ -1175,9 +1176,10 @@ static int load_elf_library(struct file *file) | |||
1175 | unsigned long elf_bss, bss, len; | 1176 | unsigned long elf_bss, bss, len; |
1176 | int retval, error, i, j; | 1177 | int retval, error, i, j; |
1177 | struct elfhdr elf_ex; | 1178 | struct elfhdr elf_ex; |
1179 | loff_t pos = 0; | ||
1178 | 1180 | ||
1179 | error = -ENOEXEC; | 1181 | error = -ENOEXEC; |
1180 | retval = kernel_read(file, 0, (char *)&elf_ex, sizeof(elf_ex)); | 1182 | retval = kernel_read(file, &elf_ex, sizeof(elf_ex), &pos); |
1181 | if (retval != sizeof(elf_ex)) | 1183 | if (retval != sizeof(elf_ex)) |
1182 | goto out; | 1184 | goto out; |
1183 | 1185 | ||
@@ -1201,7 +1203,8 @@ static int load_elf_library(struct file *file) | |||
1201 | 1203 | ||
1202 | eppnt = elf_phdata; | 1204 | eppnt = elf_phdata; |
1203 | error = -ENOEXEC; | 1205 | error = -ENOEXEC; |
1204 | retval = kernel_read(file, elf_ex.e_phoff, (char *)eppnt, j); | 1206 | pos = elf_ex.e_phoff; |
1207 | retval = kernel_read(file, eppnt, j, &pos); | ||
1205 | if (retval != j) | 1208 | if (retval != j) |
1206 | goto out_free_ph; | 1209 | goto out_free_ph; |
1207 | 1210 | ||