This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: [patch] Fix elf_getdata_rawchunk false error
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Tue, 11 Jan 2011 05:32:56 +0100
- Subject: Re: [patch] Fix elf_getdata_rawchunk false error
On Tue, 04 Jan 2011 19:03:20 +0100, Roland McGrath wrote:
> > OK to merge to master? It is now in <jankratochvil/pending>.
>
> Yes, that looks fine.
Checked in:
f1ccc410d6bda15ed49fc5d0fef9f6f65acbfb63
> > In fact I believe Elf->maximum_size should be off64_t and not size_t as this
> > way 32bit hosts cannot handle >2GB ELF files, can they?
[...]
> Someone should do the more extensive change,
> including an audit of all the uses of maximum_size. Would you like to do it?
FYI processing a WIP patch using a patch pinpointing the dangerous spots by:
typedef struct { loff_t x; } maxs_t;
#define MAXS(x) ({ maxs_t maxs = { x }; maxs; })
and doing s/(size_t|off_t|loff_t)/maxs_t/ for final easy s/maxs_t/loff_t/.
Just it is a heavy change requiring massive to-be removed modifications like:
- update_if_changed (ehdr->e_shoff, (GElf_Word) size, elf->flags);$
+ update_if_changed (ehdr->e_shoff, (GElf_Word) size.x, elf->flags);$
missing standard type of unsigned loff_t to avoid signed/unsigned comparisons:
- if (ehdr.e64->e_shoff > maxsize
+ if (ehdr.e64->e_shoff > (unsigned long long) maxsize.x
and real changes like:
/* We try to map the file ourself. */$
- map_address = mmap (NULL, maxsize, (cmd == ELF_C_READ_MMAP$
- ? PROT_READ$
- : PROT_READ|PROT_WRITE),$
- cmd == ELF_C_READ_MMAP_PRIVATE$
- || cmd == ELF_C_READ_MMAP$
- ? MAP_PRIVATE : MAP_SHARED,$
- fildes, offset);$
+ if (maxsize.x <= ~((size_t) 0))$
+ map_address = mmap (NULL, maxsize.x, (cmd == ELF_C_READ_MMAP$
+ ? PROT_READ$
+ : PROT_READ|PROT_WRITE),$
+ cmd == ELF_C_READ_MMAP_PRIVATE$
+ || cmd == ELF_C_READ_MMAP$
+ ? MAP_PRIVATE : MAP_SHARED,$
+ fildes, offset.x);$
+ else$
+ map_address = MAP_FAILED;$
off_t and loff_t should be always the same due to AC_SYS_LARGEFILE in use.
Therefore also unifying s/(off_t|loff_t)/loff_t/ as at least in public elfutils
headers apps using elfutils-libs may not be using AC_SYS_LARGEFILE.
Thanks,
Jan