linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 3/5] f2fs: fix to avoid NULL pointer dereference
@ 2020-03-25  9:18 Chao Yu
  2020-03-25 15:50 ` Jaegeuk Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2020-03-25  9:18 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, chao, Chao Yu

Unable to handle kernel NULL pointer dereference at virtual address 00000000
PC is at f2fs_free_dic+0x60/0x2c8
LR is at f2fs_decompress_pages+0x3c4/0x3e8
f2fs_free_dic+0x60/0x2c8
f2fs_decompress_pages+0x3c4/0x3e8
__read_end_io+0x78/0x19c
f2fs_post_read_work+0x6c/0x94
process_one_work+0x210/0x48c
worker_thread+0x2e8/0x44c
kthread+0x110/0x120
ret_from_fork+0x10/0x18

In f2fs_free_dic(), we can not use f2fs_put_page(,1) to release dic->tpages[i],
as the page's mapping is NULL.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
v2:
- fix to skip release tpages[i] if it is NULL in error path.
 fs/f2fs/compress.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index ef7dd04312fe..6e10800729b6 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -1137,7 +1137,10 @@ void f2fs_free_dic(struct decompress_io_ctx *dic)
 		for (i = 0; i < dic->cluster_size; i++) {
 			if (dic->rpages[i])
 				continue;
-			f2fs_put_page(dic->tpages[i], 1);
+			if (!dic->tpages[i])
+				continue;
+			unlock_page(dic->tpages[i]);
+			put_page(dic->tpages[i]);
 		}
 		kfree(dic->tpages);
 	}
-- 
2.18.0.rc1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 3/5] f2fs: fix to avoid NULL pointer dereference
  2020-03-25  9:18 [PATCH v2 3/5] f2fs: fix to avoid NULL pointer dereference Chao Yu
@ 2020-03-25 15:50 ` Jaegeuk Kim
  2020-03-26  9:30   ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Jaegeuk Kim @ 2020-03-25 15:50 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-f2fs-devel, linux-kernel, chao

Hi Chao,

I don't want to rebase old commit at this moment, so applied on top of the tree.

Thanks,

On 03/25, Chao Yu wrote:
> Unable to handle kernel NULL pointer dereference at virtual address 00000000
> PC is at f2fs_free_dic+0x60/0x2c8
> LR is at f2fs_decompress_pages+0x3c4/0x3e8
> f2fs_free_dic+0x60/0x2c8
> f2fs_decompress_pages+0x3c4/0x3e8
> __read_end_io+0x78/0x19c
> f2fs_post_read_work+0x6c/0x94
> process_one_work+0x210/0x48c
> worker_thread+0x2e8/0x44c
> kthread+0x110/0x120
> ret_from_fork+0x10/0x18
> 
> In f2fs_free_dic(), we can not use f2fs_put_page(,1) to release dic->tpages[i],
> as the page's mapping is NULL.
> 
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> ---
> v2:
> - fix to skip release tpages[i] if it is NULL in error path.
>  fs/f2fs/compress.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
> index ef7dd04312fe..6e10800729b6 100644
> --- a/fs/f2fs/compress.c
> +++ b/fs/f2fs/compress.c
> @@ -1137,7 +1137,10 @@ void f2fs_free_dic(struct decompress_io_ctx *dic)
>  		for (i = 0; i < dic->cluster_size; i++) {
>  			if (dic->rpages[i])
>  				continue;
> -			f2fs_put_page(dic->tpages[i], 1);
> +			if (!dic->tpages[i])
> +				continue;
> +			unlock_page(dic->tpages[i]);
> +			put_page(dic->tpages[i]);
>  		}
>  		kfree(dic->tpages);
>  	}
> -- 
> 2.18.0.rc1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 3/5] f2fs: fix to avoid NULL pointer dereference
  2020-03-25 15:50 ` Jaegeuk Kim
@ 2020-03-26  9:30   ` Chao Yu
  0 siblings, 0 replies; 3+ messages in thread
From: Chao Yu @ 2020-03-26  9:30 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-f2fs-devel, linux-kernel, chao

Hi Jaegeuk,

I've made that diff as a patch and changed title and commit message a
bit, let's merge the new one.

Thanks,

On 2020/3/25 23:50, Jaegeuk Kim wrote:
> Hi Chao,
> 
> I don't want to rebase old commit at this moment, so applied on top of the tree.
> 
> Thanks,
> 
> On 03/25, Chao Yu wrote:
>> Unable to handle kernel NULL pointer dereference at virtual address 00000000
>> PC is at f2fs_free_dic+0x60/0x2c8
>> LR is at f2fs_decompress_pages+0x3c4/0x3e8
>> f2fs_free_dic+0x60/0x2c8
>> f2fs_decompress_pages+0x3c4/0x3e8
>> __read_end_io+0x78/0x19c
>> f2fs_post_read_work+0x6c/0x94
>> process_one_work+0x210/0x48c
>> worker_thread+0x2e8/0x44c
>> kthread+0x110/0x120
>> ret_from_fork+0x10/0x18
>>
>> In f2fs_free_dic(), we can not use f2fs_put_page(,1) to release dic->tpages[i],
>> as the page's mapping is NULL.
>>
>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>> ---
>> v2:
>> - fix to skip release tpages[i] if it is NULL in error path.
>>  fs/f2fs/compress.c | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
>> index ef7dd04312fe..6e10800729b6 100644
>> --- a/fs/f2fs/compress.c
>> +++ b/fs/f2fs/compress.c
>> @@ -1137,7 +1137,10 @@ void f2fs_free_dic(struct decompress_io_ctx *dic)
>>  		for (i = 0; i < dic->cluster_size; i++) {
>>  			if (dic->rpages[i])
>>  				continue;
>> -			f2fs_put_page(dic->tpages[i], 1);
>> +			if (!dic->tpages[i])
>> +				continue;
>> +			unlock_page(dic->tpages[i]);
>> +			put_page(dic->tpages[i]);
>>  		}
>>  		kfree(dic->tpages);
>>  	}
>> -- 
>> 2.18.0.rc1
> .
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-26  9:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-25  9:18 [PATCH v2 3/5] f2fs: fix to avoid NULL pointer dereference Chao Yu
2020-03-25 15:50 ` Jaegeuk Kim
2020-03-26  9:30   ` Chao Yu

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).