]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
omfs: fix sign confusion for bitmap loop counter
authorBob Copeland <me@bobcopeland.com>
Thu, 28 May 2015 22:44:35 +0000 (15:44 -0700)
committerSasha Levin <sasha.levin@oracle.com>
Tue, 9 Jun 2015 17:43:51 +0000 (13:43 -0400)
commit45948a314fb5d29f92b8537dcf54888ed78bcecc
treee7c673728c8234d44551c3fa67b73308c6cf344b
parentce8d4a6371aa570bbe7ecaf618868cc4f6d5b437
omfs: fix sign confusion for bitmap loop counter

[ Upstream commit c0345ee57d461343586b5e1e2f9c3c3766d07fe6 ]

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.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
fs/omfs/inode.c