[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Xen-devel] [PATCH v9 10/27] xsplice: Add helper elf routines
- To: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>, <konrad@xxxxxxxxxx>, <sasha.levin@xxxxxxxxxx>, <andrew.cooper3@xxxxxxxxxx>, <mpohlack@xxxxxxxxx>
- From: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
- Date: Tue, 26 Apr 2016 11:05:00 +0100
- Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Keir Fraser <keir@xxxxxxx>, Ian Jackson <ian.jackson@xxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Tim Deegan <tim@xxxxxxx>
- Delivery-date: Tue, 26 Apr 2016 10:05:12 +0000
- List-id: Xen developer discussion <xen-devel.lists.xen.org>
On 04/25/2016 04:34 PM, Konrad Rzeszutek Wilk wrote:
snip
+static int xsplice_header_check(const struct xsplice_elf *elf)
+{
+ const Elf_Ehdr *hdr = elf->hdr;
+
+ if ( sizeof(*elf->hdr) > elf->len )
+ {
+ dprintk(XENLOG_ERR, XSPLICE "%s: Section header is bigger than
payload!\n",
+ elf->name);
+ return -EINVAL;
+ }
+
+ if ( !IS_ELF(*hdr) )
+ {
+ dprintk(XENLOG_ERR, XSPLICE "%s: Not an ELF payload!\n", elf->name);
+ return -EINVAL;
+ }
+
+ if ( hdr->e_ident[EI_CLASS] != ELFCLASS64 ||
+ hdr->e_ident[EI_DATA] != ELFDATA2LSB ||
+ hdr->e_ident[EI_OSABI] != ELFOSABI_SYSV ||
+ hdr->e_type != ET_REL ||
+ hdr->e_phnum != 0 )
+ {
+ dprintk(XENLOG_ERR, XSPLICE "%s: Invalid ELF payload!\n", elf->name);
+ return -EOPNOTSUPP;
+ }
+
+ if ( elf->hdr->e_shstrndx == SHN_UNDEF )
+ {
+ dprintk(XENLOG_ERR, XSPLICE "%s: Section name idx is undefined!?\n",
+ elf->name);
+ return -EINVAL;
+ }
+
+ /* Check that section name index is within the sections. */
+ if ( elf->hdr->e_shstrndx >= elf->hdr->e_shnum )
+ {
+ dprintk(XENLOG_ERR, XSPLICE "%s: Section name idx (%u) is past end of
sections (%u)!\n",
+ elf->name, elf->hdr->e_shstrndx, elf->hdr->e_shnum);
+ return -EINVAL;
+ }
+
+ if ( elf->hdr->e_shnum > 64 )
+ {
+ dprintk(XENLOG_ERR, XSPLICE "%s: Too many (%u) sections!\n",
+ elf->name, elf->hdr->e_shnum);
+ return -EOPNOTSUPP;
+ }
If I recall correctly, Andrew asked you to add this check. Due to
compiling with -ffunction-sections -fdata-sections, the build tool can
quite easily exceed this limit. IMO the check doesn't serve any useful
purpose and should be removed.
--
Ross Lagerwall
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|