Thanks Ning! I really appreciate the fast response.

-----Original Message-----
From: Sun, Ning [mailto:ning....@intel.com] 
Sent: Wednesday, April 26, 2017 9:01 PM
To: Ahmed, Safayet (GE Global Research, US) <safayet.ah...@ge.com>; TBoot Dev 
List (tboot-devel@lists.sourceforge.net) <tboot-devel@lists.sourceforge.net>
Subject: EXT: RE: Additional checks moving initrd image

Thanks for the patch, it passed review and validation, now it got merged.

-ning

-----Original Message-----
From: Ahmed, Safayet (GE Global Research, US) [mailto:safayet.ah...@ge.com] 
Sent: Sunday, April 23, 2017 1:13 PM
To: TBoot Dev List (tboot-devel@lists.sourceforge.net) 
<tboot-devel@lists.sourceforge.net>
Subject: [tboot-devel] Additional checks moving initrd image


Before expanding the Linux image in "expand_linux_image" function, TBoot moves 
the inintrd image as high in memory as possible. If the kernel image is located 
high in memory, currently, TBoot writes over the kernel image.
The following patch adds additional checks to prevent the kernel image from 
being overwritten.

Signed-off-by: Safayet Ahmed <safayet.ah...@ge.com>

diff --git a/tboot/common/linux.c b/tboot/common/linux.c index 26d653a..dfc2c54 
100644
--- a/tboot/common/linux.c
+++ b/tboot/common/linux.c
@@ -204,6 +204,19 @@ bool expand_linux_image(const void *linux_image, size_t 
linux_size,
         initrd_base = initrd_base & PAGE_MASK;
     }
 
+    /* check for overlap with a kernel image placed high in memory */
+    if( (initrd_base < ((uint32_t)linux_image + linux_size))
+            && ((uint32_t)linux_image < (initrd_base+initrd_size)) ){
+        /* set the starting address just below the image */
+        initrd_base = (uint32_t)linux_image - initrd_size;
+        initrd_base = initrd_base & PAGE_MASK;
+        /* make sure we're still in usable RAM and above tboot end address*/
+        if( initrd_base < max_ram_base ){
+            printk(TBOOT_ERR"no available memory for initrd\n");
+            return false;
+        }
+    }
+

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech 
sites, Slashdot.org! http://sdm.link/slashdot 
_______________________________________________
tboot-devel mailing list
tboot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tboot-devel

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
tboot-devel mailing list
tboot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tboot-devel

Reply via email to