public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: Gagan Sidhu <broly@mac.com>
Cc: Daniel Golle <daniel@makrotopia.org>,
	Richard Weinberger <richard@nod.at>,
	ZhaoLong Wang <wangzhaolong1@huawei.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	linux-mtd <linux-mtd@lists.infradead.org>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	yangerkun <yangerkun@huawei.com>, yi zhang <yi.zhang@huawei.com>
Subject: Re: [PATCH v2] ubi: gluebi: Fix NULL pointer dereference caused by ftl notifier
Date: Fri, 21 Jun 2024 12:55:16 +0800	[thread overview]
Message-ID: <da6f4aa8-e79d-d70a-eeb5-0068ffc1ef52@huawei.com> (raw)
In-Reply-To: <7558AC97-FFFC-4593-B946-9F8FBD8D62FA@mac.com>

在 2024/6/21 12:27, Gagan Sidhu 写道:
> 
> 
>> On Jun 20, 2024, at 9:03 PM, Zhihao Cheng <chengzhihao1@huawei.com> wrote:
>>
>> 在 2024/6/21 10:09, Gagan Sidhu 写道:
>>> Thanks,
>>> Gagan
>>>> On Jun 20, 2024, at 7:59 PM, Zhihao Cheng <chengzhihao1@huawei.com> wrote:
>>>>
>>>> 在 2024/6/21 6:06, Gagan Sidhu 写道:
>>>>> hi zhihao,
>>>>> so i assume my crude paraphrase is correct? that i may have unintentionally pointed the finger at you, but the real issue is GLUEBI existing with BLOCK on the same volume?
>>>>
>>>> Uhhh, I don't think I mean this. We will make it clear after getting the layers' information about your device.
>>>> Everything goes well from you guys talking, this patch did reject the mtdblock loading from a gluebi device, which may lead booting failed if your rootfs depends on a mtdblock(which is generated from the gluebi device).
>>>>  From your description 'spoke to a user, gave him a build without MTD_GLUEBI, restoring changes made by (HAHAHA you are! huawei), it booted fine'. One thing I'm curious about, if the device boots from the mtdblock(which is generated from gluebi device), the gluebi device won't be generated because you have turned off the CONFIG_MTD_UBI_GLUEBI, then the device boots successfully, which means that your rootfs is most likely loaded from ubiblock0_0. My questions are:
>>>> Q1. According to previous talking, the booting configuration is
>>>> https://github.com/torvalds/linux/blob/master/drivers/mtd/mtdcore.c#L774, why the device could boot from ubiblock0_0?(it looks like that the device uses config from https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/generic/pending-5.15/493-ubi-set-ROOT_DEV-to-ubiblock-rootfs-if-unset.patch;h=266a6331c2acc0f7c17d9ac72f54659d31b56249;hb=HEAD [pointed by Richard]). I'm unfamilar with openwrt(Maybe you and Daniel know much), is that possible the device could automatically choose boot device in the openwrt framework?
>>> yes, that patch will, effectively, allow an “autoselect” of the ubi partition because it looks for the string “rootfs” in the ubi-formatted file.
>>> once it finds the “rootfs” partition, it will rename it to “ubi” and that will be set as the boot/root partition
>>
>> Oh, maybe I know what has happened. According to the configuration of https://github.com/torvalds/linux/blob/master/drivers/mtd/mtdcore.c#L774, openwrt decides to boot rootfs from mtdblock(which is generated from the gluebi device), because the mtd char device (which is genertated from gluebi device) is found by openwrt. However, this patch stops generating mtdblock from gluebi device, so the mounting failed by missed mtdblock. After disabling the CONFIG_MTD_UBI_GLUEBI, the gluebi device is not generated, so openwrt decides to boot rootfs from ubiblock0_0, then your device booted successfully.
>> The key is the rootfs device judgement in openwrt, openwrt chooses the rootfs device according to the existence of mtd char device, openwrt not check whether the corresponding mtdblock exists before mouting it. Should openwrt check the existence of mtdblock beforing using it? Or maybe openwrt could turn to use ubiblock if the mtdblock device is not found?
> 
> as i understand it, the openwrt patch requires the mtdblock device to exist before finding it. it does not rely on gluebi to generate anything.

Yes, openwrt knows nothing under the mtd layer(Whatever the mtd is 
generated by a gluebi device or the mtd is a real physical nand flash). 
I mean, the layers' inforamtion on your device could be(The squashfs 
image is stored in UBI volume ubi0_0.):

                                       ↗ ubiblock0_0
mtdX(nand) -> UBI(holds volume ubi0_0)
                                       ↘ mtd12(gluebi) -> mtdblock12

The openwrt only sees ubiblock0_0, mtd12 and mtdblock12(The ubi0_0 and 
gluebi are not awared by openwrt). The openwrt detects that mtd12 has 
label 'linux,rootfs' in device tree, so it tries mouting mtdblock12 
without checking the existence of mtdblock12.
Could that be possible?

> 
> the mtd char device is not generated from gluebi. openwrt does not use gluebi at all. i was just being paranoid and had too many options enabled.
> 	-however, my paranoia has illuminated an issue with regards to GLUEBI and UBI_BLOCK’s coexistence.
> 
> https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/generic/pending-5.15/400-mtd-mtdsplit-support.patch;h=46ef15d127dfb686e4458fd5838c3eaec8aa2cd7;hb=HEAD
> 
> openwrt relies on device tree, in this case with attribute “fixed-partition” and additional parameter
> openwrt’s split_rootfs_dev merely requires a partition with the label rootfs to be used, and it will automatically create the rootfs (if the splitting criteria) are satisfied.
> 
> split_rootfs_dev requires, as a prerequisite, that there is a partition on the flash that can be “split”. after that, it will rely on ubi to create rootfs for boot.
> 	-i’m a little lazy right now on explaining the details, but trust me it doesn’t need gluebi to create the block device.
> 
> 



______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2024-06-21  4:55 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CFAC276E-E652-40CD-B3D8-563B95E679A8@mac.com>
2024-06-17 14:31 ` [PATCH v2] ubi: gluebi: Fix NULL pointer dereference caused by ftl notifier Richard Weinberger
2024-06-17 15:42 ` Richard Weinberger
     [not found]   ` <14779870-BA54-4ABF-8ABF-FF1D23D172A7@mac.com>
2024-06-17 16:00     ` Richard Weinberger
2024-06-17 16:05       ` Gagan Sidhu
2024-06-17 16:52         ` Richard Weinberger
     [not found]           ` <E3E2C13C-1E52-46F2-BE2D-D2592C3369DB@mac.com>
2024-06-17 17:33             ` Gagan Sidhu
2024-06-17 17:48               ` Gagan Sidhu
2024-06-17 18:09                 ` Richard Weinberger
2024-06-17 18:18                   ` Gagan Sidhu
2024-06-17 18:32                     ` Richard Weinberger
2024-06-17 18:46                       ` Gagan Sidhu
2024-06-17 18:52                         ` Richard Weinberger
2024-06-17 20:29                           ` Daniel Golle
2024-06-17 21:22                             ` Gagan Sidhu
2024-06-17 22:13                               ` Gagan Sidhu
2024-06-18  4:03                                 ` Zhihao Cheng
2024-06-20 22:06                                   ` Gagan Sidhu
2024-06-21  1:59                                     ` Zhihao Cheng
2024-06-21  2:09                                       ` Gagan Sidhu
2024-06-21  3:03                                         ` Zhihao Cheng
2024-06-21  4:27                                           ` Gagan Sidhu
2024-06-21  4:55                                             ` Zhihao Cheng [this message]
2024-06-21 11:36                                               ` Gagan Sidhu
2024-06-22  2:37                                                 ` Zhihao Cheng
2024-06-22  2:43                                                   ` Gagan Sidhu
2024-06-22 21:07                                                     ` Daniel Golle
2024-06-24 19:00                                                       ` Gagan Sidhu
2023-10-18 12:16 ZhaoLong Wang
2023-10-19  1:57 ` Zhihao Cheng
2023-10-19 20:27 ` Richard Weinberger
2023-10-20  2:27   ` Zhihao Cheng
2023-10-21 16:09     ` Richard Weinberger
2023-10-23  6:41       ` ZhaoLong Wang
2023-10-23  6:46         ` Richard Weinberger
2023-10-23  7:12           ` ZhaoLong Wang
2023-10-23  7:16             ` Richard Weinberger
2023-10-23  7:09       ` Zhihao Cheng
2023-10-23  7:15         ` Richard Weinberger
2023-10-23  7:36           ` Zhihao Cheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=da6f4aa8-e79d-d70a-eeb5-0068ffc1ef52@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=broly@mac.com \
    --cc=daniel@makrotopia.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.com \
    --cc=wangzhaolong1@huawei.com \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox