Skip to content

Commit 85d76ae

Browse files
Darrick J. Wongdchinner
authored andcommitted
xfs: reject unknown xattri log item filter flags during recovery
Make sure we screen the "attr flags" field of recovered xattr intent log items to reject flag bits that we don't know about. This is really the attr *filter* field from xfs_da_args, so rename the field and create a mask to make checking for invalid bits easier. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Dave Chinner <[email protected]> Reviewed-by: Allison Henderson <[email protected]> Signed-off-by: Dave Chinner <[email protected]>
1 parent 356cb70 commit 85d76ae

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

fs/xfs/libxfs/xfs_log_format.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,14 @@ struct xfs_icreate_log {
911911
#define XFS_ATTR_OP_FLAGS_REPLACE 3 /* Replace the attribute */
912912
#define XFS_ATTR_OP_FLAGS_TYPE_MASK 0xFF /* Flags type mask */
913913

914+
/*
915+
* alfi_attr_filter captures the state of xfs_da_args.attr_filter, so it should
916+
* never have any other bits set.
917+
*/
918+
#define XFS_ATTRI_FILTER_MASK (XFS_ATTR_ROOT | \
919+
XFS_ATTR_SECURE | \
920+
XFS_ATTR_INCOMPLETE)
921+
914922
/*
915923
* This is the structure used to lay out an attr log item in the
916924
* log.
@@ -924,7 +932,7 @@ struct xfs_attri_log_format {
924932
uint32_t alfi_op_flags; /* marks the op as a set or remove */
925933
uint32_t alfi_name_len; /* attr name length */
926934
uint32_t alfi_value_len; /* attr value length */
927-
uint32_t alfi_attr_flags;/* attr flags */
935+
uint32_t alfi_attr_filter;/* attr filter flags */
928936
};
929937

930938
struct xfs_attrd_log_format {

fs/xfs/xfs_attr_item.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ xfs_attr_log_item(
353353
attrp->alfi_op_flags = attr->xattri_op_flags;
354354
attrp->alfi_value_len = attr->xattri_da_args->valuelen;
355355
attrp->alfi_name_len = attr->xattri_da_args->namelen;
356-
attrp->alfi_attr_flags = attr->xattri_da_args->attr_filter;
356+
ASSERT(!(attr->xattri_da_args->attr_filter & ~XFS_ATTRI_FILTER_MASK));
357+
attrp->alfi_attr_filter = attr->xattri_da_args->attr_filter;
357358

358359
memcpy(attrip->attri_name, attr->xattri_da_args->name,
359360
attr->xattri_da_args->namelen);
@@ -500,6 +501,9 @@ xfs_attri_validate(
500501
if (attrp->alfi_op_flags & ~XFS_ATTR_OP_FLAGS_TYPE_MASK)
501502
return false;
502503

504+
if (attrp->alfi_attr_filter & ~XFS_ATTRI_FILTER_MASK)
505+
return false;
506+
503507
/* alfi_op_flags should be either a set or remove */
504508
switch (op) {
505509
case XFS_ATTR_OP_FLAGS_SET:
@@ -569,7 +573,7 @@ xfs_attri_item_recover(
569573
args->name = attrip->attri_name;
570574
args->namelen = attrp->alfi_name_len;
571575
args->hashval = xfs_da_hashname(args->name, args->namelen);
572-
args->attr_filter = attrp->alfi_attr_flags;
576+
args->attr_filter = attrp->alfi_attr_filter & XFS_ATTRI_FILTER_MASK;
573577
args->op_flags = XFS_DA_OP_RECOVERY | XFS_DA_OP_OKNOENT;
574578

575579
switch (attr->xattri_op_flags) {
@@ -658,7 +662,7 @@ xfs_attri_item_relog(
658662
new_attrp->alfi_op_flags = old_attrp->alfi_op_flags;
659663
new_attrp->alfi_value_len = old_attrp->alfi_value_len;
660664
new_attrp->alfi_name_len = old_attrp->alfi_name_len;
661-
new_attrp->alfi_attr_flags = old_attrp->alfi_attr_flags;
665+
new_attrp->alfi_attr_filter = old_attrp->alfi_attr_filter;
662666

663667
memcpy(new_attrip->attri_name, old_attrip->attri_name,
664668
new_attrip->attri_name_len);

0 commit comments

Comments
 (0)