From: Jaegeuk Kim <jaegeuk.kim@samsung.com>
To: Namjae Jeon <linkinjeon@gmail.com>
Cc: linux-f2fs-devel@lists.sourceforge.net,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Namjae Jeon <namjae.jeon@samsung.com>,
Amit Sahrawat <a.sahrawat@samsung.com>
Subject: Re: [PATCH 5/5] f2fs: avoid BUG_ON from check_nid_range and update return path in do_read_inode
Date: Mon, 18 Mar 2013 11:19:33 +0900 [thread overview]
Message-ID: <1363573173.14386.70.camel@kjgkr> (raw)
In-Reply-To: <1363508840-2954-1-git-send-email-linkinjeon@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1969 bytes --]
2013-03-17 (일), 17:27 +0900, Namjae Jeon:
> From: Namjae Jeon <namjae.jeon@samsung.com>
>
> In function check_nid_range, there is no need to trigger BUG_ON and make kernel stop.
> Instead it could just check and indicate the inode number to be EINVAL.
> Update the return path in do_read_inode to use the return from check_nid_range.
>
> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
> Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
> ---
> fs/f2fs/f2fs.h | 6 ++++--
> fs/f2fs/inode.c | 6 +++++-
> 2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index be7ae70..1dae921 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -515,9 +515,11 @@ static inline void mutex_unlock_op(struct f2fs_sb_info *sbi, enum lock_type t)
> /*
> * Check whether the given nid is within node id range.
> */
> -static inline void check_nid_range(struct f2fs_sb_info *sbi, nid_t nid)
> +static inline int check_nid_range(struct f2fs_sb_info *sbi, nid_t nid)
> {
> - BUG_ON((nid >= NM_I(sbi)->max_nid));
> + if (nid >= NM_I(sbi)->max_nid)
> + return -EINVAL;
> + return 0;
At this moment, I'd like to apply this patch and remain BUG_ON together
since we should find real bugs in f2fs.
How do you think?
> }
>
> #define F2FS_DEFAULT_ALLOCATED_BLOCKS 1
> diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
> index ddae412..6d82020 100644
> --- a/fs/f2fs/inode.c
> +++ b/fs/f2fs/inode.c
> @@ -44,7 +44,11 @@ static int do_read_inode(struct inode *inode)
> struct f2fs_inode *ri;
>
> /* Check if ino is within scope */
> - check_nid_range(sbi, inode->i_ino);
> + if (check_nid_range(sbi, inode->i_ino)) {
> + f2fs_msg(inode->i_sb, KERN_ERR, "bad inode number: %lu",
> + (unsigned long) inode->i_ino);
> + return -EINVAL;
> + }
>
> node_page = get_node_page(sbi, inode->i_ino);
> if (IS_ERR(node_page))
--
Jaegeuk Kim
Samsung
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2013-03-18 2:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-17 8:27 [PATCH 5/5] f2fs: avoid BUG_ON from check_nid_range and update return path in do_read_inode Namjae Jeon
2013-03-18 2:19 ` Jaegeuk Kim [this message]
2013-03-18 5:23 ` Namjae Jeon
2013-03-18 5:40 ` Jaegeuk Kim
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=1363573173.14386.70.camel@kjgkr \
--to=jaegeuk.kim@samsung.com \
--cc=a.sahrawat@samsung.com \
--cc=linkinjeon@gmail.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=namjae.jeon@samsung.com \
/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).