|
|
80913e |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
80913e |
From: Daniel Axtens <dja@axtens.net>
|
|
|
80913e |
Date: Mon, 18 Jan 2021 16:49:09 +1100
|
|
|
80913e |
Subject: [PATCH] fs/nilfs2: Reject too-large keys
|
|
|
80913e |
|
|
|
80913e |
NILFS2 has up to 7 keys, per the data structure. Do not permit array
|
|
|
80913e |
indices in excess of that.
|
|
|
80913e |
|
|
|
80913e |
This catches some OOB reads. I don't know how controllable the invalidly
|
|
|
80913e |
read data is or if that could be used later in the program.
|
|
|
80913e |
|
|
|
80913e |
Signed-off-by: Daniel Axtens <dja@axtens.net>
|
|
|
80913e |
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
80913e |
---
|
|
|
80913e |
grub-core/fs/nilfs2.c | 7 ++++++-
|
|
|
80913e |
1 file changed, 6 insertions(+), 1 deletion(-)
|
|
|
80913e |
|
|
|
80913e |
diff --git a/grub-core/fs/nilfs2.c b/grub-core/fs/nilfs2.c
|
|
|
80913e |
index 598a2a55baf..61e8af9ff7b 100644
|
|
|
80913e |
--- a/grub-core/fs/nilfs2.c
|
|
|
80913e |
+++ b/grub-core/fs/nilfs2.c
|
|
|
80913e |
@@ -569,6 +569,11 @@ grub_nilfs2_btree_lookup (struct grub_nilfs2_data *data,
|
|
|
80913e |
static inline grub_uint64_t
|
|
|
80913e |
grub_nilfs2_direct_lookup (struct grub_nilfs2_inode *inode, grub_uint64_t key)
|
|
|
80913e |
{
|
|
|
80913e |
+ if (1 + key > 6)
|
|
|
80913e |
+ {
|
|
|
80913e |
+ grub_error (GRUB_ERR_BAD_FS, "key is too large");
|
|
|
80913e |
+ return 0xffffffffffffffff;
|
|
|
80913e |
+ }
|
|
|
80913e |
return grub_le_to_cpu64 (inode->i_bmap[1 + key]);
|
|
|
80913e |
}
|
|
|
80913e |
|
|
|
80913e |
@@ -584,7 +589,7 @@ grub_nilfs2_bmap_lookup (struct grub_nilfs2_data *data,
|
|
|
80913e |
{
|
|
|
80913e |
grub_uint64_t ptr;
|
|
|
80913e |
ptr = grub_nilfs2_direct_lookup (inode, key);
|
|
|
80913e |
- if (need_translate)
|
|
|
80913e |
+ if (ptr != ((grub_uint64_t) 0xffffffffffffffff) && need_translate)
|
|
|
80913e |
ptr = grub_nilfs2_dat_translate (data, ptr);
|
|
|
80913e |
return ptr;
|
|
|
80913e |
}
|