From: Akinobu Mita <akinobu.mita@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Akinobu Mita <akinobu.mita@gmail.com>,
"Tigran A. Aivazian" <tigran@aivazian.fsnet.co.uk>,
linux-fsdevel@vger.kernel.org
Subject: [PATCH] bfs: fix bitmap size argument to find_first_zero_bit()
Date: Wed, 2 Mar 2011 20:36:39 +0900 [thread overview]
Message-ID: <1299065799-6289-1-git-send-email-akinobu.mita@gmail.com> (raw)
The usage of find_first_zero_bit() in bfs_create() is wrong for
two reasons.
The bitmap size argument to find_first_zero_bit() is info->si_lasti
but the correct bitmap size is info->si_lasti + 1 as info->si_lasti
is the last valid index in info->si_imap bitmap.
Another problem is that it is impossible to detect that info->si_imap
bitmap is full because there is an off-by-one bug in the return value
check for find_first_zero_bit(). If no zero bits exist in info->si_imap,
find_first_zero_bit() returns info->si_lasti. But the check can't catch it
due to the off-by-one.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: "Tigran A. Aivazian" <tigran@aivazian.fsnet.co.uk>
Cc: linux-fsdevel@vger.kernel.org
---
fs/bfs/dir.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index 685ecff..b14cebf 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -97,7 +97,7 @@ static int bfs_create(struct inode *dir, struct dentry *dentry, int mode,
if (!inode)
return -ENOSPC;
mutex_lock(&info->bfs_lock);
- ino = find_first_zero_bit(info->si_imap, info->si_lasti);
+ ino = find_first_zero_bit(info->si_imap, info->si_lasti + 1);
if (ino > info->si_lasti) {
mutex_unlock(&info->bfs_lock);
iput(inode);
--
1.7.4
reply other threads:[~2011-03-02 11:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1299065799-6289-1-git-send-email-akinobu.mita@gmail.com \
--to=akinobu.mita@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tigran@aivazian.fsnet.co.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).