NanoBSD: Create image sparsely

Nick Hibma nick at van-laarhoven.org
Sat Dec 1 22:56:42 UTC 2012


> When copying sparsely, blocks containing zeroes are not copied over but
> skipped using lseek.  When the output file is a newly created regular
> file this is OK because sparse blocks read as zeroes.
> 
> But here nanobsd.sh writes to a md(4) device which does not contain
> zeroes when created as a swap based device (NANO_MD_BACKING=swap).  When
> a file on ${MD}s1 contains a block that deliberately contains zeroes
> the resulting copy is not the same as the original which may cause all
> kinds of problems.  Only when ${MD}s1 is created as a file based device,
> blocks seeked over will read back as zeroes.
> 
> Earlier this month I started a thread on freebsd-security@ related to
> this issue (subject: md(4) (swap-base) disks not cleaned on creation)
> and the patch by Konstantin Belousov will solve this problem but that
> leaves all systems before this patch vulnerable to this problem.

Are you referring to the recent commit that bzero's a page when a new page is created by the pager (instead of an existing one returned)?

Well, if my commit follows that commit (making sure that the MFC does not precede it either) we should be fine. NanoBSD is provided in the FreeBSD source tree.

Nick


More information about the freebsd-embedded mailing list