[PATCHSET v13.1 4/9] xfs: improve extended attribute validation

Darrick J. Wong
2024-04-10T00:45:10Z

Hi all,

Prior to introducing parent pointer extended attributes, let's spend
some time cleaning up the attr code and strengthening the validation
that it performs on attrs coming in from the disk.

If you're going to start using this code, I strongly recommend pulling
from my git trees, which are linked below.

This has been running on the djcloud for months with no problems. Enjoy!
Comments and questions are, as always, welcome.

--D

kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=improve-attr-validation

xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=improve-attr-validation
---
Commits in this patchset:
* xfs: attr fork iext must be loaded before calling xfs_attr_is_leaf
* xfs: require XFS_SB_FEAT_INCOMPAT_LOG_XATTRS for attr log intent item recovery
* xfs: use an XFS_OPSTATE_ flag for detecting if logged xattrs are available
* xfs: check opcode and iovec count match in xlog_recover_attri_commit_pass2
* xfs: fix missing check for invalid attr flags
* xfs: restructure xfs_attr_complete_op a bit
* xfs: use helpers to extract xattr op from opflags
* xfs: validate recovered name buffers when recovering xattr items
* xfs: always set args->value in xfs_attri_item_recover
* xfs: use local variables for name and value length in _attri_commit_pass2
* xfs: refactor name/length checks in xfs_attri_validate
* xfs: enforce one namespace per attribute
---
fs/xfs/libxfs/xfs_attr.c | 41 ++++++++-
fs/xfs/libxfs/xfs_attr.h | 9 ++
fs/xfs/libxfs/xfs_attr_leaf.c | 7 +
fs/xfs/libxfs/xfs_da_format.h | 5 +
fs/xfs/scrub/attr.c | 25 +++--
fs/xfs/scrub/attr_repair.c | 4 -
fs/xfs/xfs_attr_item.c | 192 ++++++++++++++++++++++++++++++++---------
fs/xfs/xfs_attr_list.c | 18 +++-
fs/xfs/xfs_mount.c | 16 +++
fs/xfs/xfs_mount.h | 6 +
fs/xfs/xfs_xattr.c | 3 -
11 files changed, 258 insertions(+), 68 deletions(-)