mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] erofs: fix NULL dereference of dif->bdev_handle in fscache mode
@ 2023-11-14  7:07 Jingbo Xu
  2023-11-14  7:41 ` Gao Xiang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jingbo Xu @ 2023-11-14  7:07 UTC (permalink / raw)
  To: xiang, chao, linux-erofs; +Cc: huyue2, linux-kernel

Avoid NULL dereference of dif->bdev_handle, as dif->bdev_handle is NULL
in fscache mode.

 BUG: kernel NULL pointer dereference, address: 0000000000000000
 RIP: 0010:erofs_map_dev+0xbd/0x1c0
 Call Trace:
  <TASK>
  erofs_fscache_data_read_slice+0xa7/0x340
  erofs_fscache_data_read+0x11/0x30
  erofs_fscache_readahead+0xd9/0x100
  read_pages+0x47/0x1f0
  page_cache_ra_order+0x1e5/0x270
  filemap_get_pages+0xf2/0x5f0
  filemap_read+0xb8/0x2e0
  vfs_read+0x18d/0x2b0
  ksys_read+0x53/0xd0
  do_syscall_64+0x42/0xf0
  entry_SYSCALL_64_after_hwframe+0x6e/0x76

Reported-by: Yiqun Leng <yqleng@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=7245
Fixes: 49845720080d ("erofs: Convert to use bdev_open_by_path()")
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
 fs/erofs/data.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 029c761670bf..c98aeda8abb2 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -220,7 +220,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
 			up_read(&devs->rwsem);
 			return 0;
 		}
-		map->m_bdev = dif->bdev_handle->bdev;
+		map->m_bdev = dif->bdev_handle ? dif->bdev_handle->bdev : NULL;
 		map->m_daxdev = dif->dax_dev;
 		map->m_dax_part_off = dif->dax_part_off;
 		map->m_fscache = dif->fscache;
@@ -238,7 +238,8 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
 			if (map->m_pa >= startoff &&
 			    map->m_pa < startoff + length) {
 				map->m_pa -= startoff;
-				map->m_bdev = dif->bdev_handle->bdev;
+				map->m_bdev = dif->bdev_handle ?
+					      dif->bdev_handle->bdev : NULL;
 				map->m_daxdev = dif->dax_dev;
 				map->m_dax_part_off = dif->dax_part_off;
 				map->m_fscache = dif->fscache;
-- 
2.19.1.6.gb485710b


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

* Re: [PATCH] erofs: fix NULL dereference of dif->bdev_handle in fscache mode
  2023-11-14  7:07 [PATCH] erofs: fix NULL dereference of dif->bdev_handle in fscache mode Jingbo Xu
@ 2023-11-14  7:41 ` Gao Xiang
  2023-11-14  8:14 ` Yue Hu
  2023-11-16  6:12 ` Chao Yu
  2 siblings, 0 replies; 4+ messages in thread
From: Gao Xiang @ 2023-11-14  7:41 UTC (permalink / raw)
  To: Jingbo Xu, xiang, chao, linux-erofs; +Cc: huyue2, linux-kernel



On 2023/11/14 15:07, Jingbo Xu wrote:
> Avoid NULL dereference of dif->bdev_handle, as dif->bdev_handle is NULL
> in fscache mode.
> 
>   BUG: kernel NULL pointer dereference, address: 0000000000000000
>   RIP: 0010:erofs_map_dev+0xbd/0x1c0
>   Call Trace:
>    <TASK>
>    erofs_fscache_data_read_slice+0xa7/0x340
>    erofs_fscache_data_read+0x11/0x30
>    erofs_fscache_readahead+0xd9/0x100
>    read_pages+0x47/0x1f0
>    page_cache_ra_order+0x1e5/0x270
>    filemap_get_pages+0xf2/0x5f0
>    filemap_read+0xb8/0x2e0
>    vfs_read+0x18d/0x2b0
>    ksys_read+0x53/0xd0
>    do_syscall_64+0x42/0xf0
>    entry_SYSCALL_64_after_hwframe+0x6e/0x76
> 
> Reported-by: Yiqun Leng <yqleng@linux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=7245
> Fixes: 49845720080d ("erofs: Convert to use bdev_open_by_path()")
> Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>

Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>

Thanks,
Gao Xiang

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

* Re: [PATCH] erofs: fix NULL dereference of dif->bdev_handle in fscache mode
  2023-11-14  7:07 [PATCH] erofs: fix NULL dereference of dif->bdev_handle in fscache mode Jingbo Xu
  2023-11-14  7:41 ` Gao Xiang
@ 2023-11-14  8:14 ` Yue Hu
  2023-11-16  6:12 ` Chao Yu
  2 siblings, 0 replies; 4+ messages in thread
From: Yue Hu @ 2023-11-14  8:14 UTC (permalink / raw)
  To: Jingbo Xu; +Cc: xiang, chao, linux-erofs, huyue2, linux-kernel

On Tue, 14 Nov 2023 15:07:04 +0800
Jingbo Xu <jefflexu@linux.alibaba.com> wrote:

> Avoid NULL dereference of dif->bdev_handle, as dif->bdev_handle is NULL
> in fscache mode.
> 
>  BUG: kernel NULL pointer dereference, address: 0000000000000000
>  RIP: 0010:erofs_map_dev+0xbd/0x1c0
>  Call Trace:
>   <TASK>
>   erofs_fscache_data_read_slice+0xa7/0x340
>   erofs_fscache_data_read+0x11/0x30
>   erofs_fscache_readahead+0xd9/0x100
>   read_pages+0x47/0x1f0
>   page_cache_ra_order+0x1e5/0x270
>   filemap_get_pages+0xf2/0x5f0
>   filemap_read+0xb8/0x2e0
>   vfs_read+0x18d/0x2b0
>   ksys_read+0x53/0xd0
>   do_syscall_64+0x42/0xf0
>   entry_SYSCALL_64_after_hwframe+0x6e/0x76
> 
> Reported-by: Yiqun Leng <yqleng@linux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=7245
> Fixes: 49845720080d ("erofs: Convert to use bdev_open_by_path()")
> Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>

Reviewed-by: Yue Hu <huyue2@coolpad.com>

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

* Re: [PATCH] erofs: fix NULL dereference of dif->bdev_handle in fscache mode
  2023-11-14  7:07 [PATCH] erofs: fix NULL dereference of dif->bdev_handle in fscache mode Jingbo Xu
  2023-11-14  7:41 ` Gao Xiang
  2023-11-14  8:14 ` Yue Hu
@ 2023-11-16  6:12 ` Chao Yu
  2 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2023-11-16  6:12 UTC (permalink / raw)
  To: Jingbo Xu, xiang, linux-erofs; +Cc: huyue2, linux-kernel

On 2023/11/14 15:07, Jingbo Xu wrote:
> Avoid NULL dereference of dif->bdev_handle, as dif->bdev_handle is NULL
> in fscache mode.
> 
>   BUG: kernel NULL pointer dereference, address: 0000000000000000
>   RIP: 0010:erofs_map_dev+0xbd/0x1c0
>   Call Trace:
>    <TASK>
>    erofs_fscache_data_read_slice+0xa7/0x340
>    erofs_fscache_data_read+0x11/0x30
>    erofs_fscache_readahead+0xd9/0x100
>    read_pages+0x47/0x1f0
>    page_cache_ra_order+0x1e5/0x270
>    filemap_get_pages+0xf2/0x5f0
>    filemap_read+0xb8/0x2e0
>    vfs_read+0x18d/0x2b0
>    ksys_read+0x53/0xd0
>    do_syscall_64+0x42/0xf0
>    entry_SYSCALL_64_after_hwframe+0x6e/0x76
> 
> Reported-by: Yiqun Leng <yqleng@linux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=7245
> Fixes: 49845720080d ("erofs: Convert to use bdev_open_by_path()")
> Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

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

end of thread, other threads:[~2023-11-16  6:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-14  7:07 [PATCH] erofs: fix NULL dereference of dif->bdev_handle in fscache mode Jingbo Xu
2023-11-14  7:41 ` Gao Xiang
2023-11-14  8:14 ` Yue Hu
2023-11-16  6:12 ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®