The attached patch should prevent a core dump when a new user naively
attempts to specify "vmlinux" as the guest kernel, like I did.

ChangeLog:
        * user/bin.c
        Added error handling to prevent guest code segments from exceeding the
virtualized physical memory.

-- 
Steven Elliott ([EMAIL PROTECTED])
Name: 200003262009
ChangeLog: Added error handling to prevent guest code segments from exceeding the 
virtualized physical memory.
GenDate: 2000/03/26 20:09:44 UTC
ModifiedFiles: user/bin.c
AddedFiles: 
===================================================================
RCS file: /cvsroot-freemware/freemware/user/bin.c,v
retrieving revision 1.3
diff -u -u -r1.3 bin.c
--- user/bin.c  2000/01/23 20:13:03     1.3
+++ user/bin.c  2000/03/26 20:10:00
@@ -128,7 +128,24 @@
         /* Load all sections that occupy space and have bits */
        for (i = 0; i < eh->e_shnum; i++)
            if ((sh[i].sh_flags & SHF_ALLOC) && (sh[i].sh_type != SHT_NOBITS))
-               memcpy (ptr + sh[i].sh_addr, image + sh[i].sh_offset, sh[i].sh_size);
+            {
+                if((sh[i].sh_addr + sh[i].sh_size) > 
+                   (vm_conf.max_memory * 1024 * 1024))
+                {
+                    fprintf (stderr, "The guest code specified (%s) "
+                             "includes a segment (sh index %d) with an "
+                             "address (0x%lx) and size (0x%lx bytes) that "
+                             "will not fit into the virtualized physical "
+                             "memory (0x%lx bytes).  Specify different guest "
+                             "code or increase the \"memory\" parameter in "
+                             "fmw.conf.\n", guest_file_name, i, sh[i].sh_addr,
+                             sh[i].sh_size, vm_conf.max_memory * 1024 * 1024);
+                    exit (1);
+                }
+                memcpy (ptr + sh[i].sh_addr, image + sh[i].sh_offset,
+                        sh[i].sh_size);
+            }
+               
 
         /* Retrieve entry point address and set up initial context */
         context.eip = eh->e_entry;

Reply via email to