Go to file
Ned Bass 67629d0f08 Fix rounding discrepancy in sa_find_sizes()
A rounding discrepancy exists between how sa_build_layouts() and
sa_find_sizes() calculate when the spill block needs to be kicked in.
This results in a narrow size range where sa_build_layouts() believes
there must be a spill block allocated but due to the discrepancy there
isn't.  A panic then occurs when the hdl->sa_spill NULL pointer is
dereferenced.

The following reproducer for this bug was isolated:

    truncate -s 128m /tmp/tank
    zpool create tank /tmp/tank
    zfs create -o xattr=sa tank/fish
    ln -s `perl -e 'print "z" x 41'` /tank/fish/z
    setfattr -hn trusted.foo -v`perl -e 'print "z"x45'` /tank/fish/z

This test results in roughly the following system attribute (SA)
layout:

  176 bytes - "standard" SA's
   41 bytes - name of symbolic link target
  100 bytes - XDR encoded nvlist for xattr
  ---
  317 bytes - total

Because 317 is less than DN_MAX_BONUSLEN (320), sa_find_sizes()
decides no spill block is needed. But sa_build_layouts() rounds 41 up
to 48 when computing the space requirements so it tries to switch to
the spill block.

Note that we were only able to reproduce this bug using a combination
of symbolic links and the Linux-specific xattr=sa dataset property.
So while this issue is not technically Linux-specific, it may be
difficult or impossible to hit the narrow size range needed to
reproduce it on other platforms.

To fix the discrepancy, round the running total in sa_find_sizes() up
to an 8-byte boundary before accounting for each SA, since this is how
they will be stored in the bonus and (possibly) spill buffers.

To make the intent of the code more clear, explicitly assert key
assumptions about expected alignment of data and whether spill-over
will occur.

Signed-off-by: Matthew Ahrens <mahrens@delphix.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1240
2013-01-31 10:31:13 -08:00
cmd Retire zpool_id infrastructure 2013-01-29 12:23:17 -08:00
config Remove NPTL_GUARD_WITHIN_STACK 2013-01-29 10:58:20 -08:00
dracut Retire zpool_id infrastructure 2013-01-29 12:23:17 -08:00
etc Retire zpool_id infrastructure 2013-01-29 12:23:17 -08:00
include Retire zpool_id infrastructure 2013-01-29 12:23:17 -08:00
lib Retire zpool_id infrastructure 2013-01-29 12:23:17 -08:00
man Illumos #3035 LZ4 compression support in ZFS and GRUB 2013-01-29 09:28:20 -08:00
module Fix rounding discrepancy in sa_find_sizes() 2013-01-31 10:31:13 -08:00
patches Adding grub2 mkconfig support patch 2012-07-30 16:17:23 -07:00
scripts Retire zpool_id infrastructure 2013-01-29 12:23:17 -08:00
udev Retire zpool_id infrastructure 2013-01-29 12:23:17 -08:00
.gitignore Remove autotools products 2012-09-11 10:15:13 -07:00
AUTHORS Refresh AUTHORS 2012-12-19 09:47:25 -08:00
autogen.sh Remove autotools products 2012-08-27 11:47:44 -07:00
configure.ac Retire zpool_id infrastructure 2013-01-29 12:23:17 -08:00
copy-builtin Consistent menuconfig name 2012-08-26 13:49:37 -07:00
COPYING Relocate COPYING+COPYRIGHT, remove README cruft 2008-12-01 15:34:53 -08:00
COPYRIGHT Update COPYRIGHT to reference zpios CDDL exceptions. 2010-05-18 14:25:28 -07:00
DISCLAIMER Update COPYRIGHT and DISCLAIMER. 2010-05-18 10:32:23 -07:00
dkms.conf.in Support building a zfs-modules-dkms sub package 2012-08-08 15:21:01 -07:00
dkms.postinst Support building a zfs-modules-dkms sub package 2012-08-08 15:21:01 -07:00
Makefile.am Do not use KERNEL_DIR env var in Makefile.am 2012-12-17 09:45:47 -08:00
META ZFS 0.6.0-rc13 2012-12-20 11:02:24 -08:00
OPENSOLARIS.LICENSE Add CDDL license file 2008-12-01 14:49:34 -08:00
PKGBUILD-zfs-modules.in Add make rule for building Arch Linux packages 2011-12-14 19:14:23 -08:00
PKGBUILD-zfs.in Retire zpool_id infrastructure 2013-01-29 12:23:17 -08:00
README.markdown Add script for builtin module building. 2012-07-26 13:45:09 -07:00
zfs-modules.spec.in Cleanly remove zfs-modules-devel headers 2012-08-13 16:35:26 -07:00
zfs-script-config.sh.in Retire zpool_id infrastructure 2013-01-29 12:23:17 -08:00
ZFS.RELEASE Update to onnv_147 2010-08-26 14:24:34 -07:00
zfs.release.in Move zfs.release generation to configure step 2012-07-12 12:22:51 -07:00
zfs.spec.in Retire zpool_id infrastructure 2013-01-29 12:23:17 -08:00

Native ZFS for Linux! ZFS is an advanced file system and volume manager which was originally developed for Solaris. It has been successfully ported to FreeBSD and now there is a functional Linux ZFS kernel port too. The port currently includes a fully functional and stable SPA, DMU, and ZVOL with a ZFS Posix Layer (ZPL) on the way!

$ ./configure
$ make pkg

To copy the kernel code inside your kernel source tree for builtin compilation:

$ ./configure --enable-linux-builtin --with-linux=/usr/src/linux-...
$ ./copy-builtin /usr/src/linux-...

Full documentation for building, configuring, and using ZFS can be found at: http://zfsonlinux.org