Skip to content

Commit b853b4f

Browse files
committed
Report InnoDB redo log corruption better
recv_parse_log_recs(): Check for corruption before checking for end-of-log-buffer. mlog_parse_initial_log_record(), page_cur_parse_delete_rec(): Flag corruption for out-of-bounds values, and let the caller dump the corrupted redo log extract.
1 parent 0e15ae1 commit b853b4f

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

storage/innobase/log/log0recv.cc

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,7 +2251,6 @@ recv_parse_log_rec(
22512251
*type, new_ptr, end_ptr, *space, *page_no, apply, NULL, NULL);
22522252

22532253
if (UNIV_UNLIKELY(new_ptr == NULL)) {
2254-
22552254
return(0);
22562255
}
22572256

@@ -2402,20 +2401,19 @@ bool recv_parse_log_recs(lsn_t checkpoint_lsn, store_t store, bool apply)
24022401
len = recv_parse_log_rec(&type, ptr, end_ptr, &space,
24032402
&page_no, apply, &body);
24042403

2405-
if (len == 0) {
2406-
return(false);
2407-
}
2408-
24092404
if (recv_sys->found_corrupt_log) {
2410-
recv_report_corrupt_log(
2411-
ptr, type, space, page_no);
2405+
recv_report_corrupt_log(ptr, type, space, page_no);
24122406
return(true);
24132407
}
24142408

24152409
if (recv_sys->found_corrupt_fs) {
24162410
return(true);
24172411
}
24182412

2413+
if (len == 0) {
2414+
return(false);
2415+
}
2416+
24192417
new_recovered_lsn = recv_calc_lsn_on_data_add(old_lsn, len);
24202418

24212419
if (new_recovered_lsn > recv_sys->scanned_lsn) {
@@ -2542,10 +2540,6 @@ bool recv_parse_log_recs(lsn_t checkpoint_lsn, store_t store, bool apply)
25422540
&type, ptr, end_ptr, &space, &page_no,
25432541
false, &body);
25442542

2545-
if (len == 0) {
2546-
return(false);
2547-
}
2548-
25492543
if (recv_sys->found_corrupt_log
25502544
|| type == MLOG_CHECKPOINT
25512545
|| (*ptr & MLOG_SINGLE_REC_FLAG)) {
@@ -2559,6 +2553,10 @@ bool recv_parse_log_recs(lsn_t checkpoint_lsn, store_t store, bool apply)
25592553
return(true);
25602554
}
25612555

2556+
if (len == 0) {
2557+
return(false);
2558+
}
2559+
25622560
recv_previous_parsed_rec_type = type;
25632561
recv_previous_parsed_rec_offset
25642562
= recv_sys->recovered_offset + total_len;

storage/innobase/mtr/mtr0log.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ mlog_parse_initial_log_record(
9898
}
9999

100100
*type = mlog_id_t(*ptr & ~MLOG_SINGLE_REC_FLAG);
101-
ut_ad(*type <= MLOG_BIGGEST_TYPE || EXTRA_CHECK_MLOG_NUMBER(*type));
101+
if (UNIV_UNLIKELY(*type > MLOG_BIGGEST_TYPE
102+
&& !EXTRA_CHECK_MLOG_NUMBER(*type))) {
103+
recv_sys->found_corrupt_log = true;
104+
return NULL;
105+
}
102106

103107
ptr++;
104108

storage/innobase/page/page0cur.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2250,7 +2250,10 @@ page_cur_parse_delete_rec(
22502250
offset = mach_read_from_2(ptr);
22512251
ptr += 2;
22522252

2253-
ut_a(offset <= UNIV_PAGE_SIZE);
2253+
if (UNIV_UNLIKELY(offset >= srv_page_size)) {
2254+
recv_sys->found_corrupt_log = true;
2255+
return NULL;
2256+
}
22542257

22552258
if (block) {
22562259
page_t* page = buf_block_get_frame(block);

0 commit comments

Comments
 (0)