<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>technomasochism</title>
	<atom:link href="http://twobit.us/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://twobit.us/blog</link>
	<description>and two-wheeled vehicles</description>
	<lastBuildDate>Sun, 05 May 2013 20:53:14 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
		<item>
		<title>Calculating PCR[17]</title>
		<link>http://twobit.us/blog/2013/05/calculating-pcr17/</link>
		<comments>http://twobit.us/blog/2013/05/calculating-pcr17/#comments</comments>
		<pubDate>Sun, 05 May 2013 19:36:53 +0000</pubDate>
		<dc:creator>Philip</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[measured]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://twobit.us/blog/?p=1585</guid>
		<description><![CDATA[When I left off my last discussin of tboot PCR calculations I gave a quick intro but little more. In this post I&#8217;ll go into details for calculating the first of them: PCR[17]. There have been a number of discussions with regard to calculating or verifying PCR values on the tboot-devel mailing list and they [...]]]></description>
				<content:encoded><![CDATA[<p>When I left off my last discussin of tboot PCR calculations I gave a quick intro but little more.  In this post I&#8217;ll go into details for calculating the first of them: PCR[17].</p>
<p>There have been a number of discussions with regard to calculating or verifying PCR values on the tboot-devel mailing list and they were extremely useful in writing this code and post.  These all fell a bit short of what I wanted to accomplish in that all approaches extracted hashes from the output of the <code>txt-stat</code> program (the tboot log) and used those hashes to re-construct the PCR values.  I wanted to construct all hashes manually, to measure and account for the actual <em>things</em> that TXT and tboot were measuring and storing into the PCRs and to do this independent of an actual measured launch.  Basically this translates to isolating the things being measured, extracting them (if possible) and use them to reconstruct the PCR value on any system, like a build server or an external verifying party.</p>
<p>The process is pretty straight forward, though time consuming, and the specification is phrased in such a way as to force some guess and check.  There&#8217;s even a bit of a trick in the end which requires that we go digging around in the tboot source code which is always fun.  I&#8217;ll also present a bit of code that will automate the calculation for you so if you&#8217;re anxious and don&#8217;t want to read any more you can go straight to the code which can be found here: https://github.com/flihp/pcr-calc.</p>
<p>DISCLAIMER: The code in the pcr-cal git repo is very much a work-in-progress and should be considered unstable at best so YMMV.</p>
<p>The spec that defines the DRTM specific PCRs is the &#8220;PC Client Implementation for BIOS&#8221;.  These are PCRs 17 through 20.  Their individual use however is hardware specific and on Intel hardware, the definitive source of data on what gets extended into which of these PCRs as part of establishing a DRTM is a document titled &#8220;Intel® Trusted Execution Technology (Intel® TXT) Software Development Guide: Measured Launched Environment Developer’s Guide&#8221;.</p>
<p>Quite a mouth full.  Anyways section 1.9.1 covers PCR[17] but the details of what various bits are measured are spread out over the document.  A default tboot configuration will cause 3 extends to this PCR so we&#8217;ll break this post up into 3 sections, each one describing the hashes that go into the 3 consecutive extend operations.</p>
<h2>First extend: SINIT ACM</h2>
<p>The first thing that&#8217;s extended into PCR[17] is the hash of the SINIT ACM.  This is a binary blob that Intel ships which is used by tboot to establish the DRTM on a platform.  The binary code in the ACM is chipset specific so there are a number of ACMs out there to chose from.  tboot automates the process so if you&#8217;re unsure which ACM is the right one for your platform you can configure your bootloader to load every ACM and tboot will pick the right one.  This will slow your boot process down considerably though and selecting the proper one isn&#8217;t hard with a bit of reading so don&#8217;t be lazy.</p>
<p>With the right ACM in hand you&#8217;d think it would be a simple matter of calculating the sha1 hash of the file and extending that into PCR[17].  That&#8217;s not the case though.  There are two little details that must be sorted first.</p>
<p>Depending on the version of the ACM you&#8217;re using the hash algorithm may be sha1 or it may be sha256.  ACMs version 7 or later will use sha256, while earlier versions will use sha1.  The current version of the ACM format is 8 so most modern hardware will need a sha256 hash (not to mention that most OEM implementations of TXT 3 years or older never worked in the first place &#8230; snap!).</p>
<p>Further, there are some fileds in the ACM that aren&#8217;t included in the hash.  The logic behind this escapes me but the apendix A.1.2 specifies that some fields are omitted.  Quoting the spec: &#8220;Those parts of the module header not included are: the RSA Signature, the public key, and the scratch field.&#8221;  That sounds like 3 fields from the ACM right?  Wrong: there&#8217;s a 4th field omitted as well and that&#8217;s the RSA exponent.  I guess they meant for the exponent to be included in the definition of &#8220;public key&#8221;?  Thanks for being explicit.</p>
<p>Anyways omit the fields: RSAPubKey, RSAPubExp, RSASig and the Scratch space, got it.  To omit these fields from the hash we&#8217;ve gotta parse the ACM.  I&#8217;ll cover this code at the end.</p>
<p>Finally the 32 bits that make up the EDX register which hold the flags passed to the GETSEC[SENTER] instruction are appended to the hash of the ACM.  We represent PCR[17] at the first extend operation thusly:</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">PCR[17]_1 = Extend(PCR[17]_0 | SHA256 (ACM | EDX))</pre></div></div>

<p>where PCR[17]_0 is the state of PCR[17] at time = 0.  PCRs are initialized to 20bytes of 0&#8242;s so PCR[17]_0 is 20 bytes of 0&#8242;s.</p>
<h2>Second Extend: Heap Data</h2>
<p>The second extend to PCR[17] includes various bits of data from the TXT heap.  Appendix C describes the TXT heap as a contiguous region of memory set asside by the BIOS for use by &#8216;system software&#8217; (aka BIOS) to pass data to the SINIT ACM and the MLE.  PCR[17] is extended with the sha1 hash of either 6 or 7 concatenated pieces of data depending on the version of the ACM.  The following fields are concatenated together and their sha1 hash is extended into PCR[17] for the second extend:</p>
<ol>
<li>BiosAcmId</li>
<li>MsegValid</li>
<li>StmHash</li>
<li>PolicyControl</li>
<li>LcpPolicyHash</li>
<li>OsSinitCaps or 4 bytes of 0&#8242;s as specified by the LCP (more on this next)</li>
</ol>
<p>If the SINIT to MLE data table version is 8 or greater an additional 4 bytes are appended representing the processor S-CRTM status.  These 4 bytes are in the ProcScrtmStatus field in the SINIT to MLE data table.</p>
<p>The second extend to PCR[17] could be represented as follows for SINIT to MLE data table versions < 8:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">PCR[17]_2 = sha1 (PCR[17]_1 | sha1 ( SinitMleData.BiosAcm.ID | SinitMleData.MsegValid |
                                     SinitMleData.StmHash | SinitMleData.PolicyControl |
                                     SinitMleData.LcpPolicyHash | (OsSinitData.Capabilities, 0)))</pre></div></div>

<p>For SINIT to MLE data table versions >= 8:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">PCR[17]_2 = sha1 (PCR[17]_1 | sha1 ( SinitMleData.BiosAcm.ID | SinitMleData.MsegValid | 
                                     SinitMleData.StmHash | SinitMleData.PolicyControl |
                                     SinitMleData.LcpPolicyHash | (OsSinitData.Capabilities, 0) |
                                     SinitMleData.ProcessorSCRTMStatus))</pre></div></div>

<p>where we use the notation (OSSinitData.Capabilities, 0) to represent a choce made between appending the value of OsSinitData.Capabilities or 4 bytes of 0&#8242;s depending on the state of the LCP policy control field.</p>
<p>The astute reader is likely wondering: &#8220;How do I get these values out of the TXT heap &#8230; and where do I even get the TXT heap from?&#8221;  Both are very good questions.  Getting at the TXT heap isn&#8217;t too difficult.  You&#8217;re on a Linux system presumably with root access.  The TXT heap is a region of memory like any other and you only need to know the offset where it resides and how to determine it&#8217;s size.  Both the offset  and the heap size are obtained from the TXT public registers which are mapped to well known memory addresses (read the spec if you&#8217;re really interested).</p>
<p>In the git repo linked above I&#8217;ve written a simple utility to parse and output the TXT Heap: <code>txt-heapdump</code>.  You can run this utility to display the contents of the heap on the system you wish to calcuclate PCR[17] in a human readable form:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">$ txt-heapdump --mmap --pretty</pre></div></div>

<p>You can also use it to obtain the heap as a binary file:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">$ txt-heapdump --mmap &gt; txtheap.bin</pre></div></div>

<p>You can then parse the binary file to display the heap in a human readable form and it&#8217;ll look just like it did coming straight from /dev/mem::</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">$ txt-heapdump --pretty -i txtheap.bin</pre></div></div>

<p>Once you have the heap as a file you can use the pcr-calc library to parse and extract various bits. Again, I&#8217;ll present the utility that does it all for you at the end. But first, the third and final extend &#8230;</p>
<h2>Third Extend: Launch Control Policy (LCP)</h2>
<p>You&#8217;d expect that all of the values that are hashed as part of PCR[17] are discussed in the spec under section &#8220;PCR 17&#8243; &#8230; and you&#8217;d be wrong.  A couple of sections deeper where the LCP is discussed, you&#8217;ll find a description of how the LCP policy is measured and it turns out that this measurement gets extended into PCR[17] as well!  There are a number of rules laid out in this section for how the system behaves when there&#8217;s no &#8216;Supplier&#8217; or &#8216;Owner&#8217; LCP present.  Specifically the spec states:</p>
<blockquote><p>
As a matter of integrity, the LCP_POLICY::PolicyControl field will always be extended into PCR 17. If an Owner policy exists, its PolicyControl field will be extended; otherwise the Supplier policy’s will be. If there are no policies, 32 bits of 0s will be extended.
</p></blockquote>
<p>I&#8217;ve not gone through this section with a very thorough eye so I&#8217;m not an authority here, but tboot seems to ignore these rules and instead loads a default policy when there isn&#8217;t one in the TPM NV RAM.  Not saying this is good or bad, right or wrong, just pointing out that this is what tboot does and it was something that I had to figure out in order to calculate the value of PCR[17] independently on my test systems.</p>
<p>So my goal here is to calculate PCR values.  If your system is like mine and both you (the &#8216;Owner&#8217;) and the &#8216;Supplier&#8217; (your OEM) didn&#8217;t provide an LCP, how do we measure the default policy from tboot?  The only thing I could come up with is to pull apart the tboot code and copy the hard-coded structures into a C program and then dump them to disk in binary.  The hash of this file is the one we need to extend into PCR[17] along with the LCP PolicyControl value.  I&#8217;ve added a class to the pcr-calc library to parse the necessary parts of the binary LCP to support this operation.</p>
<p>The program that dumps the binary LCP from tboot is: <code>lcp_def</code>  I&#8217;ve kept this utility in the pcr-calc project to reproduce the LCP on demand.  I considered only keeping around the LCP binary in a data file but in the event that the default tboot policy changes in the future I wanted to keep the program around to dump the binary structures.  When executed this program just dumps the binary policy so you&#8217;ll have to redirect the output:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">$ lcp_def &gt; lcp.bin</pre></div></div>

<h2>Final PCR[17] Calculation</h2>
<p>Now that we&#8217;ve figured out how to do all three independent extend operations and we&#8217;ve collected the heap and LCP blobs, we can calculate the final state of PCR[17].  I&#8217;ve automated this in the program: pcr17 (very creative name I know).  Assuming your heap is in txtheap.bin and your LCP is in lcp.bin your SINIT ACM file is named sinit.acm you should invoke the program as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">$ pcr17 -i txtheap.bin -l lcp.bin sinit.acm</pre></div></div>

<p>Your output should look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">$ ./bin/pcr17 -i ../txt-data/txtheap.bin -l ../txt-data/lcp_def.bin ../3rd_gen_i5_i7_SINIT_51.BIN 
first extend: SINIT ACM hash
  extending with: 0fcc099f81549da4836d492afb8ab2e303cecfa1
  PCR[17] before extend: 0000000000000000000000000000000000000000
  PCR[17] after extend: 8d3dd5c8e795dfac5dbfa9859310b2bcea36d347
second extend: TXT heap data
  append BiosAcmId:
    8000 0000 2010 1022 0000 b001 ffff ffff 
    ffff ffff 
  append MsegValid_Bytes:
    0000 0000 0000 0000 
  append StmHash:
    0000 0000 0000 0000 0000 0000 0000 0000 
    0000 0000 
  append PolicyControl_Bytes:
    0000 0000 
  append LcpPolicyHash:
    0000 0000 0000 0000 0000 0000 0000 0000 
    0000 0000 
  append Capabilities_Bytes: False
    Hashing 4 bytes of 0s in place of OsSinit.Capabilities
  append ProcScrtmStatus_Bytes:
    0000 0000 
  extending with: 7e0cdad3b8d9c344ab89657efdbfa638d1b25978
  PCR[17] before extend: 8d3dd5c8e795dfac5dbfa9859310b2bcea36d347
  PCR[17]: bfa4421b49f6ab899157ba6ee8fec3c5c5abf4ab
third extend: LCP
  lcp hash: ab41624e7d71f068d48e1c2f43e616bf40671c39
  polctrl: 1
  extending with: 9704353630674bfe21b86b64a7b0f99c297cf902
  PCR[17] before extend: bfa4421b49f6ab899157ba6ee8fec3c5c5abf4ab
  PCR[17] after extend: 57a5f1b245ac52614498a728efe7f741b4dc3ebf
&nbsp;
PCR[17] final: 57a5f1b245ac52614498a728efe7f741b4dc3ebf</pre></div></div>

<p>Currently the program will dump the hashes and PCR states after each extend along with the actual sha1 that should be in PCR[17] after a successful TXT measured launch.  Take a look at the code if you&#8217;re interested in the details.  This was as much an exercise for me in learning a bit of python as it was about the actual end result.  If given the choice again I&#8217;d have implemented this in C just because it&#8217;s much easier to deal with binary values and memory ranges in C than in Python.  Then again this may just be that I know C better than I know Python so YMMV.</p>
<h2>Conclusion</h2>
<p>As you&#8217;ve probably noticed I was only partially successful in my goal.  All of the data from the TXT heap that are extended in to PCR[17] are themselves hashes of things we can&#8217;t access.  Most of these hashes are all 0&#8242;s though denoting that the BIOS implementer opted out of implementing that feature (you&#8217;ll have an STM on your system one of these days but don&#8217;t hold your breath).  The only one that&#8217;s actually present is the <code>BiosAcmId</code> but I&#8217;d expect in the future for the other fields to be populated as well.</p>
<p>This is just another instance of binary blobs making their way into the TCB of our software systems.  We&#8217;ve had to deal with these in various forms over the years: binary drivers, firmware and BIOS code.  Intel and other chip manufacturers have been making their hardware extensible using firmware and microcode for a while now so it&#8217;s no surprise that these things have made their way into the TCB.  The good news is that they&#8217;re being measured and even if we can&#8217;t get our hands on the code, or even the binary blob on account of it being embedded in some piece of hardware, we can still identify them by their hash.  The implications for trust aren&#8217;t great but it&#8217;s a start.</p>
]]></content:encoded>
			<wfw:commentRss>http://twobit.us/blog/2013/05/calculating-pcr17/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using OE to build an XT &#8216;Service VM&#8217;</title>
		<link>http://twobit.us/blog/2013/03/using-oe-to-build-an-xt-service-vm/</link>
		<comments>http://twobit.us/blog/2013/03/using-oe-to-build-an-xt-service-vm/#comments</comments>
		<pubDate>Sun, 31 Mar 2013 16:15:09 +0000</pubDate>
		<dc:creator>Philip</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[OE]]></category>
		<category><![CDATA[XenClient]]></category>

		<guid isPermaLink="false">http://twobit.us/blog/?p=1576</guid>
		<description><![CDATA[Over the past few weeks I&#8217;ve run into a few misconceptions about XenClient XT and OpenEmbedded. First is that XT is some sort of magical system that mere mortals can&#8217;t customize. Second is that building a special-purpose, super small Linux image on OpenEmbedded is an insurmountable task. This post is an attempt to dispel both [...]]]></description>
				<content:encoded><![CDATA[<p>Over the past few weeks I&#8217;ve run into a few misconceptions about XenClient XT and OpenEmbedded.  First is that XT is some sort of magical system that mere mortals can&#8217;t customize.  Second is that building a special-purpose, super small Linux image on OpenEmbedded is an insurmountable task.  This post is an attempt to dispel both of these misconceptions and maybe even motivate some fun work in the process.</p>
<p>Don&#8217;t get me wrong though, this isn&#8217;t a trival task and I didn&#8217;t start and end this work in one night.  There&#8217;s still a bunch of work to do here.  I&#8217;ll lay that out at the end though.  For now, I&#8217;ve put up the build scripts I threw together last night on git hub.  They&#8217;re super minimal and derived from another project.  Get them here: https://github.com/flihp/transbridge-build-scripts</p>
<p>My goal here is to build a simple rootfs that XT can boot with a VM &#8216;type&#8217; of &#8216;servicevm&#8217;.  This is the type that the XT toolstack associates with the default &#8216;Network&#8217; VM.  Basically it will be a VM invisible to the user.  Eventually I&#8217;d like for this example to be useful as a transparent network bridge suitable as an in-line filter or even as a &#8216;driver domain&#8217;.  But let&#8217;s not get ahead of ourselves &#8230;</p>
<h2>What image do I build?</h2>
<p>The first thing that you need to chose to do when building an image with OE is what <code>MACHINE</code> you&#8217;re building for.  XT uses Xen for virtualization so whatever platform you&#8217;re running it on will dictate the <code>MACHINE</code>.  Since XT only runs on Intel hardware it&#8217;s pretty safe to assume you&#8217;re system is compatible with generic i586.  The basic qemux86 <code>MACHINE</code> that&#8217;s in the <code>oe-core</code> layer builds for this so for these purposes it&#8217;ll suffice.  This is already set up in the <code>local.conf</code> in my build scripts.</p>
<p>To build the minimal core image that&#8217;s in the <code>oe-core</code> layer just run my <code>build.sh</code> script from the root of the repository.  I like to <code>tee</code> the output to a log file for inspection in the event of a failure:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">./build.sh | tee build.log</pre></div></div>

<p>Now you should have a bunch of new stuff in <code>./tmp-eglibc/deploy/images/</code> which includes an ext3 rootfs.  The file name should be something like <code>core-image-minimal.ext3</code>.  Copy this over to your XT dom0 and get ready to build a VM.</p>
<h2>Make a VHD</h2>
<p>The next thing to do is copy the ext3 image over to a VHD.  From within <code>/storage/disks</code> create a new VHD large enough to hold the image.  I&#8217;ve experimented with both <code>core-image-basic</code> and <code>core-image-minimal</code> and a 100M VHD will be large enough &#8230; yes that&#8217;s a very small rootfs.  <code>core-image-minimal</code> is around 9M:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">cd /storage/disks
vhd-util create -n transbridge.vhd -s 100</pre></div></div>

<p>Next have <code>tap-ctl</code> create a new device node for the VHD:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">tap-ctl create -a vhd:/storage/disks/transbridge.vhd</pre></div></div>

<p>This will output the path to the device node created (and yeah the weird command syntax bugs me too).  You can alternatively list the current blktap devices and find yours there:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">tap-ctl list
1276    0    0        vhd /storage/ndvm/ndvm.vhd
1281    1    0        vhd /storage/ndvm/ndvm-swap.vhd
...</pre></div></div>

<p>I&#8217;ve got no idea what the first number is (maybe PID of the blktap instance that&#8217;s backing the device?) but the 2nd and 3rd numbers are the major / minor for the device.  The last column is the VHD file backing the device so find your VHD there and the major number then find the device in <code>/dev/xen/blktap-2/tapdevX</code> &#8230; mine had a major number of &#8217;8&#8242; so that&#8217;s what I&#8217;ll use in this example.  Then just byte copy your ext3 on to this device:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">dd if=/storage/disks/transbridge.ext3 of=/dev/xen/blktap-2/tapdev8</pre></div></div>

<p>Then you can mount your VHD in dom0 to poke around:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">mount /dev/xen/blktap-2/tapdev8 /media/hdd</pre></div></div>

<h2>Where&#8217;s my kernel?</h2>
<p>Yeah so OE doesn&#8217;t put a kernel on the rootfs for <code>qemu</code> machines.  That&#8217;s part of why the <code>core-image-minimal</code> image is so damn small.  QEMU doesn&#8217;t actually boot like regular hardware so you actually pass it the kernel on the command line so OE&#8217;s doing the right thing here.  If you want the kernel from the OE build it&#8217;ll be in <code>./tmp-eglibc/deploy/images/</code> with the images &#8230; but it won&#8217;t boot on XT <img src='http://twobit.us/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>This is a kernel configuration thing.  I could have spent a few days creating a new meta layer and customizing the Yocto kernel to get a &#8216;Xen-ified&#8217; image but taht sounds like a lot of work.  I&#8217;m happy for this to be quick and dirty for the time being so I just stole the kernel image from the XT &#8216;Network&#8217; VM to see if I could get my VM booting.</p>
<p>You can do this too by first mounting the Network VMs rootfs.  Cool thing is you don&#8217;t need to power down the Network VM to mount it&#8217;s FS in dom0!  The disk is exposed to the Network VM as a read-only device so you can mount it read only in dom0:</p>
<pre lan='sh'>
mount /dev/xen/blktap-2/tapdev0 /media/cf
</pre>
<p>Then just copy the kernel and modules over to your new rootfs and set up some symlinks to the kernel image so it&#8217;s easy to find:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">cp /media/cf/boot/vmlinuz-2.6.32.12-0.7.1 /media/hdd/boot
cp -R /media/cf/lib/modules/2.6.32.12-0.7.1 /media/hdd/lib/modules
cd /media/hdd/boot
ln -s vmlinuz-2.6.32.12-0.7.1 vmlinuz
cd /media/hdd
ln -s ./boot/vmlinuz-2.6.32.12-0.7.1 vmlinuz</pre></div></div>

<p>You may find that there isn&#8217;t enough space on the ext3 image you copied on to the VHD.  Remember that the ext3 image is only as large as the disk image created by OE.  It&#8217;s size won&#8217;t be the same as the VHD you created unless you resize it to fill the full VHD.  You can do so by first umount&#8217;ing the tapdev then running <code>resize2fs</code> on the tapdev:</p>
<pre lan='sh'>
umount /media/hdd
resize2fs /dev/xen/blktap-2/tapdev8
</pre>
<p>This will make the file system on the VHD expand to fill the full virtual disk.  If you made your VHD large enough you&#8217;ll have enough space for the kernel and modules.  Like I say above, 100M is a safe number but you can go smaller.</p>
<p>Finally you&#8217;ll want to be able to log into your VM.  If you picked the minimal image it won&#8217;t have ssh or anything so you&#8217;ll need a <code>getty</code> listening on the xen console device.  Add the following line to your <code>inittab</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">echo -e &quot;\nX:2345:respawn:/sbin/getty 115200 xvc0&quot; &gt;&gt; /media/hdd/etc/inittab</pre></div></div>

<p>There&#8217;s also gonna be a default <code>getty</code> trying to attach to <code>ttyS0</code> which isn&#8217;t present.  When the VM is up it will cause some messages on the console:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">respawning too fast: disabled for 5 minutes</pre></div></div>

<p>You can disable this by removing the &#8216;S&#8217; entry in <code>inittab</code> but really the proper solution is a new image with a proper <code>inittab</code> for an XT service VM &#8230; I&#8217;ll get there eventually.</p>
<h2>Make it a VM</h2>
<p>Up till now all we&#8217;ve got is a VHD file.  Without a VM to run it nothing interesting is gonna happen though so now we make one.  The XT toolstack isn&#8217;t documented to the point where someone can just read the man page.  But it will tell you a lot about itself if you just run it with out any parameters.  Honestly I know very little about our toolstack so I&#8217;m always executing <code>xec</code> and grepping though the output.</p>
<p>After some experimentation here are the commands to create a new Linux VM from the provided template and modify it to be a para-virtualized service VM.  In retrospect it may be better to use the &#8216;ndvm&#8217; template but this is how I did it for better or for worse:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">xec create-vm-with-template new-vm-linux</pre></div></div>

<p>This command will output a path to the VM node in the XT configuration database.  The name of the VM will also be something crazy.  Ge the name from the output of <code>xec-vm</code> and change it to something sensible like &#8216;minimal&#8217;:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">xec-vm --name &lt;name-some-wacky-uuid&gt; set name minimal</pre></div></div>

<p>Your VM will also get a virutal CD-ROM which we don&#8217;t want so delete it and then add a disk for VHD we configured:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">xec-vm --name minimal --disk 0 delete
xec-vm --name minimal add-disk
xec-vm --name minimal --disk 0 set phys-path /storage/disks/minimal.vhd</pre></div></div>

<p>Then set all of the VM properties per the instructions provided in the XT Developer Guide:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">xec-vm --name minimal --disk 0 set virt-path xvda
xec-vm --name minimal set flask-label &quot;system_u:system_r:nilfvm_t&quot;
xec-vm --name minimal set stubdom false
xec-vm --name minimal set hvm false
xec-vm --name minimal set qemu-dm-path &quot;&quot;
xec-vm --name minimal set slot -1
xec-vm --name minimal set type servicevm
xec-vm --name minimal set kernel /tmp/minimal-vmlinuz
xec-vm --name minimal set kernel-extract /vmlinuz
xec-vm --name minimal set cmd-line &quot;root=/dev/xvda xencons=xvc0 console=xvc0 rw&quot;</pre></div></div>

<p>Then all that&#8217;s left is booting your new minimal VM:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">xec-vm --name minimal start</pre></div></div>

<p>You can then connect to the dom0 end of the Xen serial device to log into your VM:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">screen $(xenstore-read /local/domain/$(xec-vm --name minimal get domid)/console/tty))</pre></div></div>

<h2>Next steps</h2>
<p>This is a pretty rough set of instructions but it will produce a bootable VM on XenClient XT from a very small OpenEmbedded core-image-minimal.  There&#8217;s tons of places this can be cleaned up starting with an kernel that&#8217;s specific to a Xen domU.  A real OE DISTRO would be another welcome addition so various distro specific features could be added and removed more easily.  If the lazywebs feel like contributing some OE skills to this effort leave me a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://twobit.us/blog/2013/03/using-oe-to-build-an-xt-service-vm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What&#8217;s in a hash?</title>
		<link>http://twobit.us/blog/2013/03/whats-in-a-hash/</link>
		<comments>http://twobit.us/blog/2013/03/whats-in-a-hash/#comments</comments>
		<pubDate>Sat, 30 Mar 2013 19:26:16 +0000</pubDate>
		<dc:creator>Philip</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[measured]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://twobit.us/blog/?p=1567</guid>
		<description><![CDATA[After the initial work on meta-measured it was very clear that configuring an MLE is great but alone it has little value. Sure tboot will measure things for you, it will even store these measurements in your TPM&#8217;s PCRs! But the &#8220;so what?&#8221; remains unanswered: there are hashes in your TPM, who cares? Even after [...]]]></description>
				<content:encoded><![CDATA[<p>After the initial work on meta-measured it was very clear that configuring an MLE is great but alone it has little value.  Sure tboot will measure things for you, it will even store these measurements in your TPM&#8217;s PCRs!  But the &#8220;so what?&#8221; remains unanswered: there are hashes in your TPM, who cares?</p>
<p>Even after you&#8217;ve set-up <code>meta-measured</code>, launch an MLE and dumped out the contents of <code>/sys/class/misc/tpm0/device/pcrs</code> what have you accomplished?  The whole point of <code>meta-measured</code> was to setup the machinery to make this easier and for the PCR values to remain unchanged across a reboot.  I was surprised at how much work went into just this.  But after this work, the hashes in these PCRs still had no meaning beyond being mysterious, albeit static, hashes.</p>
<p>I closed the <code>meta-measured</code> post stating my next goal was to take a stab at pre-computing some PCR values.  Knowing the values that PCRs will have in your final running system allows for secrets to be protected by sealed storage at install time (which I&#8217;ve heard called &#8216;local attestation&#8217; just to confuse things).  Naturally the more system state involved in the sealing operation (assume this means &#8216;more PCRs&#8217; for now) the better.  So I had hoped to come back after a bit with the tools necessary for meta-measured to produce a manifest of as many of the tboot PCR values as possible.</p>
<h2>Starting with PCR[17]</h2>
<p>Naturally I started with what I knew would be the hardest PCR to calculate: the infamous PCR[17].  JPs comment on my last post pointed out some of his heroic efforts to compute PCR[17] so that was a huge help.  So first things first: respect to JP for the pointer.  This task would have taken me twice as long were it not for his work and the work of others on tboot-devel.</p>
<p>So I set out to calculate PCR[17] but I think my approach was different from those I was able to find in the public domain.  The criteria I came up with for my work was:</p>
<ol>
<li>Calculate PCR[17] for system A on system B.</li>
<li>Do the measurements myself.</li>
</ol>
<p>So &#8216;rule #1&#8242; basically says: no reliance on having a console on the running system.  This is one part technical purity, one part good design as the intent is to make these tools as flexible as possible and useful in a build system. &#8216;Rule #2&#8242; is all technical purity.  This isn&#8217;t an exercise in recreating the algorithm that produces the value that ends up in PCR[17].</p>
<p>This last bit is important.  The whole point is to account for the actual things (software, configuration etc) that are measured as part of bringing up a TXT MLE.  Once these are identified they need to be collected (maybe even extracted from the system) if possible, and then used to calculate the final hash stored in PCR[17].  So basically, no parsing and hashing the output from &#8216;txt-stat&#8217;, that&#8217;s cheating <img src='http://twobit.us/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   I explained this approach to a friend and was instantly accused of masochism.  That&#8217;s a good sign and I guess there&#8217;s an element of that in the approach as well, if not everything I do.</p>
<p>As always, wrapping up one exploratory exercise in learning / brushing up on a language is always a good idea right?  So I did as much of my work as possible on this in Python.  Naturally I had to break this rule and use some C at the end but that&#8217;s a bit of a punchline so I don&#8217;t want to spoil that joke.</p>
<p>So if you&#8217;re only interested in the code I won&#8217;t bore you with any more talk about &#8216;goals&#8217; and &#8216;design&#8217;.  It&#8217;s all up on github.  The python&#8217;s here: <a href="https://github.com/flihp/pcr-calc">https://github.com/flihp/pcr-calc</a>.  The C is here: <a href="https://github.com/flihp/pcr-calc_c">https://github.com/flihp/pcr-calc_c</a>.  There isn&#8217;t much in the way of documentation but I&#8217;ll get into that soon.</p>
<p>If you are interested in the words that accompany this work stay tuned.  My next post will give a bit of a tour of the rabbit hole that is  calculating PCR[17].  This will include discussion of each &#8216;thing&#8217; that&#8217;s measured and what it all means.  Like I said though: the end result is that precalculating PCR[17] for arbitrary platforms is a massive PITA and likely not very useful for my original purposes.  After thinking on it a bit however I&#8217;m quite certain this info may be useful elsewhere but I&#8217;ll save that for discussion on follow-on work.</p>
]]></content:encoded>
			<wfw:commentRss>http://twobit.us/blog/2013/03/whats-in-a-hash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Measured Launch on OE core</title>
		<link>http://twobit.us/blog/2013/01/meta-measured/</link>
		<comments>http://twobit.us/blog/2013/01/meta-measured/#comments</comments>
		<pubDate>Tue, 08 Jan 2013 03:31:50 +0000</pubDate>
		<dc:creator>Philip</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[measured]]></category>
		<category><![CDATA[OE]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[Yocto]]></category>

		<guid isPermaLink="false">http://twobit.us/blog/?p=1547</guid>
		<description><![CDATA[It&#8217;s been 4 months since my last post but I&#8217;ve been working on some fun stuff. Said work has progressed to the point where it&#8217;s actually worth talking about publically so I&#8217;m crawling out from under my favorite rock and putting it &#8220;out there&#8221;. My last few bits of writing were about some random OpenEmbedded [...]]]></description>
				<content:encoded><![CDATA[<p>It&#8217;s been 4 months since my last post but I&#8217;ve been working on some fun stuff.  Said work has progressed to the point where it&#8217;s actually worth talking about publically so I&#8217;m crawling out from under my favorite rock and putting it &#8220;out there&#8221;.</p>
<p>My last few bits of writing were about some random OpenEmbedded stuff, basically outlining things I was learning while bumbling my way through the OE basics.  I&#8217;ve been reading through the meta-selinux and meta-virtualization layers and they&#8217;re a great place to learn.  Over the winter Holiday here I had some extra vacation time from my day job to burn so I finally got serious about a project I&#8217;ve been meaning to start for way too long.</p>
<h2>meta-measured</h2>
<p>Over the past year I&#8217;ve been thinking a lot about the &#8220;right way&#8221; to measure a software system.  We&#8217;ve implemented a measurement architecture on XT but this has a few down sides:  First a system as large as XT is very difficult to use as a teaching tool.  It&#8217;s hard to explain and show someone the benefits of measuring a system when your example is large, complex and the relevant bits are spread throughout the whole system.  Even our engineers who know our build system inside and out often get lost in the details.  Second the code belongs to Citrix and closed source software isn&#8217;t very useful to anyone except the people selling it.</p>
<p>So after reading through the meta-selinux and meta-xen layers a bunch and learning a good bit about writing recipes I&#8217;ve started work on a reference image for a &#8220;measured system&#8221;.  I&#8217;m keeping the recipes  that make up this work in a layer I call &#8216;meta-measured&#8217;.  For this first post on the topic of measured systems I&#8217;ll stick to discussing the basic mechanics of it&#8217;s construction.  This includes some data on the supporting recipes and some of the component parts necessary for booting it.  Hopefully along the way I&#8217;ll be able to justify the work by discussing the potential benefits to system security but the theory and architecture discussions will be left for a later post.</p>
<h2>get the source</h2>
<p>If you&#8217;re interested in just building it and playing with the live image this is where you should start.  Take a look and let me know what you think.  Feedback would be much appreciated.</p>
<p>All of the work I&#8217;ve done to get this first bootable image working is up on my github.  You can get there, from here: <a href="https://github.com/flihp">https://github.com/flihp</a>.  The &#8216;meta-measured&#8217; layer is here: <a href="https://github.com/flihp/meta-measured.git">https://github.com/flihp/meta-measured.git</a>.  To automate setting up a build environment for this I&#8217;ve got another repo with a few scripts to checkout the necessary supporting software (bitbake / OE / meta-intel etc), a local.conf (which you may need to modify for your environment), and a script to build the &#8216;iso&#8217; that can be written to a USB drive for booting a test system: <a href="https://github.com/flihp/measured-build-scripts">https://github.com/flihp/measured-build-scripts</a>.</p>
<p>The best way to build this currently is to checkout the measured-build-scripts repo:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> clone <span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>flihp<span style="color: #000000; font-weight: bold;">/</span>measured-build-scripts.git</pre></div></div>

<p>run the &#8216;fetch.sh&#8217; script to populate the required git submodules and to clone the meta-measured layer:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> measured-build-scripts
.<span style="color: #000000; font-weight: bold;">/</span>fetch.sh</pre></div></div>

<h2>build the iso</h2>
<p>If you try to run the ./build.sh script next as you would think you should, the build will fail currently.  It will do so while attempting to download the SINIT / ACM module for TXT / tboot because Intel hides the ACMs behind a legal terms wall with terms that must be accepted before the files can be downloaded.  I&#8217;ve put the direct link to it in the recipe but the download fails unless you&#8217;ve got the right cookie in your browser so wget blows up.  Download it yourself from here: <a href="http://software.intel.com/en-us/articles/intel-trusted-execution-technology">http://software.intel.com/en-us/articles/intel-trusted-execution-technology</a>, then drop the zip into your &#8216;download&#8217; directory manually. I&#8217;ve got the local.conf with DL_DIR hardwired to /mnt/openembedded/downloads so you&#8217;ll likely want to change this to suit your environment.</p>
<p>Anyway I&#8217;ll sort out a way to fool the Intel lawyer wall eventually &#8230; I&#8217;m tempted to mirror these files since the legal notice seems to allow this but I don&#8217;t really have the bandwidth ATM. Once you&#8217;ve got this sorted, run the build.sh script. I typically tee the output to a file for debugging &#8230; this is some very &#8216;pre-alpha&#8217; stuff so you should expect to debug the build a bit <img src='http://twobit.us/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>build.sh <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tee</span> build.log</pre></div></div>

<p>This will build a few images from the measured-image-bootimg recipe (tarballs, cpios, and an iso). The local.conf I&#8217;ve got in my build directory is specific to my test hardware so if you&#8217;ve got an Intel SugarBay system to test on then you can dump the ISO directly to a USB stick and boot it.  If you don&#8217;t have a SugarBay system then you&#8217;ll have to do some work to get it booting since this measured boot stuff is closely tied to the hardware, though the ACMs I&#8217;ve packaged work for 2nd and 3rd gen i5 and i7 hardware (Sandy and Ivy Bridge).</p>
<h2>recipes</h2>
<p>I&#8217;ve organized the recipes that make up this work into two categories:  Those that are specific to the TPM and those that are specific to TXT / tboot.  Each of these two technologies requires some kernel configs so those are separated out into fragments like I&#8217;ve found in other layers.  My test hardware has USB 3.0 ports which the base OE layers don&#8217;t seem to have yet.  I&#8217;ve included this config in my oe-measured distro just so I can use the ports on the front of my test system.</p>
<p>The TPM recipes automate building the Trousers daemon, libtspi and some user space tools that consume the TSS interface. Recipes for the TPM software are pretty straight forward as most are autotools projects.  Some work was required to get the trousers project separated into packages for the daemon and library.</p>
<p>The tboot recipes were a bit more work because tboot packages a bunch of utilites in the main tboot source tree so they had to be separated out into different packages (this work is still on-going). Further tboot doesn&#8217;t use autotools and they squash most compiler flags that the OE environment passes in. The compler flags required by tboot are static which stands at odds with OE and a cross-compiled environment that wants to change the path to everything including the compiler.</p>
<p>I&#8217;ve no clue if tboot will build properly on anything other than an Intel system.  Further the issue of Intel hiding the ACMs required for their chipssets behind an EULA wall is annoying as the default OE fetcher won&#8217;t work.</p>
<h2>images</h2>
<p>My first instinct is always to to describe a system by construction: from the bottom up.  In this case I think going top-down is a better approach so we&#8217;ll start with the rootfs and work backwards.  The TPM recipes includes two images based on the core-image from OE core.  That&#8217;s one initramfs image and one rootfs.  The rootfs is just the core-image with the TPM kernel drivers, trousers daemon, tpm-tools and the tpm-quote-tools.  I haven&#8217;t done much with this rootfs other than booting it up and see if TXT and the TPM works as expected.</p>
<p>There&#8217;s also an initramfs with the TPM kernel drivers, trousers daemon and the tpm-tools but not the quote tools.  This is a very minimal initramfs with the TSS daemon loaded manually in the initrd script.  It&#8217;s not expected that users will be using the tpm-tools interactively here but that&#8217;s what I&#8217;ve been doing for initial testing.  Only the <code>tpm_extendpcr</code> tool (open source from Citrix) is used to extend a PCR with the sha1sum hash of the rootfs before the call to switch_root.  This requires that the &#8216;coreutils&#8217; package be included just for the one utility which bloats the initramfs unfortunately.  Slimming this down should&#8217;t be too much work in the future.  Anyway I think this is &#8216;the right way&#8217; to extend the measurement chain from the initramfs up to the rootfs of the system.</p>
<p>The rest of the measruements we care about are taken care of by the components from the TXT recipes.  There&#8217;s only one image in the TXT recipe group however.  This is derived from the OE core live image and it&#8217;s intended to be &#8216;deployable&#8217; in the lanugage of OE recipes.  I think this means an hddimg or an ISO image, basically something you can &#8216;dd&#8217; to disk and boot.  Currently it&#8217;s the basis for a live image but could easily be used for something like an installer simply by switching out the rootfs.</p>
<p>This image is not a separate root filesystem but instead it&#8217;s an image created with the files necessary to boot the system: syslinux (configured with the mboot.c32 comboot module), tboot, acms and the initrd and the rootfs from the TPM recipes.  tboot measures the bootloader config, all of the boot modules and a bunch of other stuff (see the README in the tboot sources for details).  It stores these measurements in the TPM for us, creating the &#8216;dynamic root of trust for measurement&#8217; (DRTM).</p>
<p>Once tboot has measured all of the modules, the initramfs takes over.  The initramfs then measures the rootfs as described above before the switch to root.  I&#8217;ve added a few kernel parameters to pass the name of the rootfs and the PCR where it&#8217;s measurement is to be stored.</p>
<p>If the rootfs is measured on each boot it must be mounted read-only to prevent its measurement from changing &#8230; yup even mounting a journaled file system read-write will modify the journal and change the filesystem.  Creating a read-only image is a bit of work so for this first prototype I&#8217;ve used a bit of a short cut:  I&#8217;ve mounted the rootfs read only, create a ramfs read write, then the two are combined in a unionfs.  In this configuration when rootfs boots it looks like a read / write mount.  Thus on each boot the measurements in the TPM are the same.</p>
<h2>Next Steps</h2>
<p>Measuring a system is all well and good but who cares?  Measurements are only useful when they&#8217;re communicated to external parties.  For now this image only takes measurements and these measurements are the same on each boot.  That&#8217;s it.  Where this can be most immediately useful is that these measurements can be predicted in the build.</p>
<p>The PCRs 0-7 are reserved for the BIOs and we have no way of predicting these values currently as they&#8217;re unique to the platform and that&#8217;s messy.  The tboot PCRs however (17, 18 and 19 in the Legacy mapping currently used) can be calculated based on the hashing done by tboot (read their docs and http://www.mail-archive.com/tboot-devel@lists.sourceforge.net/msg00069.html).  The PCR value containing the measurement of the rootfs can be calculated quite simply as well.</p>
<p>For a reference live image this is interesting only in an academic capacity.  As I suggest above, this image can be used as a template for something like an installer which would give the predictability of PCR values much deeper meaning:  Consider an installer architecture where the installer itself is a very small rootfs that downloads the install package from a remote server (basically Debian&#8217;s netboot iso or a PXE boot setup).  Assuming we have a method for exchanging system measurements (more future work) it would be very useful for the remote server to be able to evaluate measurements from the installer before releasing the install package.</p>
<p>This is probably a good place to wrap up this post.  The meta-measured layer I&#8217;ve described is still very new and the images I&#8217;ve built are still usefuly only for &#8216;tire-kicking&#8217;.  My next post will hopefully discuss predicting measurement values in the build system and other fun stuffs.</p>
]]></content:encoded>
			<wfw:commentRss>http://twobit.us/blog/2013/01/meta-measured/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Openembedded Yocto Native Hello World: Take 2</title>
		<link>http://twobit.us/blog/2012/08/openembedded-yocto-native-hello-world-take-2/</link>
		<comments>http://twobit.us/blog/2012/08/openembedded-yocto-native-hello-world-take-2/#comments</comments>
		<pubDate>Sun, 19 Aug 2012 18:28:41 +0000</pubDate>
		<dc:creator>Philip</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[OE]]></category>
		<category><![CDATA[OE Yocto]]></category>

		<guid isPermaLink="false">http://twobit.us/blog/?p=1534</guid>
		<description><![CDATA[A while back I wrote about some problems I was having with native OpenEmbedded recipes that were building packages with raw Makefiles (no autotools). I wrote up the problem and the work around I was using here. I got some feedback pointing out what I was doing wrong but I guess my brain just didn&#8217;t [...]]]></description>
				<content:encoded><![CDATA[<p>A while back I wrote about some problems I was having with native OpenEmbedded recipes that were building packages with raw Makefiles (no autotools).  I wrote up the problem and the work around I was using <a href="http://twobit.us/blog/2012/04/openembedded-yocto-native-hello-world/">here</a>.  I got some feedback pointing out what I was doing wrong but I guess my brain just didn&#8217;t process it.  I was using uppercase variables while the <a href="http://www.gnu.org/prep/standards/html_node/Directory-Variables.html#Directory-Variables">GNU Make docs</a> specifically call for lowercase!  These variables get magically passed to Make likely through the environment and then everything just works. </p>
<p>So here&#8217;s my retraction: I was wrong <img src='http://twobit.us/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   The &#8216;hello world&#8217; Makefile should look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">.PHONY : clean uninstall
&nbsp;
prefix ?= /usr
exec_prefix ?= $(prefix)
bindir ?= $(exec_prefix)/bin
&nbsp;
HELLO_src = hello.c
HELLO_bin = hello
HELLO_tgt = $(DESTDIR)$(bindir)/$(HELLO_bin)
&nbsp;
all : $(HELLO_bin)
&nbsp;
$(HELLO_bin) : $(HELLO_src)
&nbsp;
$(HELLO_tgt) : $(HELLO_bin)
	install -d $(DESTDIR)$(bindir)
	install -m 0755 $^ $@
&nbsp;
clean :
	rm $(HELLO_bin)
&nbsp;
install : $(HELLO_tgt)
&nbsp;
uninstall :
	rm $(HELLO_TGT)</pre></div></div>

<p>You can download the recipe here: <a href='/files/2012/08/hello_1.1.bb.gz'>hello_1.1.bb</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://twobit.us/blog/2012/08/openembedded-yocto-native-hello-world-take-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>TXT Capable Desktop Virtualization System</title>
		<link>http://twobit.us/blog/2012/08/txt-capable-desktop-virtualization-system/</link>
		<comments>http://twobit.us/blog/2012/08/txt-capable-desktop-virtualization-system/#comments</comments>
		<pubDate>Thu, 09 Aug 2012 21:56:39 +0000</pubDate>
		<dc:creator>Philip</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Hobby]]></category>
		<category><![CDATA[SysAdmin]]></category>

		<guid isPermaLink="false">http://twobit.us/blog/?p=1507</guid>
		<description><![CDATA[Having worked on XenClient XT for the past year I&#8217;ve experienced the pain of debugging vendors TXT implementations first hand. TXT may be a nearly 6 year old technology but it&#8217;s just now coming into use and many vendors platforms have only received internal testing. We&#8217;ve found a number of ways for platforms to fail [...]]]></description>
				<content:encoded><![CDATA[<p>Having worked on <a href="http://www.citrix.com/English/ps2/products/subfeature.asp?contentID=2315434">XenClient XT</a> for the past year I&#8217;ve experienced the pain of debugging vendors TXT implementations first hand.  TXT may be a nearly 6 year old technology but it&#8217;s just now coming into use and many vendors platforms have only received internal testing.  We&#8217;ve found a number of ways for platforms to fail in strange ways and we&#8217;ve had to work with the vendors to get their implementations working for a system like XT that uses tboot as part of our measured launch.</p>
<p>For development Citrix has provided me with a number of systems but I&#8217;ve been meaning to put one together for myself for some time now.  I&#8217;ve always liked building my own so I wasn&#8217;t thrilled with the prospect of purchasing a Dell / HP system.  Home builds are always a bit cooler, a bit cheaper, and more fun in general.  That said I was a bit worried about being able to find a motherboard / CPU combo with full AND WORKING VT-x, VT-d and TXT.  It wasn&#8217;t as bad as I expected.  So the following is a breakdown of the home build system I put together specifically to run XT.</p>
<h2>Case</h2>
<p>I always start building systems with the case.  This will dictate size which in turn limits your choices for motherboards.  I&#8217;ve had a string of successes building systems in <a href="http://www.lian-li.com/v2/en/contact_us/index1.php">Lian Li</a> cases so again they were my first choice.  I wanted this system to be as small as possible.  Lian Li happens to make probably the best mini-ITX case on the market: the <a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16811112369">PC-Q02A</a>.  This case is tiny and it comes bundled with a 300W power supply.  No room in the back of the case for PCI cards either so if you buy this don&#8217;t expect to throw a graphics card in it.  Whatever you need has to be on the motherboard!</p>
<h2>CPU</h2>
<p>Since I intend to run XT on this system the CPU has to support the full Intel vPro suite including TXT.  This limited me to high-end intel i5 and i7 processors.  Since this system will be in a small, low power case I wanted a 65W CPU and went with the <a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16819115228">Intel i7-2600S</a>.  CPUs aren&#8217;t really where you want to save money on your build so I didn&#8217;t skimp here.</p>
<h2>Motherboard</h2>
<p>The motherboard is really where vPro and TXT are either made or broken.  The BIOS is where CPU features are either enabled or disabled and many motherboard vendors don&#8217;t list anything in their docs about TXT compatibility.  This is mostly because home users typically don&#8217;t really care.  In this case we do so some research is required.  I played it safe and went with an <a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16813121513">Intel DQ67EP</a>.  TXT and the TPM worked flawlessly.  One thing that was a deviation from the platforms from Dell and HP I&#8217;ve played with was the TPM came without an EK populated.  It&#8217;s a simple case of running <code>tpm_createek</code> on the system but because all of the vendor platforms come with an EK pre-populated the XT code doesn&#8217;t account for this situation.  Easy to work around.</p>
<h2>RAM</h2>
<p>From here it&#8217;s just a matter of getting RAM and hard drive / CD-ROM.  Since this system will be running virutalized desktops the more RAM the better. XT doesn&#8217;t over commit RAM so if you want to run two desktops with 4G of RAM each you&#8217;ll need a bit more than 8G of RAM since the dom0 and service VMs will need a bit too.  I picked up 16G of <a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16820231556">G.SKILL Ares</a> RAM.  Generally I run 3 desktops: one Debian Squeeze for development, one Debian Wheezy for my personal stuffs and one Windows 7 for required email and GoToMeetings each with 4G of ram.  This system has no problems handling all 3 at the same time.</p>
<h2>Disks</h2>
<p>Hard disk is always faster and bigger is better.  This is where I saved money though since I&#8217;ve already got a huge (6T!) NFS server for bulk storage.  I went with a modest <a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16820227726">120G OCZ Agility 3</a>.  I haven&#8217;t done any benchmarking but it&#8217;s big enough for my root filesystems and fast enough as well.  I also put in a <a href="http://www.amazon.com/Sony-Optiarc-BC-5650H-01-Blu-Ray-Optical/dp/B00604YVGO">Sony Optiarc BC-5650H-01</a> 6X Slim Blu-Ray Reader.  I got in on the cheap from an ebay seller.  It&#8217;s one of those fancy slimline drives so there&#8217;s no tray to eject.  I hardly ever use optical media except to rip CDs on to my NFS storage.  Not sure how much I&#8217;ll use this but it&#8217;s nice even though it doesn&#8217;t match the case <img src='http://twobit.us/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>Photos</h2>
<p><a href="/files/2012/08/microVirt-open.jpg"><img src="/files/2012/08/microVirt-open-300x225.jpg" alt="" title="microVirt-open" width="300" height="225" class="alignleft size-medium wp-image-1513" /></a></p>
<p><a href="/files/2012/08/microVirt-on.jpg"><img src="/files/2012/08/microVirt-on-225x300.jpg" alt="" title="microVirt-on" width="225" height="300" class="aligncenter size-medium wp-image-1517" /></a></p>
<p>I wish there were something in this last photo to give some perspective on the size of the case.  Basically it&#8217;s the size of a lunchbox <img src='http://twobit.us/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>XT Configuration</h2>
<p>Once it&#8217;s all put together with XT installed it pretty much &#8220;just works&#8221;.  The USB stack on XT isn&#8217;t perfect so some USB devices won&#8217;t work unless you pass the USB controller directly through to a guest using Xen&#8217;s PCI passthrough stuff.  Since XT doesn&#8217;t support USB 3.0 anyways I&#8217;ve passed the 3.0 controller on the motherboard through directly to my Windows 7 guest to get my webcam working.  The Plantronics headset you see in the photo works fine over the virtualized USB stack though and together they make for a pretty sweet VoIP / Video Converencing / GoToMeeting setup.  So that&#8217;s it.  A home build Intel i7 system with 16G of ram, an SSD and Intel TXT / measured boot running XenClient XT.  Pretty solid home system by my standards.</p>
]]></content:encoded>
			<wfw:commentRss>http://twobit.us/blog/2012/08/txt-capable-desktop-virtualization-system/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Chrome web sandbox on XenClient</title>
		<link>http://twobit.us/blog/2012/04/chrome-web-sandbox-on-xenclient/</link>
		<comments>http://twobit.us/blog/2012/04/chrome-web-sandbox-on-xenclient/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 02:06:11 +0000</pubDate>
		<dc:creator>Philip</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[XenClient]]></category>

		<guid isPermaLink="false">http://twobit.us/blog/?p=1471</guid>
		<description><![CDATA[There&#8217;s lots of software out there that sets up a &#8220;sandbox&#8221; to protect your system from untrusted code. The examples that come to mind are Chrome and Adobe for the flash sandbox. The strength of these sandboxes are an interesting point of discussion. Strength is always related to the mechanism and if you&#8217;re running on [...]]]></description>
				<content:encoded><![CDATA[<p>There&#8217;s lots of software out there that sets up a &#8220;sandbox&#8221; to protect your system from untrusted code.  The examples that come to mind are Chrome and Adobe for the flash sandbox.  The strength of these sandboxes are an interesting point of discussion.  Strength is always related to the mechanism and if you&#8217;re running on Windows the separation guarantees you get are only as strong as the separation Windows affords to processes.  If this is a strong enough guarantee for you then you probably won&#8217;t find this post very useful.  If you&#8217;re interested in using XenClient and the Xen hypervisor to get yourself the strongest separation that I can think of, then read on!</p>
<h2>Use Case</h2>
<p>XenClient allows you to run any number of operating systems on a single piece of hardware.  In my case this is a laptop.  I&#8217;ve got two VMs: my work desktop (Windows 7) for email and other work stuff and my development system that runs Debian testing (Wheezy as of now).</p>
<p>Long story short, I don&#8217;t trust some of the crap that&#8217;s out on the web to run on either of these systems.  I&#8217;d like to confine my web browsing to a separate VM to protect my company&#8217;s data and my development system.  This article will show you how to build a bare bones Linux VM that runs a web browser (Chromium) and little more.</p>
<h2>Setup</h2>
<p>You&#8217;ll need a linux VM to host your web browser.  I like Debian Wheezy since the PV xen drivers for network and disk work out of the box on XenClient (2.1).  There&#8217;s a small bug that required you use LVM for your rootfs but I typically do that anyways so no worries there.  </p>
<p>Typically I do an install omitting even the &#8220;standard system tools&#8221; to keep things as small as possible.  This results in a root file system that&#8217;s < 1G.  All you need to do then is install the web browser (chromium), rungetty, and the xinint package.  Next is a bit of scripting and some minor configuration changes.</p>
<h3>inittab</h3>
<p>When this VM boots we want the web browser to launch and run full screen.  We don&#8217;t want a window manager or anything.  Just the browser.</p>
<p>When Linux boots, the <code>init</code> process parses the <code>/etc/inittab</code> file.  One of the things specified in <code>inittab</code> are processes that <code>init</code> starts like <code>getty</code>.  Typically <code>inittab</code> starts <code>getty</code>&#8216;s on 6 ttys but we want it to start chrome for us.  We can do this by having init execute <code>rungetty</code> (read the man page!)  which we can then have execute arbitrary commands for us:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># /sbin/getty invocations for the runlevels.
#
# The &quot;id&quot; field MUST be the same as the last
# characters of the device (after &quot;tty&quot;).
#
# Format:
#  &lt;id&gt;:&lt;runlevels&gt;:&lt;action&gt;:&lt;process&gt;
#
# Note that on most Debian systems tty7 is used by the X Window System,
# so if you want to add more getty's go ahead but skip tty7 if you run X.
#
1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/rungetty tty6 -u root /usr/sbin/chrome-restore.sh</pre></div></div>

<p>Another configuration change you&#8217;ll have to make is in <code>/etc/X11/Xwrapper.config</code>.  The default configuration in this file prevents users from starting X if their controlling TTY isn&#8217;t a virtual console.  Since we&#8217;re kicking off <code>chromium</code> directly we need to relax this restriction:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">allowed_users=anybody</pre></div></div>

<h3>chromium-restore script</h3>
<p>Notice that we have <code>rungetty</code> execute a script for us and it does so as the root user.  We don&#8217;t want <code>chromium</code> running as root but we need to do some set-up before we kick off <code>chromium</code> as an unprivileged user.  Here&#8217;s the <code>chrome-restore.sh</code> script:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #007800;">USER</span>=chromium
<span style="color: #007800;">HOMEDIR</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${USER}</span>
<span style="color: #007800;">HOMESAFE</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${USER}</span><span style="color: #660033;">-clean</span>
<span style="color: #007800;">CONFIG</span>=<span style="color: #800000;">${HOMEDIR}</span><span style="color: #000000; font-weight: bold;">/</span>.config<span style="color: #000000; font-weight: bold;">/</span>chromium<span style="color: #000000; font-weight: bold;">/</span>Default<span style="color: #000000; font-weight: bold;">/</span>Preferences
<span style="color: #007800;">LAUNCH</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">which</span> chromium-launch.sh<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-x</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LAUNCH}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;web-launch.sh not executable: <span style="color: #007800;">${LAUNCH}</span>&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #007800;">CMD</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${LAUNCH}</span> <span style="color: #007800;">${CONFIG}</span>&quot;</span>
&nbsp;
rsync <span style="color: #660033;">-avh</span> <span style="color: #660033;">--delete</span> <span style="color: #800000;">${HOMESAFE}</span><span style="color: #000000; font-weight: bold;">/</span> <span style="color: #800000;">${HOMEDIR}</span><span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
<span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> <span style="color: #800000;">${USER}</span>:<span style="color: #800000;">${USER}</span> <span style="color: #800000;">${HOMEDIR}</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">su</span> - <span style="color: #660033;">--</span> <span style="color: #800000;">${USER}</span> <span style="color: #660033;">-l</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;STARTUP=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">${CMD}</span><span style="color: #000099; font-weight: bold;">\&quot;</span> startx&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
shutdown <span style="color: #660033;">-Ph</span> now</pre></div></div>

<p>The first part of this script is setting up the home directory for the user (chromium) that will be running chromium.  This is the equivalent of us restoring the users home directory to a &#8220;known good state&#8221;.  This means that the directory located at <code>/usr/share/chromium-clean</code> is a &#8220;known good&#8221; home directory for us to start from.  On my system it&#8217;s basically an empty directory with chrome&#8217;s default config.</p>
<p>The second part of the script, well really the last two lines just runs <code>startx</code> as an unprivileged user.  <code>startx</code> kicks off the X server but first we set a variable <code>STARTUP</code> to be the name of another script: <code>chromium-launch.sh</code>.  When this variable is set, <code>startx</code> runs the command from the variable after the X server is started.  This is a convenient way to kick off an X server that runs just a single graphical application.</p>
<p>The last command shuts down the VM.  The shutdown command will only be run after the X server terminates which will happen once the chromium process terminates.  This means that once the last browser tab is closed the VM will shutdown.</p>
<h3>chromium-launch script</h3>
<p>The <code>chromium-launch.sh</code> script looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #007800;">CONFIG</span>=<span style="color: #007800;">$1</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${CONFIG}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;cannot locate CONFIG: <span style="color: #007800;">${CONFIG}</span>&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #007800;">LINE</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>xrandr <span style="color: #660033;">-q</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> Screen<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">WIDTH</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${LINE}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ print $8 }'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">HEIGHT</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${LINE}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ print $10 }'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">','</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s&amp;\(\s\+<span style="color: #000099; font-weight: bold;">\&quot;</span>bottom<span style="color: #000099; font-weight: bold;">\&quot;</span>:\s\+\)-\?[0-9]\+&amp;\1<span style="color: #007800;">${HEIGHT}</span>&amp;&quot;</span> <span style="color: #800000;">${CONFIG}</span>
<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s&amp;\(\s\+<span style="color: #000099; font-weight: bold;">\&quot;</span>left<span style="color: #000099; font-weight: bold;">\&quot;</span>:\s\+\)-\?[0-9]\+&amp;\10&amp;&quot;</span> <span style="color: #800000;">${CONFIG}</span>
<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s&amp;\(\s\+<span style="color: #000099; font-weight: bold;">\&quot;</span>right<span style="color: #000099; font-weight: bold;">\&quot;</span>:\s\+\)-\?[0-9]\+&amp;\1<span style="color: #007800;">${WIDTH}</span>&amp;&quot;</span> <span style="color: #800000;">${CONFIG}</span>
<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s&amp;\(\s\+<span style="color: #000099; font-weight: bold;">\&quot;</span>top<span style="color: #000099; font-weight: bold;">\&quot;</span>:\s\+\)-\?[0-9]\+&amp;\10&amp;&quot;</span> <span style="color: #800000;">${CONFIG}</span>
<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s&amp;\(\s\+<span style="color: #000099; font-weight: bold;">\&quot;</span>work_area_bottom<span style="color: #000099; font-weight: bold;">\&quot;</span>:\s\+\)-\?[0-9]\+&amp;\1<span style="color: #007800;">${HEIGHT}</span>&amp;&quot;</span> <span style="color: #800000;">${CONFIG}</span>
<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s&amp;\(\s\+<span style="color: #000099; font-weight: bold;">\&quot;</span>work_area_left<span style="color: #000099; font-weight: bold;">\&quot;</span>:\s\+\)-\?[0-9]\+&amp;\10&amp;&quot;</span> <span style="color: #800000;">${CONFIG}</span>
<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s&amp;\(\s\+<span style="color: #000099; font-weight: bold;">\&quot;</span>work_area_right<span style="color: #000099; font-weight: bold;">\&quot;</span>:\s\+\)-\?[0-9]\+&amp;\1<span style="color: #007800;">${WIDTH}</span>&amp;&quot;</span> <span style="color: #800000;">${CONFIG}</span>
<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s&amp;\(\s\+<span style="color: #000099; font-weight: bold;">\&quot;</span>work_area_top<span style="color: #000099; font-weight: bold;">\&quot;</span>:\s\+\)-\?[0-9]\+&amp;\10&amp;&quot;</span> <span style="color: #800000;">${CONFIG}</span>
&nbsp;
chromium</pre></div></div>

<p>It&#8217;s a pretty simple script.  It takes one parameter which is the path to the main <code>chromium</code> config file.  It query&#8217;s the X server through <code>xrandr</code> to get the screen dimensions (WIDTH and HEIGHT) which means it must be run <em>after</em> the X server starts.  It then re-writes the relevant values in the config file to the maximum screen width and height so the browser is run &#8220;full screen&#8221;.  Pretty simple stuff &#8230; once you figure out the proper order to do things and the format of the <code>Preferences</code> file which was non-trivial.</p>
<h3>User Homedir</h3>
<p>The other hard part is creating the &#8220;known good&#8221; home directory for your unprivileged user.  What I did was start up <code>chromium</code> once manually.  This causes the standard <code>chromium</code> configuration to be generated with default values.  I then copied this off to /usr/share to be extracted on each boot.</p>
<h3>Conclusion</h3>
<p>So hopefully these instructions are enough to get you a Linux system that boots and runs Chromium as an unprivileged user.  It should restore that users home directory to a known good state on each boot so that any downloaded data will be wiped clean.  When the last browser tab is closed it will power off the system.</p>
<p>I use this on my XenClient XT system for browsing sites that I want to keep separate from my other VMs.  It&#8217;s not perfect though and as always there is more that can be done to secure it.  I&#8217;d start by making the root file system read only and adding SELinux would be fun.  Also the interface is far too minimal.  Finding a way to handle edge cases like making pop-ups manageable and allowing us to do things like control volume levels would also be nice.  This may require configuring a minimal window manager which is a pretty daunting task.  If you have any other interesting ways to make this VM more usable or lock it down better you should leave them in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://twobit.us/blog/2012/04/chrome-web-sandbox-on-xenclient/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>openembedded yocto native hello world</title>
		<link>http://twobit.us/blog/2012/04/openembedded-yocto-native-hello-world/</link>
		<comments>http://twobit.us/blog/2012/04/openembedded-yocto-native-hello-world/#comments</comments>
		<pubDate>Fri, 13 Apr 2012 20:12:05 +0000</pubDate>
		<dc:creator>Philip</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OE]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[Yocto]]></category>

		<guid isPermaLink="false">http://twobit.us/blog/?p=1441</guid>
		<description><![CDATA[NOTE: I took the time to get to the bottom of the issue discussed in this post. There&#8217;s a new post here that explains the &#8220;right way&#8221; to use Makefiles with yocto. As always, the error in this post was mine I&#8217;ve officially &#8220;drank the Kool-Aid&#8221; and I&#8217;m convinced openembedde and Yocto are pretty awesome. [...]]]></description>
				<content:encoded><![CDATA[<p><strong>NOTE:</strong> I took the time to get to the bottom of the issue discussed in this post.  There&#8217;s a new post <a href="http://twobit.us/blog/2012/08/openembedded-yocto-native-hello-world-take-2/">here</a> that explains the &#8220;right way&#8221; to use Makefiles with yocto.  As always, the error in this post was mine <img src='http://twobit.us/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I&#8217;ve officially &#8220;drank the Kool-Aid&#8221; and I&#8217;m convinced openembedde and Yocto are pretty awesome.  I&#8217;ve had a blast building small Debian systems on PCEngines hardware in the past and while I&#8217;m waiting for my <a href="http://www.raspberrypi.org/">Raspberry Pi</a> to arrive I&#8217;ve been trying to learn the ins and outs of Yocto.  The added bonus is that the XenClient team at Citrix uses openembedded for our build system so this work can also fall under the heading of &#8220;professional development&#8221;.</p>
<p>Naturally the first task I took on was way too complicated so I made a bunch of great progress (more about that in a future post once I get it stable) but then I hit a wall that I ended up banging my head against for a full day.  I posted a cry for help on the mailing list and didn&#8217;t get any responses so I set out to remove as many moving parts as possible and find the root cause.</p>
<p>First things first read the <a href="http://www.yoctoproject.org/docs/current/dev-manual">Yocto development</a> manual and the <a href="http://www.yoctoproject.org/docs/1.1.1/poky-ref-manual">Yocto reference</a> for whatever release you&#8217;re using.  This is essential because no one will help you till you&#8217;ve read and understand these <img src='http://twobit.us/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So the software I&#8217;m trying to build is built using raw Makefiles, none of that fancy autotools stuff.  This can be a bit of a pain because depending on the Makefiles, it&#8217;s not uncommon for assumptions to be made about file system paths.  Openembedded is all about cross compiling so it wants to build and install software under all sorts of strange roots and some Makefiles just can&#8217;t handle this.  I ran into a few of these scenarios but nothing I couldn&#8217;t overcome.</p>
<p>Getting a package for my target architecture wasn&#8217;t bad but I did run into a nasty problem when I tried to get a native package built.  From the searches I did on the interwebs it looks like there have been a number of ways to build native packages.  The current &#8220;right way&#8221; is simply to have your recipe extend the native class.  Thanks to <a href="http://www.xora.org.uk/">XorA</a> for documenting his/her <a href="http://www.xora.org.uk/2010/01/22/openembeddedangstom-new-package-workflow-eggdbus/">new package workflow</a> for that nugget.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">BBCLASSEXTEND = &quot;native&quot;</pre></div></div>

<p>After having this method blow up for my recipe I was tempted to hack together some crazy work around.  I really want to upstream the stuff I&#8217;m working on though and I figure having crazy shit in my recipe to work around my misunderstanding of the native class was setting the whole thing up for failure.  So instead I went back to basics and made a &#8220;hello world&#8221; program and recipe (included at the end of this post) hoping to recreate the error and hopefully figure out what I was doing wrong at the same time.</p>
<p>It took a bit of extra work but I was able to recreate the issue with a very simple Makefile.  First the error message:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">NOTE: package hello-native-1.0-r0: task do_populate_sysroot: Started
ERROR: Error executing a python function in /home/build/poky-edison-6.0/meta-test/recipes-test/helloworld/hello_1.0.bb:
CalledProcessError: Command 'tar -cf - -C /home/build/poky-edison-6.0/build/tmp/work/i686-linux/hello-native-1.0-r0/sysroot-destdir///home/build/poky-edison-6.0/build/tmp/sysroots/i\
686-linux -ps . | tar -xf - -C /home/build/poky-edison-6.0/build/tmp/sysroots/i686-linux' returned non-zero exit status 2 with output tar: /home/build/poky-edison-6.0/build/tmp/work\
/i686-linux/hello-native-1.0-r0/sysroot-destdir///home/build/poky-edison-6.0/build/tmp/sysroots/i686-linux: Cannot chdir: No such file or directory
tar: Error is not recoverable: exiting now
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
&nbsp;
&nbsp;
ERROR: The stack trace of python calls that resulted in this exception/failure was:
ERROR:   File &quot;sstate_task_postfunc&quot;, line 10, in &lt;module&gt;
ERROR:
ERROR:   File &quot;sstate_task_postfunc&quot;, line 4, in sstate_task_postfunc
ERROR:
ERROR:   File &quot;sstate.bbclass&quot;, line 19, in sstate_install
ERROR:
ERROR:   File &quot;/home/build/poky-edison-6.0/meta/lib/oe/path.py&quot;, line 59, in copytree
ERROR:     check_output(cmd, shell=True, stderr=subprocess.STDOUT)
ERROR:
ERROR:   File &quot;/home/build/poky-edison-6.0/meta/lib/oe/path.py&quot;, line 121, in check_output
ERROR:     raise CalledProcessError(retcode, cmd, output=output)
ERROR:
ERROR: The code that was being executed was:
ERROR:      0006:        bb.build.exec_func(intercept, d)
ERROR:      0007:    sstate_package(shared_state, d)
ERROR:      0008:
ERROR:      0009:
ERROR:  *** 0010:sstate_task_postfunc(d)
ERROR:      0011:
ERROR: (file: 'sstate_task_postfunc', lineno: 10, function: &lt;module&gt;)
ERROR:      0001:
ERROR:      0002:def sstate_task_postfunc(d):
ERROR:      0003:    shared_state = sstate_state_fromvars(d)
ERROR:  *** 0004:    sstate_install(shared_state, d)
ERROR:      0005:    for intercept in shared_state['interceptfuncs']:
ERROR:      0006:        bb.build.exec_func(intercept, d)
ERROR:      0007:    sstate_package(shared_state, d)
ERROR:      0008:
ERROR: (file: 'sstate_task_postfunc', lineno: 4, function: sstate_task_postfunc)
ERROR: Function 'sstate_task_postfunc' failed
ERROR: Logfile of failure stored in: /home/build/poky-edison-6.0/build/tmp/work/i686-linux/hello-native-1.0-r0/temp/log.do_populate_sysroot.30718
Log data follows:
| NOTE: QA checking staging
| ERROR: Error executing a python function in /home/build/poky-edison-6.0/meta-test/recipes-test/helloworld/hello_1.0.bb:
| CalledProcessError: Command 'tar -cf - -C /home/build/poky-edison-6.0/build/tmp/work/i686-linux/hello-native-1.0-r0/sysroot-destdir///home/build/poky-edison-6.0/build/tmp/sysroots\
/i686-linux -ps . | tar -xf - -C /home/build/poky-edison-6.0/build/tmp/sysroots/i686-linux' returned non-zero exit status 2 with output tar: /home/build/poky-edison-6.0/build/tmp/wo\
rk/i686-linux/hello-native-1.0-r0/sysroot-destdir///home/build/poky-edison-6.0/build/tmp/sysroots/i686-linux: Cannot chdir: No such file or directory
| tar: Error is not recoverable: exiting now
| tar: This does not look like a tar archive
| tar: Exiting with failure status due to previous errors
|
|
| ERROR: The stack trace of python calls that resulted in this exception/failure was:
| ERROR:   File &quot;sstate_task_postfunc&quot;, line 10, in &lt;module&gt;
| ERROR:
| ERROR:   File &quot;sstate_task_postfunc&quot;, line 4, in sstate_task_postfunc
| ERROR:
| ERROR:   File &quot;sstate.bbclass&quot;, line 19, in sstate_install
| ERROR:
| ERROR:   File &quot;/home/build/poky-edison-6.0/meta/lib/oe/path.py&quot;, line 59, in copytree
| ERROR:     check_output(cmd, shell=True, stderr=subprocess.STDOUT)
| ERROR:
| ERROR:   File &quot;/home/build/poky-edison-6.0/meta/lib/oe/path.py&quot;, line 121, in check_output
| ERROR:     raise CalledProcessError(retcode, cmd, output=output)
| ERROR:
| ERROR: The code that was being executed was:
| ERROR:      0006:        bb.build.exec_func(intercept, d)
| ERROR:      0007:    sstate_package(shared_state, d)
| ERROR:      0008:
| ERROR:      0009:
| ERROR:  *** 0010:sstate_task_postfunc(d)
| ERROR:      0011:
| ERROR: (file: 'sstate_task_postfunc', lineno: 10, function: &lt;module&gt;)
| ERROR:      0001:
| ERROR:      0002:def sstate_task_postfunc(d):
| ERROR:      0003:    shared_state = sstate_state_fromvars(d)
| ERROR:  *** 0004:    sstate_install(shared_state, d)
| ERROR:      0005:    for intercept in shared_state['interceptfuncs']:
| ERROR:      0006:        bb.build.exec_func(intercept, d)
| ERROR:      0007:    sstate_package(shared_state, d)
| ERROR:      0008:
| ERROR: (file: 'sstate_task_postfunc', lineno: 4, function: sstate_task_postfunc)
| ERROR: Function 'sstate_task_postfunc' failed
NOTE: package hello-native-1.0-r0: task do_populate_sysroot: Failed
ERROR: Task 3 (virtual:native:/home/build/poky-edison-6.0/meta-test/recipes-test/helloworld/hello_1.0.bb, do_populate_sysroot) failed with exit code '1'
ERROR: 'virtual:native:/home/build/poky-edison-6.0/meta-test/recipes-test/helloworld/hello_1.0.bb' failed</pre></div></div>

<p>So even with the most simple Makefile I could cause a native recipe build to blow up.  Here&#8217;s the Makefile:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">.PHONY : all clean install uninstall
&nbsp;
PREFIX ?= $(DESTDIR)/usr
BINDIR ?= $(PREFIX)/bin
&nbsp;
HELLO_src = hello.c
HELLO_bin = hello
HELLO_tgt = $(BINDIR)/$(HELLO_bin)
&nbsp;
all : $(HELLO_bin)
&nbsp;
$(HELLO_bin) : $(HELLO_src)
&nbsp;
$(HELLO_tgt) : $(HELLO_bin)
	install -d $(BINDIR)
	install -m 0755 $^ $@
&nbsp;
clean :
	rm $(HELLO_bin)
&nbsp;
install : $(HELLO_tgt)
&nbsp;
uninstall :
	rm $(BINDIR)/$(HELLO_tgt)</pre></div></div>

<p>And here&#8217;s the relevant install method from the bitbake recipe:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">do_install () {
    oe_runmake DESTDIR=${D} install
}</pre></div></div>

<p>Notice I&#8217;m using the variable <code>DESTDIR</code> to tell the Makefile the root (not just /) to install things to.  This should work right?  It works for a regular package but not for a native one!  This drove me nuts for a full day.</p>
<p>The solution to this problem lies in some weirdness in the Yocto <code>native</code> class when combined with the <code>populate_sysroot</code> method.  The way I figured this out was by inspecting the differences in the environment when building <code>hello</code> vs <code>hello-native</code>.  When building the regular package for the target architecture variables like <code>bindir</code> and <code>sbindir</code> were what I would expect them to be:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">bindir=&quot;/usr/bin&quot;
sbindir=&quot;/usr/sbin&quot;</pre></div></div>

<p>but when building <code>hello-native</code> they get a bit crazy:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">bindir=&quot;/home/build/poky-edison-6.0/build/tmp/sysroots/i686-linux/usr/bin&quot;
sbindir=&quot;/home/build/poky-edison-6.0/build/tmp/sysroots/i686-linux/usr/sbin&quot;</pre></div></div>

<p>This is a hint at the source of crazy path that staging is trying to tar up above in the error message.  Further if you look in the build directory for a regular target arch package you&#8217;ll see your files where you expect in <code>${D}sysroot-destdir/usr/bin</code> but for a native build you&#8217;ll see stuff in <code>${D}sysroot-destdir/home/build/poky-edison-6.0/build/tmp/sysroots/i686-linux/usr/bin</code>.  Pretty crazy right?  I&#8217;m sure there&#8217;s a technical reason for this but it&#8217;s beyond me.</p>
<p>So the way you can work around this is by telling your <code>Makefile</code>s about paths like <code>bindir</code> through the recipe.  A fixed <code>do_install</code> would look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">do_install () {
    oe_runmake DESTDIR=${D} BINDIR=${D}${bindir} install
}</pre></div></div>

<p>For more complicated Makefiles you can probably specify a <code>PREFIX</code> and set this equal to the <code>${prefix}</code> variable but YMMV.  I&#8217;ll be trying this out to keep my recipes as simple as possible.</p>
<p>If you want to download my example the <a href="http://twobit.us/files/2012/04/hello_1.0.bb.gz">recipe is here</a>.  This will pull down the hello world source code and build the whole thing for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://twobit.us/blog/2012/04/openembedded-yocto-native-hello-world/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Linux bridge forward EAPOL 8021x frames</title>
		<link>http://twobit.us/blog/2012/03/linux-bridge-forward-eapol-8021x-frames/</link>
		<comments>http://twobit.us/blog/2012/03/linux-bridge-forward-eapol-8021x-frames/#comments</comments>
		<pubDate>Thu, 29 Mar 2012 02:08:05 +0000</pubDate>
		<dc:creator>Philip</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[XenClient]]></category>

		<guid isPermaLink="false">http://twobit.us/blog/?p=1435</guid>
		<description><![CDATA[XenClient is no different from other Xen configurations in that the networking hardware is shared between guests through a bridge hosted in dom0 (or a network driver domain in the case of XenClient XT). For most use cases the standard Linux bridge will route your traffic as expected. We ran into an interesting problem however [...]]]></description>
				<content:encoded><![CDATA[<p>XenClient is no different from other Xen configurations in that the networking hardware is shared between guests through a bridge hosted in dom0 (or a <a href="http://twobit.us/blog/2010/07/xen-network-driver-domain-how/">network driver domain</a> in the case of XenClient XT).  For most use cases the standard Linux bridge will route your traffic as expected.  We ran into an interesting problem however when a customer doing a pilot on XenClient XT tried to authenticate their guest VMs using EAPOL (8021x auth over ethernet).  The bridge gobbled up their packets and we got some pretty strange bug reports as a result.</p>
<p>Just throwing &#8220;linux bridge EAPOL 8021x&#8221; into a search engine will return a <a href="http://forum.soft32.com/linux/EAPOL-bridging-ftopict523493.html">number</a> <a href="http://lkml.indiana.edu/hypermail/linux/kernel/1010.2/00890.html">of</a> <a href="http://www.gremwell.com/dot1x-transparent-linux-bridge">hits</a> from various mailing lists where users report similar issues.  <a href="https://lists.linux-foundation.org/pipermail/bridge/2010-October/007378.html">The fix</a> is literally a one line change that drops a check on the destination MAC address.  This check is to ensure compliance with the 8021d standard which requires layer 2 bridges to drop packets from the &#8220;<a href="standards.ieee.org/develop/regauth/tut/macgrp.pdf">bridge filter MAC address group</a>&#8220;.  Since XenClient is a commercial product and the fix is in code that is responsible for our guest networking (which is pretty important) we wanted to code up a way to selectively enable this feature on a per-bridge basis using a sysfs node.  We / I also tested the hell out of it for a few days straight.</p>
<p>The end result is a neat little patch that allows users to selectively pass EAPOL packets from their guests across the layer 2 bridge in dom0 / ndvm and out to their authentication infrastructure.  The patch is available opensource just like the kernel and is available on the XenClient source CD.  It&#8217;s also <a href='/files/2012/03/break_8021d.gz'>available here</a> for your convenience <img src='http://twobit.us/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://twobit.us/blog/2012/03/linux-bridge-forward-eapol-8021x-frames/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OE-Core Yocto gcc timeout</title>
		<link>http://twobit.us/blog/2012/03/oe-core-yocto-gcc-timeout/</link>
		<comments>http://twobit.us/blog/2012/03/oe-core-yocto-gcc-timeout/#comments</comments>
		<pubDate>Mon, 19 Mar 2012 03:55:56 +0000</pubDate>
		<dc:creator>Philip</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[OE]]></category>
		<category><![CDATA[Yocto]]></category>

		<guid isPermaLink="false">http://twobit.us/blog/?p=1428</guid>
		<description><![CDATA[I&#8217;ve been thrashing around trying to get the upstream OE to build an image for me. Today I finally made a concerted effort over a few hours to dive deep and do this right. It turns out I was using the &#8220;old&#8221; OE repos when I should have been using the &#8220;new&#8221; build system from [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been thrashing around trying to get the upstream OE to build an image for me.  Today I finally made a concerted effort over a few hours to dive deep and do this right.  It turns out I was using the &#8220;old&#8221; OE repos when I should have been using the &#8220;new&#8221; build system from the <a href="http://www.yoctoproject.org/">Yocto Project</a>.  Their documentation is excellent but still, my first build failed.</p>
<p>What&#8217;s this?  The GCC recipe failing because of a network timeout?  Oddly enough it actually downloaded some of the sources but not all of &#8216;em.<br />
<code><br />
| svn: REPORT of '/svn/gcc/!svn/vcc/default': Could not read response body: connection was closed by server (http://gcc.gnu.org)<br />
NOTE: package gcc-cross-initial-4.6.1+svnr175454-r10: task do_fetch: Failed<br />
ERROR: Task 5 (/home/build/poky-edison-6.0/meta/recipes-devtools/gcc/gcc-cross-initial_4.6.bb, do_fetch) failed with exit code '1'<br />
ERROR: '/home/build/poky-edison-6.0/meta/recipes-devtools/gcc/gcc-cross-initial_4.6.bb' failed<br />
</code></p>
<p>At this point I just tried again and it failed in the same place but had checked out more of the code.  A quick search turns up a similar error is common when checking out code from SVN servers over HTTP.  Apache just has a tendency to timeout when checking out large repositories with mod-svn.  The suggested fix is to increase the timeout value in your Apache configs &#8230; except these configs are on the GNU web servers and we can&#8217;t change them.</p>
<p>What we can change though is the protocol bitbake uses when getting the sources.  Just change the proto from &#8216;http&#8217; to &#8216;svn&#8217; in the SRC_URI in gcc-4.6.inc (found at <code>/meta/recipes-devtools/gcc/gcc-4.6.inc</code> and we&#8217;re almost good.  It&#8217;ll look like this when you&#8217;re done.</p>
<p><code><br />
SRC_URI = "svn://gcc.gnu.org/svn/gcc/branches;module=${BRANCH};proto=svn \<br />
</code></p>
<p>It still timed out for me a few times but it ran for much longer than the HTTP protocol option.  HTTP timed out after about 10 minutes, SVN made it almost an hour before timing out &#8230; You&#8217;d think there would be a tarball of these sources mirrored somewhere so we didn&#8217;t have to kill the GNU SVN servers on every fresh build.  Something to look into I guess.  Either way gcc is building now, hopefully I&#8217;ll have a build running soon &#8230;</p>
<p>UPDATE: With some advice from Scott below I used the poky distro by including: <code>DISTRO="poky"</code> in my local.conf file.  As promised bitbake then doesn&#8217;t try to check out the gcc svn repository directly from gnu.org.  Instead it grabs a tarball from one ob the Yocto mirrors and the build takes mere minutes.  Thanks Scott!</p>
]]></content:encoded>
			<wfw:commentRss>http://twobit.us/blog/2012/03/oe-core-yocto-gcc-timeout/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
