* [PATCH RESEND] fs/befs: fix shift-out-of-bounds in befs_check_sb
@ 2023-08-01 15:58 Manas Ghandat
2023-08-13 9:07 ` Manas Ghandat
0 siblings, 1 reply; 2+ messages in thread
From: Manas Ghandat @ 2023-08-01 15:58 UTC (permalink / raw)
To: salah.triki, luisbg
Cc: Manas Ghandat, linux-kernel, Linux-kernel-mentees,
syzbot+fc26c366038b54261e53
The consistency check for the block_size by using the block_shift caused
integer overflow. Thus a max limit to the block_shift was defined named
BEFS_MAX_BLOCK_SHIFT in befs.h. Also check for the block_shift was added
so that overflow does not occur.
Reported-by: syzbot+fc26c366038b54261e53@syzkaller.appspotmail.com
Signed-off-by: Manas Ghandat <ghandatmanas@gmail.com>
---
fs/befs/befs.h | 2 +-
fs/befs/super.c | 11 +++++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/fs/befs/befs.h b/fs/befs/befs.h
index 7cd47245694d..5490024adb33 100644
--- a/fs/befs/befs.h
+++ b/fs/befs/befs.h
@@ -13,7 +13,7 @@
/* used in debug.c */
#define BEFS_VERSION "0.9.3"
-
+#define BEFS_MAX_BLOCK_SHIFT 31
typedef u64 befs_blocknr_t;
/*
diff --git a/fs/befs/super.c b/fs/befs/super.c
index 7c50025c99d8..f2aeb2ed6e77 100644
--- a/fs/befs/super.c
+++ b/fs/befs/super.c
@@ -88,6 +88,17 @@ befs_check_sb(struct super_block *sb)
return BEFS_ERR;
}
+ /*
+ * block_shift check added so that overflow does not
+ * occur during the block_size check
+ */
+
+ if (befs_sb->block_shift > BEFS_MAX_BLOCK_SHIFT) {
+ befs_error(sb, "block_size too large. "
+ "Corruption likely.");
+ return BEFS_ERR;
+ }
+
/*
* block_shift and block_size encode the same information
* in different ways as a consistency check.
--
2.37.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH RESEND] fs/befs: fix shift-out-of-bounds in befs_check_sb
2023-08-01 15:58 [PATCH RESEND] fs/befs: fix shift-out-of-bounds in befs_check_sb Manas Ghandat
@ 2023-08-13 9:07 ` Manas Ghandat
0 siblings, 0 replies; 2+ messages in thread
From: Manas Ghandat @ 2023-08-13 9:07 UTC (permalink / raw)
To: salah.triki, luisbg
Cc: linux-kernel, Linux-kernel-mentees, syzbot+fc26c366038b54261e53
Just a friendly ping :)
On 01/08/23 21:28, Manas Ghandat wrote:
> The consistency check for the block_size by using the block_shift caused
> integer overflow. Thus a max limit to the block_shift was defined named
> BEFS_MAX_BLOCK_SHIFT in befs.h. Also check for the block_shift was added
> so that overflow does not occur.
>
> Reported-by: syzbot+fc26c366038b54261e53@syzkaller.appspotmail.com
>
> Signed-off-by: Manas Ghandat <ghandatmanas@gmail.com>
> ---
> fs/befs/befs.h | 2 +-
> fs/befs/super.c | 11 +++++++++++
> 2 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/fs/befs/befs.h b/fs/befs/befs.h
> index 7cd47245694d..5490024adb33 100644
> --- a/fs/befs/befs.h
> +++ b/fs/befs/befs.h
> @@ -13,7 +13,7 @@
>
> /* used in debug.c */
> #define BEFS_VERSION "0.9.3"
> -
> +#define BEFS_MAX_BLOCK_SHIFT 31
>
> typedef u64 befs_blocknr_t;
> /*
> diff --git a/fs/befs/super.c b/fs/befs/super.c
> index 7c50025c99d8..f2aeb2ed6e77 100644
> --- a/fs/befs/super.c
> +++ b/fs/befs/super.c
> @@ -88,6 +88,17 @@ befs_check_sb(struct super_block *sb)
> return BEFS_ERR;
> }
>
> + /*
> + * block_shift check added so that overflow does not
> + * occur during the block_size check
> + */
> +
> + if (befs_sb->block_shift > BEFS_MAX_BLOCK_SHIFT) {
> + befs_error(sb, "block_size too large. "
> + "Corruption likely.");
> + return BEFS_ERR;
> + }
> +
> /*
> * block_shift and block_size encode the same information
> * in different ways as a consistency check.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-13 9:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-01 15:58 [PATCH RESEND] fs/befs: fix shift-out-of-bounds in befs_check_sb Manas Ghandat
2023-08-13 9:07 ` Manas Ghandat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®