@@ -96,6 +96,11 @@ static int check_dquot_block_header(struct qtree_mem_dqinfo *info,
96
96
err = do_check_range (info -> dqi_sb , "dqdh_prev_free" ,
97
97
le32_to_cpu (dh -> dqdh_prev_free ), 0 ,
98
98
info -> dqi_blocks - 1 );
99
+ if (err )
100
+ return err ;
101
+ err = do_check_range (info -> dqi_sb , "dqdh_entries" ,
102
+ le16_to_cpu (dh -> dqdh_entries ), 0 ,
103
+ qtree_dqstr_in_blk (info ));
99
104
100
105
return err ;
101
106
}
@@ -348,6 +353,10 @@ static int do_insert_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot,
348
353
}
349
354
ref = (__le32 * )buf ;
350
355
newblk = le32_to_cpu (ref [get_index (info , dquot -> dq_id , depth )]);
356
+ ret = do_check_range (dquot -> dq_sb , "block" , newblk , 0 ,
357
+ info -> dqi_blocks - 1 );
358
+ if (ret )
359
+ goto out_buf ;
351
360
if (!newblk )
352
361
newson = 1 ;
353
362
if (depth == info -> dqi_qtree_depth - 1 ) {
@@ -739,15 +748,21 @@ static int find_next_id(struct qtree_mem_dqinfo *info, qid_t *id,
739
748
goto out_buf ;
740
749
}
741
750
for (i = __get_index (info , * id , depth ); i < epb ; i ++ ) {
742
- if (ref [i ] == cpu_to_le32 (0 )) {
751
+ uint blk_no = le32_to_cpu (ref [i ]);
752
+
753
+ if (blk_no == 0 ) {
743
754
* id += level_inc ;
744
755
continue ;
745
756
}
757
+ ret = do_check_range (info -> dqi_sb , "block" , blk_no , 0 ,
758
+ info -> dqi_blocks - 1 );
759
+ if (ret )
760
+ goto out_buf ;
746
761
if (depth == info -> dqi_qtree_depth - 1 ) {
747
762
ret = 0 ;
748
763
goto out_buf ;
749
764
}
750
- ret = find_next_id (info , id , le32_to_cpu ( ref [ i ]) , depth + 1 );
765
+ ret = find_next_id (info , id , blk_no , depth + 1 );
751
766
if (ret != - ENOENT )
752
767
break ;
753
768
}
0 commit comments