@@ -734,6 +734,46 @@ const struct xfs_defer_op_type xfs_attr_defer_type = {
734
734
.relog_intent = xfs_attr_relog_intent ,
735
735
};
736
736
737
+ static inline void *
738
+ xfs_attri_validate_name_iovec (
739
+ struct xfs_mount * mp ,
740
+ struct xfs_attri_log_format * attri_formatp ,
741
+ const struct xfs_log_iovec * iovec ,
742
+ unsigned int name_len )
743
+ {
744
+ if (iovec -> i_len != xlog_calc_iovec_len (name_len )) {
745
+ XFS_CORRUPTION_ERROR (__func__ , XFS_ERRLEVEL_LOW , mp ,
746
+ attri_formatp , sizeof (* attri_formatp ));
747
+ return NULL ;
748
+ }
749
+
750
+ if (!xfs_attr_namecheck (iovec -> i_addr , name_len )) {
751
+ XFS_CORRUPTION_ERROR (__func__ , XFS_ERRLEVEL_LOW , mp ,
752
+ attri_formatp , sizeof (* attri_formatp ));
753
+ XFS_CORRUPTION_ERROR (__func__ , XFS_ERRLEVEL_LOW , mp ,
754
+ iovec -> i_addr , iovec -> i_len );
755
+ return NULL ;
756
+ }
757
+
758
+ return iovec -> i_addr ;
759
+ }
760
+
761
+ static inline void *
762
+ xfs_attri_validate_value_iovec (
763
+ struct xfs_mount * mp ,
764
+ struct xfs_attri_log_format * attri_formatp ,
765
+ const struct xfs_log_iovec * iovec ,
766
+ unsigned int value_len )
767
+ {
768
+ if (iovec -> i_len != xlog_calc_iovec_len (value_len )) {
769
+ XFS_CORRUPTION_ERROR (__func__ , XFS_ERRLEVEL_LOW , mp ,
770
+ attri_formatp , sizeof (* attri_formatp ));
771
+ return NULL ;
772
+ }
773
+
774
+ return iovec -> i_addr ;
775
+ }
776
+
737
777
STATIC int
738
778
xlog_recover_attri_commit_pass2 (
739
779
struct xlog * log ,
@@ -798,30 +838,18 @@ xlog_recover_attri_commit_pass2(
798
838
i ++ ;
799
839
800
840
/* Validate the attr name */
801
- if (item -> ri_buf [i ].i_len != xlog_calc_iovec_len (name_len )) {
802
- XFS_CORRUPTION_ERROR (__func__ , XFS_ERRLEVEL_LOW , mp ,
803
- attri_formatp , len );
804
- return - EFSCORRUPTED ;
805
- }
806
-
807
- attr_name = item -> ri_buf [i ].i_addr ;
808
- if (!xfs_attr_namecheck (attr_name , name_len )) {
809
- XFS_CORRUPTION_ERROR (__func__ , XFS_ERRLEVEL_LOW , mp ,
810
- attri_formatp , len );
841
+ attr_name = xfs_attri_validate_name_iovec (mp , attri_formatp ,
842
+ & item -> ri_buf [i ], name_len );
843
+ if (!attr_name )
811
844
return - EFSCORRUPTED ;
812
- }
813
845
i ++ ;
814
846
815
847
/* Validate the attr value, if present */
816
848
if (value_len != 0 ) {
817
- if (item -> ri_buf [i ].i_len != xlog_calc_iovec_len (value_len )) {
818
- XFS_CORRUPTION_ERROR (__func__ , XFS_ERRLEVEL_LOW , mp ,
819
- item -> ri_buf [0 ].i_addr ,
820
- item -> ri_buf [0 ].i_len );
849
+ attr_value = xfs_attri_validate_value_iovec (mp , attri_formatp ,
850
+ & item -> ri_buf [i ], value_len );
851
+ if (!attr_value )
821
852
return - EFSCORRUPTED ;
822
- }
823
-
824
- attr_value = item -> ri_buf [i ].i_addr ;
825
853
i ++ ;
826
854
}
827
855
0 commit comments