diff options
author | Chao Yu <yuchao0@huawei.com> | 2020-03-23 10:43:04 +0100 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2020-03-31 05:46:25 +0200 |
commit | 79bbefb19f1359fb2cbd144d5a054649e7e583be (patch) | |
tree | 26a75c709f304b8ba73f135a0741abf15549b6b0 /fs/f2fs/compress.c | |
parent | f2fs: fix to clear PG_error if fsverity failed (diff) | |
download | linux-79bbefb19f1359fb2cbd144d5a054649e7e583be.tar.xz linux-79bbefb19f1359fb2cbd144d5a054649e7e583be.zip |
f2fs: fix NULL pointer dereference in f2fs_verity_work()
If both compression and fsverity feature is on, generic/572 will
report below NULL pointer dereference bug.
BUG: kernel NULL pointer dereference, address: 0000000000000018
RIP: 0010:f2fs_verity_work+0x60/0x90 [f2fs]
#PF: supervisor read access in kernel mode
Workqueue: fsverity_read_queue f2fs_verity_work [f2fs]
RIP: 0010:f2fs_verity_work+0x60/0x90 [f2fs]
Call Trace:
process_one_work+0x16c/0x3f0
worker_thread+0x4c/0x440
? rescuer_thread+0x350/0x350
kthread+0xf8/0x130
? kthread_unpark+0x70/0x70
ret_from_fork+0x35/0x40
There are two issue in f2fs_verity_work():
- it needs to traverse and verify all pages in bio.
- if pages in bio belong to non-compressed cluster, accessing
decompress IO context stored in page private will cause NULL
pointer dereference.
Fix them.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/compress.c')
-rw-r--r-- | fs/f2fs/compress.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index d66d372d104d..adac6fcb2830 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -477,6 +477,8 @@ out_vunmap_cbuf: out_vunmap_rbuf: vunmap(dic->rbuf); out_free_dic: + if (verity) + refcount_add(dic->nr_cpages - 1, &dic->ref); if (!verity) f2fs_decompress_end_io(dic->rpages, dic->cluster_size, ret, false); |