Posted by: Joe Devietti on: February 6, 2010
I recently decided to try using the x86 emulator bochs for some of my architecture research, as bochs seems to have a well-structured code base highly amenable to hacking. I also considered using qemu, but qemu’s design was ultimately not a great fit for the do-1-insn-at-a-time model of an architecture simulator. Instead, qemu is designed to run a bunch of instructions (really fast) instead of stopping precisely after each one. For the record, I was using bochs from CVS as of 2 Feb 2010 (bochs 2.4.2 was the latest release at the time) and qemu 0.12.2.
Next came the supposedly easy part: create a disk image with Linux on it (I wanted to use Ubuntu Karmic Server) and start simulating.
It turns out that running the Ubuntu installer in bochs is a real pain. Not only is it slow, but I encountered an assertion failure (in bochs) during the disk partition step of the installation. It turned out that this was due to some funkiness in the bochs plugin system (which is based on dynamically-linked libraries); switching to static linking finally got me past the assertion failure. After that adventure I had some kind of boot loader corruption that caused the virtual machine to fail to boot. Don’t even ask about getting networking to work (it still doesn’t), or why the terminal occasionally looks like the picture below.
An alternative approach is to use debootstrap to setup a chroot Linux installation, and then copy that installation onto the virtual hard disk, as outlined here. However, this is a pretty involved procedure, debootstrap with Ubuntu didn’t install any kernels for me, and installing the boot loader also proved tricky.
Contrast these circuitous approaches with qemu, which is very fast (even without using KVM acceleration) and installed Ubuntu without a hitch on the first try. With networking. And a nice virtual monitor via VNC. All straight out of the box. qemu+kvm might even be fast enough to compile code inside the VM, which would ensure that the right headers, libraries, etc are used (otherwise you can always just mount the virtual drive as a regular filesystem and use cp from the host machine). qemu is everything I could ask for — if only its codebase was more in tune with what I wanted to do!
It took me a while to realize that I could have my bochs and qemu it, too, as both emulators can read and write a common virtual disk format: it’s called “raw” for qemu and “flat” for bochs. Essentially, it just uses a single regular file as the virtual disk. The only trick is that you have to create the virtual disk using bochs’ bximage program; if it’s created with qemu’s corresponding qemu-img program then bochs won’t recognize the virtual disk for some reason.
With this hybrid approach, I can boot the disk using qemu for installing the OS, interactively setting things up via the commandline, downloading packages from the internet and so on, and then reboot into bochs to run simulations. It gives me the excellent speed and hardware emulation of qemu, with the more-natural-for-simulation interface of bochs.
Posted by: Joe Devietti on: November 10, 2009
My school (UW) recently allowed students to switch their school email accounts over to one of 2 providers: Google (via gmail) or Microsoft (via Outlook Web Access). Feeling the inexorable pull of the cloud, I decided to take the plunge and switch to gmail, but one thing held me back. I have used Thunderbird for a few years now and have accumulated roughly 1GB of archived messages that are generally unimportant but occasionally vital. I’ve also espoused Lifehacker’s Trusted Trio email organization system and so many of the emails in my archive are tagged for easier organization.
I’d like to have this email archive searchable from gmail. And I would really like to have all those tags I’ve accumulated over the years show up as gmail “labels”. Fortunately, this isn’t too difficult thanks to the following: Read the rest of this entry »
Posted by: Joe Devietti on: April 17, 2009
One of the cool things I learned about Powerpoint the other day is that it’s possible to create interactions between an embedded Flash movie and the presentation itself. This allows you to coordinate animations across the movie and the slide, e.g. to have a mouse click sometimes advance the slide and sometimes trigger some action in the movie.
The reason all this works is because you can do function calls up from the Flash movie, through the ActiveX container and into VBA code attached to the Powerpoint presentation. You can also call down from Powerpoint into Flash in a similar manner, though I haven’t experimented with this.
Perhaps surprisingly, writing the code is the easy part. The Visual Basic code attached to the Powerpoint slide looks like this:
Private Sub ShockwaveFlash1_FlashCall(ByVal request As String)
'request looks like:
'<invoke name="foo" returntype="xml"><arguments></arguments></invoke>;
If InStr(request, "gotoNextSlide") > 0 Then
ActivePresentation.SlideShowWindow.View.Next
ElseIf InStr(request, "gotoPrevSlide") > 0 Then
ActivePresentation.SlideShowWindow.View.Previous
End If
End Sub
ShockwaveFlash1 is the name of the ActiveX control for the Flash movie. If you only have one of these on a slide, this will be its name. But if you have more than one, the names will be ShockwaveFlash2 and so on.
In ActionScript land, the code that calls out of the Flash movie looks like this:
import flash.external.ExternalInterface;
if ( ExternalInterface.available ) {
ExternalInterface.call( "gotoNextSlide" );
}
Unfortunately, this code won’t do anything out of the box.
This is because of the Flash player security model, with which I became overly familiar over the course of this project. There are several different security sandboxes in which a Flash movie can potentially be running. In order for ExternalInterface function calls to work, the movie needs to be, sensibly, in the most trusted sandbox: the LOCAL_TRUSTED sandbox. Fortunately, a movie can check what sandbox it’s running in with the following code:
import flash.system.Security; trace( Security.sandboxType );
If you run a Flash movie in the standalone Flash player, it runs with LOCAL_TRUSTED privileges. However, if you run that same movie via an ActiveX control in Powerpoint, the default security settings put it in the LOCAL_WITH_NETWORK sandbox, which is insufficiently privileged to allow Powerpoint-Flash interaction to work. Instead, things will fail silently. And no amount of tinkering with Powerpoint’s security settings (trusting ActiveX content, macros, etc.) will fix things. After much anguish, I discovered that you have to talk directly to the Flash runtime to get a movie into the LOCAL_TRUSTED sandbox when running inside an ActiveX control.
There are several ways of telling the Flash runtime to put a particular movie in the LOCAL_TRUSTED sandbox, all of them documented at the Adobe link above. Probably the easiest way is via the Flash Security Settings Manager gui: it’s a Flash applet that runs in your browser to control your local Flash settings – spooky! You can decide to trust particular .swf files, or directories, or even the Powerpoint executable itself which will automatically trust all movies that are included in Powerpoint slides. I’ve blogged previously about how to do this, but there are a few tricky parts I haven’t covered before.
If you’re embedding Flash movies into Powerpoint (as opposed to just linking to the movies), then you have to trust the Powerpoint binary, as the Flash movies don’t have a real filesystem location – if you check where an embedded movie lives via root.loaderInfo.url you will get the path to the Powerpoint binary. Trusting the Powerpoint binary is a hack that allows the movie, indirectly, to be trusted as well. Trusting Powerpoint will also enable non-embedded Flash movies to run in the LOCAL_TRUSTED sandbox.
If your Powerpoint slides just link to the Flash movies, then you can have finer-grained control over security, but of course you have to ensure the links are always valid or the movies won’t work.
Getting the Flash player security settings right was definitely the trickiest part, because they’re a bit out of the way and not terribly popular topics of conversation according to Google. But to make Powerpoint and Flash play nice together you also need to (clearly) enable macros in Powerpoint and allow ActiveX controls to run. ActiveX controls don’t need any special treatment however: they can run in Safe Mode with privileges that prompt you before they are enabled with “minimal restrictions”. I never saw a prompt, because I don’t think the Flash ActiveX control requires any special privileges.
Once you get the security settings resolved things work great. It is highly unlikely, however, that things will work out-of-the-box if you move the presentation to a new computer, due to the default security settings. But once you get things integrated, you get the power of Flash for doing complicated animations with the ease of Powerpoint for the simple stuff. Pretty much the best of both worlds!
Posted by: Joe Devietti on: April 11, 2009
I love Amazon’s Elastic Compute Cloud, and have been using it to run research experiments without having to worry about multiplexing computing resources among other members of my research group. No running top after I login to make sure I’m not stepping on someone else’s experiments: I launch an instance and I get it all to myself.
Sharing storage across instances, however, is tricky. For my purposes, having a read-only copy distributed among my instances is sufficient; of course adding read/write access makes things substantially trickier. Yet even given that I was fine with read-only access, none of the solutions that immediately came to mind were satisfactory:
What I really wanted was the ability to mount an EBS volume read-only on multiple instances. Since things are read-only, there won’t be any consistency issues but, still, Amazon doesn’t support this. Until I discovered a hack to make it possible, using EBS snapshots.
The basic idea is to have a master EBS volume V that you want to replicate with read-only copies across a number of instances. Upon bootup, each instance makes a snapshot of V and then its own personal volume Vp based on that snapshot. Each instance can then attach the volume Vp and voila – we’ve got our data replicated across our instances. No fancy network filesystem or S3 hacks necessary.
What makes all this go is that EBS snapshots are very fast (because they’re lazily constructed). My master volume V is 10GB in size, and about 7GB full at the moment. And this whole take-a-snapshot-and-mount-it routine takes less than 10 seconds. After I’m done with an instance, I have it throw away the snapshot and volume Vp to save space. But since snapshots are built on diffs, having a bunch of snapshots doesn’t take up much room in S3 (i.e. cost much money) anyway. Ultimately, EBS is doing exactly what I would want to provide a high performance read-only version of the volume: lazy creation of snapshots makes replication fast, and each snapshot volume functions as a cache to increase read bandwidth. And all this without any extra engineering on my part!
I put together some Python scripts (with the help of the excellent Boto library) to automate this read-only replication of an EBS volume. All you have to do is edit some parameters in ec2lib.py and then link these scripts into your distro’s boot/shutdown routines; this code is designed to be run from the instance itself. The code is available under the MIT license (like Boto itself). The repository includes a copy of Boto 1.7a to keep things self-contained.
Posted by: Joe Devietti on: March 20, 2009
The first beta version of the Lockfox Firefox extension has been posted to addons.mozilla.org! I developed this with Rohit Chaudhri as our class project for Yoshi Kohno’s graduate course in computer security at the University of Washington. I’ll use this blog to talk about the development of Lockfox and interact with its (eventual) users. Right now it’s just an experimental addon (so it’s kinda hard to find) but hopefully it will soon pass AMO’s code review and be listed as a trusted, public addon!
Lockfox works in a manner similar to the SSH known_hosts database, but instead of remembering an association between public keys and domain names, Lockfox remembers an association between a password submitted on a web form and the domain to which that password was submitted. For added privacy, Lockfox stores only the SHA1 hash of the password, not the password itself. Lockfox monitors all password submissions and checks on each submission if a remembered (hashed) password is being submitted to a new, unknown domain. Lockfox prompts the user with a dialog to ensure that the user wants to submit their password to a new domain. If the user authorizes the submission, Lockfox forges a new trusted association between the password and the new domain. Otherwise, Lockfox redirects the user to the old, trusted domain.
For additional security, Lockfox also remembers any SSL certificate information available for the site to which a password is submitted. If this certificate information changes unexpectedly for some password submission, Lockfox requires the user to authorize the submission. The intuition here is exactly the same as that behind SSH’s known_hosts database: an unexpectedly changed SSL certificate likely indicates a man-in-the-middle attack.
The intuition behind Lockfox is that a password is generally used only with a very limited set of domains – if a password gets sent to a different domain, it is likely that a phishing attack is taking place. Lockfox has a number of advantages compared to existing anti-phishing techniques:
To be fair, there are some disadvantages to Lockfox’s approach, too:
Ultimately, Lockfox is just one more tool for keeping people safe online. It will work best when combined with existing anti-phishing techniques (such as those already built-in to Firefox).
Are you using Lockfox? Thanks for your bravery, and please post any feedback in the comments!
Posted by: Joe Devietti on: March 15, 2009
Here are some instructions to help you run the presentation I gave on Deterministic Shared Memory Multiprocessing at ASPLOS 2009. The presentation itself can be downloaded here. This presentation uses Shockwave Flash movies embedded in Powerpoint, and interaction between the two, so there are a few steps you have to go through to get everything to work right.
Software you need installed:
There are macros on the slides with Flash movies that synchronize the advancing of the slide with the animation being played by Flash. Essentially, any slide with a Flash movie is “driven by” the movie – clicking on the movie will either advance the movie or the animated elements (e.g. bullet points appearing) on the Powerpoint slide, as appropriate. The Flash movies need enhanced privileges to be able to call code outside their ActiveX container, and you need Powerpoint macros enabled so that the Flash movies have some code to call.
If you just want to look over the slides and/or play the Flash movies in a standalone Flash player, you can ignore all the nonsense below. This is also helpful if you don’t want to run Powerpoint macros or trust any Flash content to run with local privileges.
To get things to work with macros disabled and the Flash content remaining untrusted: just click on the movie as usual and, if nothing happens, that click was supposed to animate something on the slide instead. You can just click on the slide (not the Flash movie! – clicking on the slide title text is safe) to animate the slide manually. It requires moving the mouse around, so I didn’t want to do that for my actual presentation, but it works just as well for a less formal setting.
If you don’t want to install or run any ActiveX plugins in Powerpoint, you can also just play the Flash movies in a standalone Flash player. Synchronizing this with the slides is kind of klunky though.
First off, I’m pretty sure this only works on Windows, due to the dependence on the Flash ActiveX Control. I’ve tested it on Windows Vista, but XP should be okay too. There are 4 things you need for this to work seamlessly.
Visit the Flash Security Settings Manager web page and specify that you trust the Powerpoint executable via the “Add location” dropdown. With Office 2007 on Vista, my Powerpoint executable was at C:\Program Files\Microsoft Office\Office12\POWERPNT.EXE
Why is this way less secure? By setting Powerpoint as a trusted source for Flash, any Flash content that gets embedded into Powerpoint will run with the highest privileges (which includes access to local files). You may or may not feel comfortable with this. The upside is that you can move the presentation to a new directory without breaking anything.
Visit the Flash Security Settings Manager web page and specify that you trust only the directory where the Flash movies for the presentation are (e.g. C:\Users\Admin\Desktop\dmp-asplos2009-presentation\ if you downloaded the presentation and unzipped it onto your Desktop). You do this via the “Add location” dropdown.
This is more secure because only the Flash content in the specified directory will be trusted, but if you move the movies or the presentation to a new directory, things will stop working (and silently!).
There’s a test slide at the end of the presentation which has an embedded Flash movie in it. The movie runs some basic sanity checks on your configuration and displays the results. If everything appears ok, then the presentation itself should run fine.
Clicking on a Flash movie will advance the animation one step forward. Pressing the ‘c’ key makes the animation go one step backward. That’s all there is to it!
Posted by: Joe Devietti on: March 12, 2009
Here’s how I got the Adobe Flash Player 10 ActiveX Control to install under Windows Vista, so I could embed Flash movies in Powerpoint.
This is kind of convoluted; maybe people have found easier ways?
Posted by: Joe Devietti on: February 21, 2009
I recently attended ASPLOS 2009 in Washington, D.C., and put together some slides for the presentation I gave on Deterministic Shared Memory Multiprocessing. To appease my endless thirst for new technologies, I figured I’d try using Powerpoint with embedded Shockwave Flash movies for the presentation, instead of the traditional vanilla-Powerpoint. Why bother making my life so complicated? Well, there were 5 main reasons.
So, the next series of posts will describe how I got Flash, Powerpoint, ActiveX and other buzzwords to play nicely together. I hope this will prove useful to others who might be crazy enough to try this out – I can definitely see myself doing this again someday.