From: Salah Triki <salah.triki@gmail.com>
To: akpm@linux-foundation.org, viro@zeniv.linux.org.uk,
luisbg@osg.samsung.com
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
salah.triki@gmail.com
Subject: [PATCH] befs: return BEFS_ERR if validation of ag_shift fails
Date: Fri, 12 Aug 2016 11:12:31 +0100 [thread overview]
Message-ID: <1470996751-18466-1-git-send-email-salah.triki@gmail.com> (raw)
ag_shift is used by blockno2iaddr() to get allocation group number
from block. If ag_shift is inconsistent with block_per_ag, an out of
bounds allocation group may occur [1]. So add return BEFS_ERR and update
comment and error message to reflect this change.
[1] https://lkml.org/lkml/2016/8/12/42
Signed-off-by: Salah Triki <salah.triki@gmail.com>
---
fs/befs/super.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/fs/befs/super.c b/fs/befs/super.c
index 7c50025..2e3a3fd 100644
--- a/fs/befs/super.c
+++ b/fs/befs/super.c
@@ -101,10 +101,13 @@ befs_check_sb(struct super_block *sb)
/* ag_shift also encodes the same information as blocks_per_ag in a
- * different way, non-fatal consistency check
+ * different way as a consistency check.
*/
- if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
- befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
+ if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag) {
+ befs_error(sb, "ag_shift disagrees with blocks_per_ag. "
+ "Corruption likely.");
+ return BEFS_ERR;
+ }
if (befs_sb->log_start != befs_sb->log_end ||
befs_sb->flags == BEFS_DIRTY) {
--
1.9.1
next reply other threads:[~2016-08-12 10:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-12 10:12 Salah Triki [this message]
2016-08-12 11:00 ` [PATCH] befs: return BEFS_ERR if validation of ag_shift fails Luis de Bethencourt
2016-08-16 7:53 ` Salah Triki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1470996751-18466-1-git-send-email-salah.triki@gmail.com \
--to=salah.triki@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luisbg@osg.samsung.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).