Skip to contentSkip to conversation

f2fs: fix off-by-one error in nat journal entries check

PATCH In review Daniel Axtens 2 participants 2 messages Jan 14, 2023 – Jan 17, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: fix off-by-one error in nat journal entries check

Oops. You're allowed to have up to n = NAT_JOURNAL_ENTRIES entries _inclusive_, because the loop below uses i < n, not i <= n. D'oh.

Fixes 4bd9877f6216 ("fs/f2fs: Do not read past the end of nat journal entries")
---
 grub-core/fs/f2fs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/fs/f2fs.c +1 -1
index df6beb544cbd..855e24618c2b 100644
@@ -650,7 +650,7 @@ get_blkaddr_from_nat_journal (struct grub_f2fs_data *data, grub_uint32_t nid,
   grub_uint16_t n = grub_le_to_cpu16 (data->nat_j.n_nats);
   grub_uint16_t i;
 
-  if (n >= NAT_JOURNAL_ENTRIES)
+  if (n > NAT_JOURNAL_ENTRIES)
     return grub_error (GRUB_ERR_BAD_FS,
                        "invalid number of nat journal entries");
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Daniel Axtens

Oops. You're allowed to have up to n = NAT_JOURNAL_ENTRIES entries _inclusive_, because the loop below uses i < n, not i <= n. D'oh.

Fixes 4bd9877f6216 ("fs/f2fs: Do not read past the end of nat journal entries")

Daniel