kernel_samsung_a53x/drivers/mtd
ZhaoLong Wang 2ae8b200a7 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: 2ba3d76a1e29 ("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-11-18 12:12:25 +01:00
..
chips mtd: cfi_cmdset_0001: Byte swap OTP info 2024-11-18 11:43:26 +01:00
devices Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hyperbus Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lpddr Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
maps mtd: physmap-core: Restore map_rom fallback 2024-11-08 11:26:18 +01:00
nand mtd: rawnand: Increment IFC_TIMEOUT_MSECS for nand controller response 2024-11-18 12:12:20 +01:00
parsers Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
spi-nor Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tests Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ubi Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ftl.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inftlcore.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inftlmount.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtd_blkdevs.c mtd: Fix gluebi NULL pointer dereference caused by ftl notifier 2024-11-18 12:12:25 +01:00
mtdblock.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdblock_ro.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdchar.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdconcat.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdcore.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdcore.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdoops.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdpart.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdpstore.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdsuper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdswap.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
nftlcore.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
nftlmount.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rfd_ftl.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sm_ftl.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sm_ftl.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ssfdc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00