Skip to contentSkip to conversation

exfat: Fix pontential use after free in exfat_load_upcase_table()

PATCH Applied Dan Carpenter 2 participants 2 messages Jun 8, 2020 – Jun 9, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 exfat: Fix pontential use after free in exfat_load_upcase_table()

This code calls brelse(bh) and then dereferences "bh" on the next line resulting in a possible use after free. The brelse() should just be moved down a line.

Fixes b676fdbcf4c8 ("exfat: standardize checksum calculation")
---
 fs/exfat/nls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/exfat/nls.c +1 -1
index c1ec056954974..57b5a7a4d1f7a 100644
@@ -692,8 +692,8 @@ static int exfat_load_upcase_table(struct super_block *sb,
 				index++;
 			}
 		}
-		brelse(bh);
 		chksum = exfat_calc_chksum32(bh->b_data, i, chksum, CS_DEFAULT);
+		brelse(bh);
 	}
 
 	if (index >= 0xFFFF && utbl_checksum = chksum)
Signature · 1 line
2.26.2
Applied
#1 lore raw
Quoted 5 lines

This code calls brelse(bh) and then dereferences "bh" on the next line resulting in a possible use after free. The brelse() should just be moved down a line.

Fixes b676fdbcf4c8 ("exfat: standardize checksum calculation")

Applied. Thanks!

Quoted 19 lines
---
 fs/exfat/nls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/exfat/nls.c +1 -2
@@ -692,8 +692,8 @@ static int exfat_load_upcase_table(struct super_block *sb,
 				index++;
 			}
 		}
-		brelse(bh);
 		chksum = exfat_calc_chksum32(bh->b_data, i, chksum, CS_DEFAULT);
+		brelse(bh);
 	}
 
 	if (index >= 0xFFFF && utbl_checksum = chksum)
--

2.26.2