Dear Ted,<br>     Thank you very much for your patient answer. you always Shine a <em>light on me </em>for some new idea.<br><br>    i have tested in domU for protect file writen, but failed. the reason is that each time when i open a file for writting, and save back to the disk. the block number of the file will change. (i use filefrag to see the blocks of a file). but success  from a file for reading, by first get the block number of the file and then save the block number to dom0, each time when the file is read in domU, it will send request to dom0. if i detect the block number is the same to which i saved before, the read operation will be stopped. <br>

     is that the filesystem mechanism to change bock number of a file when written even if the operation is to make the file to smaller than before? <br>     and how could i make the file written protection in the block level when the block number always change?<br>

     Thanks a lot ;)<br><br><div class="gmail_quote">2009/6/4 Theodore Tso <span dir="ltr"><<a href="mailto:tytso@mit.edu">tytso@mit.edu</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div class="im">On Tue, Jun 02, 2009 at 09:29:43PM +0800, Zhang Shukun wrote:<br>
> thanks! your reply it's very useful to me!!<br>
><br>
> yes, it' security purposes! i just trust dom0 , but not trust domU. i want<br>
> to save the blocks of improtant files of domU into dom0, when write<br>
> operation happend in domU, domU will send the request struct , which contain<br>
> the sectors need to write, to dom0, next, in dom0 compare the sector number.<br>
> if the sector numbers is which i want to protect, the write operation will<br>
> be stoped by dom0. even if intruder  get the root privilege in domU, he<br>
> can't change the file (for example :files in /bin dir) which i protected.<br>
<br>
</div>So what I would strongly suggest that you do is to create a userspace<br>
program, using the libext2fs library, which reads an unmounted<br>
filesystem image, and creates a list of block ranges which should be<br>
protected.  This program would be run in dom0, and it would then pass<br>
the block ranges down a device driver which would restrict write<br>
access to the domU guest program.  It will be much simpler than trying<br>
to figure out this information inside the kernel.<br>
<br>
Also, note that you need to restrict more information than just actual<br>
files; you will also need to disallow changes to certain directories.<br>
After all, what use is it to protect the blocks associated with<br>
/lib/libc.so.6, if the attacker can simply modify /lib by replacing<br>
/lib/libc.so.6 with a new file that has modified contents.  And<br>
protecting /lib isn't enough, since the attacker could just modify the<br>
root directory and replace the /lib directory....<br>
<br>
You also have to consider the fact that the attacker could simply<br>
modify the inode table and simply change the blocks which a particular<br>
file is pointing at.  But there are multiple inodes stored in a single<br>
block, so if you protect a block in the inode table, that will be<br>
effectively preventing multiple inodes in the filesystem from being<br>
change, and that might not be desireable depending on what other<br>
inodes are sharing a particular block in the inode table with the file<br>
you are trying to protect.<br>
<br>
The bottom line is what you are trying to do is pretty hard; you are<br>
trying to write protect part of a filesystem from an untrustworthy<br>
root user by restricting write operations on a per-block basis.  This<br>
is an abstraction violation, and when you violate abstractions, you<br>
can expect that (a) things won't be easy, and (b) unless you are very<br>
careful, you might not achieve the goal you were hoping for anyway.<br>
<br>
It might be better, if you really don't trust the domU OS, that you<br>
use a fully write protected block device, plus some kind of union<br>
filesystem.<br>
<br>
                                                - Ted<br>
</blockquote></div><br><br clear="all"><br>-- <br>Regards,<br>Sucan<br>