Skip to content

Commit 356cb70

Browse files
Darrick J. Wongdchinner
authored andcommitted
xfs: reject unknown xattri log item operation flags during recovery
Make sure we screen the op flags field of recovered xattr intent log items to reject flag bits that we don't know about. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Allison Henderson <[email protected]> Reviewed-by: Dave Chinner <[email protected]> Signed-off-by: Dave Chinner <[email protected]>
1 parent a618aca commit 356cb70

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

fs/xfs/xfs_attr_item.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ xfs_attr_log_item(
349349
*/
350350
attrp = &attrip->attri_format;
351351
attrp->alfi_ino = attr->xattri_da_args->dp->i_ino;
352+
ASSERT(!(attr->xattri_op_flags & ~XFS_ATTR_OP_FLAGS_TYPE_MASK));
352353
attrp->alfi_op_flags = attr->xattri_op_flags;
353354
attrp->alfi_value_len = attr->xattri_da_args->valuelen;
354355
attrp->alfi_name_len = attr->xattri_da_args->namelen;
@@ -496,6 +497,9 @@ xfs_attri_validate(
496497
if (attrp->__pad != 0)
497498
return false;
498499

500+
if (attrp->alfi_op_flags & ~XFS_ATTR_OP_FLAGS_TYPE_MASK)
501+
return false;
502+
499503
/* alfi_op_flags should be either a set or remove */
500504
switch (op) {
501505
case XFS_ATTR_OP_FLAGS_SET:
@@ -556,7 +560,8 @@ xfs_attri_item_recover(
556560
args = (struct xfs_da_args *)(attr + 1);
557561

558562
attr->xattri_da_args = args;
559-
attr->xattri_op_flags = attrp->alfi_op_flags;
563+
attr->xattri_op_flags = attrp->alfi_op_flags &
564+
XFS_ATTR_OP_FLAGS_TYPE_MASK;
560565

561566
args->dp = ip;
562567
args->geo = mp->m_attr_geo;
@@ -567,7 +572,7 @@ xfs_attri_item_recover(
567572
args->attr_filter = attrp->alfi_attr_flags;
568573
args->op_flags = XFS_DA_OP_RECOVERY | XFS_DA_OP_OKNOENT;
569574

570-
switch (attrp->alfi_op_flags & XFS_ATTR_OP_FLAGS_TYPE_MASK) {
575+
switch (attr->xattri_op_flags) {
571576
case XFS_ATTR_OP_FLAGS_SET:
572577
case XFS_ATTR_OP_FLAGS_REPLACE:
573578
args->value = attrip->attri_value;

0 commit comments

Comments
 (0)