Skip to contentSkip to conversation

gfs2: fix gfs2_find_jhead that returns uninitialized jhead with seq 0

PATCH New Abhi Das 2 participants 2 messages Feb 4, 2020 GFS2 file system

lore
Share & tools
lore

Abhi Das

author
#0 lore raw

PATCH v2 1/1 gfs2: fix gfs2_find_jhead that returns uninitialized jhead with seq 0

Hi,

This version changes the description as per discussion with Andreas.

Cheers!
--Abhi

When the first log header in a journal happens to have a sequence number of 0, a bug in gfs2_find_jhead() causes it to prematurely exit, and return an uninitialized jhead with seq 0. This can cause failures in the caller. For instance, a mount fails in one test case.

The correct behavior is for it to continue searching through the journal to find the correct journal head with the highest sequence number.

---
 fs/gfs2/lops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/lops.c +1 -1
index d9431724b788..c090d5ad3f22 100644
@@ -422,7 +422,7 @@ static bool gfs2_jhead_pg_srch(struct gfs2_jdesc *jd,
 
 	for (offset = 0; offset < PAGE_SIZE; offset += sdp->sd_sb.sb_bsize) {
 		if (!__get_log_header(sdp, kaddr + offset, 0, &lh)) {
-			if (lh.lh_sequence > head->lh_sequence)
+			if (lh.lh_sequence >= head->lh_sequence)
 				*head = lh;
 			else {
 				ret = true;
Signature · 1 line
2.20.1
#1 lore raw

PATCH v2 1/1 gfs2: fix gfs2_find_jhead that returns uninitialized jhead with seq 0

Hi Abhi,

Quoted 7 lines · Abhi Das

When the first log header in a journal happens to have a sequence number of 0, a bug in gfs2_find_jhead() causes it to prematurely exit, and return an uninitialized jhead with seq 0. This can cause failures in the caller. For instance, a mount fails in one test case.

The correct behavior is for it to continue searching through the journal to find the correct journal head with the highest sequence number.

applied for the next merge window, with a suitable Fixes tag for stable.

Thanks,
Andreas