linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yunlong Song <yunlong.song@huawei.com>
To: Chao Yu <yuchao0@huawei.com>, <jaegeuk@kernel.org>,
	<chao@kernel.org>, <yunlong.song@icloud.com>
Cc: <miaoxie@huawei.com>, <bintian.wang@huawei.com>,
	<shengyong1@huawei.com>, <heyunlei@huawei.com>,
	<linux-fsdevel@vger.kernel.org>,
	<linux-f2fs-devel@lists.sourceforge.net>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] fsck.f2fs: check nid range before use to avoid segmentation fault
Date: Sat, 23 Dec 2017 11:35:50 +0800	[thread overview]
Message-ID: <88632fa0-ec8d-ecf0-656f-c52fbfdc9be2@huawei.com> (raw)
In-Reply-To: <e912dbdb-3614-cee0-c7f7-2b5f6344466f@huawei.com>

Both are OK, since nid < root_ino cannot trigger segmentation fault 
(nat_block->entries[nid%NAT_ENTRY_PER_BLOCK]).

On 2017/12/23 11:14, Chao Yu wrote:
> On 2017/12/18 19:53, Yunlong Song wrote:
>> Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
> How about introducing IS_AVAILABLE_NID as below, and use it instead?
>
> #define IS_AVAILABLE_NID(sbi, nid)	(IS_VALID_NID(sbi, nid) && (nid >= root_ino))
>
> Thanks,
>
>> ---
>>   fsck/fsck.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fsck/fsck.c b/fsck/fsck.c
>> index 11b8b0b..faf0663 100644
>> --- a/fsck/fsck.c
>> +++ b/fsck/fsck.c
>> @@ -740,7 +740,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
>>   	for (idx = 0; idx < 5; idx++) {
>>   		u32 nid = le32_to_cpu(node_blk->i.i_nid[idx]);
>>   
>> -		if (nid != 0) {
>> +		if (nid != 0 && IS_VALID_NID(sbi, nid)) {
>>   			struct node_info ni;
>>   
>>   			get_node_info(sbi, nid, &ni);
>>
>
> .
>

-- 
Thanks,
Yunlong Song

      reply	other threads:[~2017-12-23  3:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-15  6:26 [PATCH] fsck.f2fs: check nid range before use to avoid segmentation fault Yunlong Song
2017-12-15 10:06 ` Sheng Yong
2017-12-18 11:53 ` [PATCH v2] " Yunlong Song
2017-12-23  3:14   ` Chao Yu
2017-12-23  3:35     ` Yunlong Song [this message]

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=88632fa0-ec8d-ecf0-656f-c52fbfdc9be2@huawei.com \
    --to=yunlong.song@huawei.com \
    --cc=bintian.wang@huawei.com \
    --cc=chao@kernel.org \
    --cc=heyunlei@huawei.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miaoxie@huawei.com \
    --cc=shengyong1@huawei.com \
    --cc=yuchao0@huawei.com \
    --cc=yunlong.song@icloud.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).