Comment 5 for bug 144001

Revision history for this message
Colin Watson (cjwatson) wrote :

This is also a kernel bug. The manual page for msync() says:

RETURN VALUE
       On success, zero is returned. On error, -1 is returned, and errno is set appropriately.

Yet here an strace shows:

  msync(0xb630c000, 8564, MS_SYNC) = 524288

This is AOP_WRITEPAGE_ACTIVATE, which include/linux/fs.h says may be returned by writepage() methods on address space mappings. Like some other parts of the kernel, unionfs returns this from its writepage() method. The call chain appears to go like this: sys_msync -> do_fsync -> filemap_fdatawrite -> __filemap_fdatawrite -> __filemap_fdatawrite_range -> do_writepages -> generic_writepages -> write_cache_pages -> __writeback -> unionfs_writepage. When unionfs_writepage returns AOP_WRITEPAGE_ACTIVATE, write_cache_pages does check for this and unlocks the page, but it doesn't sanitise the return code (I don't know exactly where this ought to happen). As a result, that return code wrongly propagates all the way back up to userspace.

It is possible to work around this in apt by simply checking msync() < 0 rather than msync() != 0; I've tested this and 'apt-get update' now works fine. I'll upload this now, which will be good enough for beta.