From: Bob Copeland <me@bobcopeland.com>
To: akpm@linux-foundation.org
Cc: linux-fsdevel@vger.kernel.org, Bob Copeland <me@bobcopeland.com>,
stable@vger.kernel.org
Subject: [PATCH 3/4] omfs: fix sign confusion for bitmap loop counter
Date: Mon, 18 May 2015 07:34:37 -0400 [thread overview]
Message-ID: <1431948878-3756-4-git-send-email-me@bobcopeland.com> (raw)
In-Reply-To: <1431948878-3756-1-git-send-email-me@bobcopeland.com>
The count variable is used to iterate down to (below) zero from the
size of the bitmap and handle the one-filling the remainder of the
last partial bitmap block. The loop conditional expects count to
be signed in order to detect when the final block is processed, after
which count goes negative.
Unfortunately, a recent change made this unsigned along with some other
related fields. The result of is this is that during mount,
omfs_get_imap will overrun the bitmap array and corrupt memory unless
number of blocks happens to be a multiple of 8 * blocksize.
Fix by changing count back to signed: it is guaranteed to fit in an s32
without overflow due to an enforced limit on the number of blocks in the
filesystem.
Cc: stable@vger.kernel.org
Signed-off-by: Bob Copeland <me@bobcopeland.com>
---
fs/omfs/inode.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
index 6ce542c11f98..3d935c81789a 100644
--- a/fs/omfs/inode.c
+++ b/fs/omfs/inode.c
@@ -306,7 +306,8 @@ static const struct super_operations omfs_sops = {
*/
static int omfs_get_imap(struct super_block *sb)
{
- unsigned int bitmap_size, count, array_size;
+ unsigned int bitmap_size, array_size;
+ int count;
struct omfs_sb_info *sbi = OMFS_SB(sb);
struct buffer_head *bh;
unsigned long **ptr;
--
2.1.4
next prev parent reply other threads:[~2015-05-18 11:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-18 11:34 [PATCH 0/4] OMFS fixes Bob Copeland
2015-05-18 11:34 ` [PATCH 1/4] fs, omfs: add NULL terminator in the end up the token list Bob Copeland
2015-05-18 11:34 ` [PATCH 2/4] omfs: set error return when d_make_root() fails Bob Copeland
2015-05-18 11:34 ` Bob Copeland [this message]
2015-05-18 11:34 ` [PATCH 4/4] omfs: fix potential integer overflow in allocator Bob Copeland
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=1431948878-3756-4-git-send-email-me@bobcopeland.com \
--to=me@bobcopeland.com \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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).