During the update process in sa_modify_attrs(), the sizes of existing
variably-sized SA entries are obtained from sa_lengths[]. The case where
a variably-sized SA was being replaced neglected to increment the index
into sa_lengths[], so subsequent variable-length SAs would be rewritten
with the wrong length. This patch adds the missing increment operation
so all variably-sized SA entries are stored with their correct lengths.

Previously, a size-changing update of a variably-sized SA that occurred
when there were other variably-sized SAs in the bonus buffer would cause
the subsequent SAs to be corrupted.  The most common case in which this
would occur is when a mode change caused the ZPL_DACL_ACES entry to
change size when a ZPL_DXATTR (SA xattr) entry already existed.

The following sequence would have caused a failure when xattr=sa was in
force and would corrupt the bonus buffer.  This is a long standing issue
but it was exposed under Linux and FreeBSD where the use of multiple
variable length SAs is common.

    open(filename, O_WRONLY | O_CREAT, 0600);
    ...
    lsetxattr(filename, ...);       /* create xattr SA */
    chmod(filename, 0650);          /* enlarges the ACL */

zfsonlinux/zfs#1978

Signed-off-by: Chris Dunlop <[email protected]>
Signed-off-by: Ned Bass <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
You can view, comment on, or merge this pull request online at:

  https://github.com/openzfs/openzfs/pull/24

-- Commit Summary --

  * Properly handle updates of variably-sized SA entries.

-- File Changes --

    M usr/src/uts/common/fs/zfs/sa.c (17)

-- Patch Links --

https://github.com/openzfs/openzfs/pull/24.patch
https://github.com/openzfs/openzfs/pull/24.diff

---
Reply to this email directly or view it on GitHub:
https://github.com/openzfs/openzfs/pull/24
_______________________________________________
developer mailing list
[email protected]
http://lists.open-zfs.org/mailman/listinfo/developer

Reply via email to