Avoid the possibility of truncating disk info file
Commit dc8de42 makes nova persist image format to a file to avoid
attacks based on changing it later. However the way it was implemented
leaves a small window of opportunity for the file to be truncated before
it gets written back to effectively making it possible for data to get
lost leaving us with a potential problem next time it is attempted to be
read.
This patch changes the way file is updated to be atomic, thus closing
the race window (and also removes the chown that we did not really
need).
It is worth noting that a better solution to this would be
to allow the code calling the imagebackend to write the file (once!)
and make it impossible to update after the boot process is done. This
approach would require more refactoring of the libvirt driver code, and
may be done in the future.
Reviewed: https:/ /review. openstack. org/86353 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=d416f4310bb 946b4b127201ec3 c37e530d988714
Committed: https:/
Submitter: Jenkins
Branch: master
commit d416f4310bb946b 4b127201ec3c37e 530d988714
Author: Nikola Dipanov <email address hidden>
Date: Wed Apr 9 15:50:20 2014 +0200
Avoid the possibility of truncating disk info file
Commit dc8de42 makes nova persist image format to a file to avoid
attacks based on changing it later. However the way it was implemented
leaves a small window of opportunity for the file to be truncated before
it gets written back to effectively making it possible for data to get
lost leaving us with a potential problem next time it is attempted to be
read.
This patch changes the way file is updated to be atomic, thus closing
the race window (and also removes the chown that we did not really
need).
It is worth noting that a better solution to this would be
to allow the code calling the imagebackend to write the file (once!)
and make it impossible to update after the boot process is done. This
approach would require more refactoring of the libvirt driver code, and
may be done in the future.
Partial-bug: #1221190 89f34d1774a12a1 b4151773fc7
Change-Id: Ia1b073f38e0969