android_kernel_xiaomi_sm8450/drivers/mtd
ZhaoLong Wang 001a3f59d8 mtd: Fix gluebi NULL pointer dereference caused by ftl notifier
[ Upstream commit a43bdc376deab5fff1ceb93dca55bcab8dbdc1d6 ]

If both ftl.ko and gluebi.ko are loaded, the notifier of ftl
triggers NULL pointer dereference when trying to access
‘gluebi->desc’ in gluebi_read().

ubi_gluebi_init
  ubi_register_volume_notifier
    ubi_enumerate_volumes
      ubi_notify_all
        gluebi_notify    nb->notifier_call()
          gluebi_create
            mtd_device_register
              mtd_device_parse_register
                add_mtd_device
                  blktrans_notify_add   not->add()
                    ftl_add_mtd         tr->add_mtd()
                      scan_header
                        mtd_read
                          mtd_read_oob
                            mtd_read_oob_std
                              gluebi_read   mtd->read()
                                gluebi->desc - NULL

Detailed reproduction information available at the Link [1],

In the normal case, obtain gluebi->desc in the gluebi_get_device(),
and access gluebi->desc in the gluebi_read(). However,
gluebi_get_device() is not executed in advance in the
ftl_add_mtd() process, which leads to NULL pointer dereference.

The solution for the gluebi module is to run jffs2 on the UBI
volume without considering working with ftl or mtdblock [2].
Therefore, this problem can be avoided by preventing gluebi from
creating the mtdblock device after creating mtd partition of the
type MTD_UBIVOLUME.

Fixes: 2ba3d76a1e ("UBI: make gluebi a separate module")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=217992 [1]
Link: https://lore.kernel.org/lkml/441107100.23734.1697904580252.JavaMail.zimbra@nod.at/ [2]
Signed-off-by: ZhaoLong Wang <wangzhaolong1@huawei.com>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Acked-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20231220024619.2138625-1-wangzhaolong1@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 14:37:41 -08:00
..
chips mtd: cfi_cmdset_0001: Byte swap OTP info 2023-11-28 16:54:58 +00:00
devices mtd: devices: docg3: check the return value of devm_ioremap() in the probe 2022-10-26 13:25:34 +02:00
hyperbus mtd: hyperbus: rpc-if: fix bug in rpcif_hb_remove 2022-01-27 10:53:50 +01:00
lpddr mtd: lpddr2_nvm: Fix possible null-ptr-deref 2023-01-14 10:15:30 +01:00
maps mtd: physmap-core: Restore map_rom fallback 2023-10-25 11:54:24 +02:00
nand mtd: rawnand: Increment IFC_TIMEOUT_MSECS for nand controller response 2024-01-25 14:37:40 -08:00
parsers mtd: parsers: bcm47xxpart: Fix halfblock reads 2022-11-10 18:14:21 +01:00
spi-nor mtd: spi-nor: Check bus width while setting QE bit 2023-09-19 12:20:20 +02:00
tests
ubi ubi: Refuse attaching if mtd's erasesize is 0 2023-10-10 21:53:37 +02:00
ftl.c
inftlcore.c
inftlmount.c
Kconfig
Makefile
mtd_blkdevs.c mtd: Fix gluebi NULL pointer dereference caused by ftl notifier 2024-01-25 14:37:41 -08:00
mtdblock_ro.c
mtdblock.c mtdblock: tolerate corrected bit-flips 2023-04-20 12:10:25 +02:00
mtdchar.c mtd: require write permissions for locking and badblock ioctls 2021-05-14 09:50:13 +02:00
mtdconcat.c mtd: mtdconcat: Check _read, _write callbacks existence before assignment 2021-09-22 12:28:03 +02:00
mtdcore.c mtd: Fix device name leak when register device failed in add_mtd_device() 2023-01-14 10:15:28 +01:00
mtdcore.h
mtdoops.c mtd: mtdoops: Don't write panic data twice 2020-09-07 14:22:12 +02:00
mtdpart.c mtd: Fixed breaking list in __mtd_del_partition. 2022-01-27 10:53:41 +01:00
mtdpstore.c iov_iter: Move unnecessary inclusion of crypto/hash.h 2020-06-30 09:34:23 -04:00
mtdsuper.c
mtdswap.c
nftlcore.c
nftlmount.c
rfd_ftl.c
sm_ftl.c mtd: sm_ftl: Fix deadlock caused by cancel_work_sync in sm_release 2022-08-21 15:15:53 +02:00
sm_ftl.h
ssfdc.c