Hello,

I have a seL4 project that creates a number of processes with multiple
threads. An application works fine. Every process periodically calculates
the checksum of the executable segment and the system (Monitor process)
keeps track that these values should be the same over the time.
Some time when I change (add) some code in amu process I have an error that
Monitor process prints

CHECKSUM ERROR -------- Someone modified executable memory process=Startup
  0x400000 8868997 last->10daf436f961b809 this->95ebd3119aee7736!!!!

It always complains about the root (Startup) task. Checksum value changes
every time the Startup process calculates it.

The code that calculate executable segment are:

typedef struct
{
  unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
  Elf64_Half e_type; /* Object file type */
  Elf64_Half e_machine; /* Architecture */
  Elf64_Word e_version; /* Object file version */
  Elf64_Addr e_entry; /* Entry point virtual address */
  Elf64_Off e_phoff; /* Program header table file offset */
  Elf64_Off e_shoff; /* Section header table file offset */
  Elf64_Word e_flags; /* Processor-specific flags */
  Elf64_Half e_ehsize; /* ELF header size in bytes */
  Elf64_Half e_phentsize; /* Program header table entry size */
  Elf64_Half e_phnum; /* Program header table entry count */
  Elf64_Half e_shentsize; /* Section header table entry size */
  Elf64_Half e_shnum; /* Section header table entry count */
  Elf64_Half e_shstrndx; /* Section header string table index */
} Elf64_Ehdr;


extern char __executable_start[];

// function returns executable segment start address and size
int initStartupElfSegsParams(Elf64_Ehdr *pELFHeader, uintptr_t *startAddr,
uintptr_t *size)
{
seL4_Word phoff = pELFHeader->e_phoff;
Elf_Phdr *currentPH = (Elf_Phdr *)((void *)pELFHeader + phoff);
for (int i=0; i<pELFHeader->e_phnum; i++)
{
ZF_LOGD("ELF:  p_type=%x p_flags=%x p_vaddr=%p p_memsz=%lu",
currentPH[i].p_type, currentPH[i].p_flags, (void *)currentPH[i].p_vaddr,
currentPH[i].p_memsz);
if ( ((currentPH[i].p_type & 1) == 1) && ((currentPH[i].p_flags & 1) == 1))
// p_flags & 1 == 1 - executable
{
*startAddr = (uintptr_t)currentPH[i].p_vaddr;
*size = (uintptr_t)currentPH[i].p_memsz / sizeof(uint64_t);
return 0;
}
}

return -1;
};

initStartupElfSegsParams((Elf64_Ehdr *)__executable_start,
&proc_validate_params[STARTUP_INDEX].p_addr,
&proc_validate_params[STARTUP_INDEX].p_size);

Any help will be appreciated.
Thanks
_______________________________________________
Devel mailing list -- devel@sel4.systems
To unsubscribe send an email to devel-leave@sel4.systems

Reply via email to