From: Quanyang Wang <quanyang.w...@windriver.com>

Hi Bruce,

Would you please help merge this patch to the branches for:
linux-yocto v5.2/standard/base
linux-yocto-dev standard/base

This patch fixes a bug:
when using MMC card with btrfs filesystem to be root device, kernel will crash 
and the log as below:

mmc0: new high speed SDHC card at address aaaa
  #0: DisplayPort monitor
Waiting 5 sec before mounting root device...
mmcblk0: mmc0:aaaa SC32G 29.7 GiB
 mmcblk0: p1 p2 p3 p4
[drm] Cannot find any crtc or sizes
md: Waiting for all devices to be available before autodetect
md: If you don't use raid, use raid=noautodetect
md: Autodetecting RAID arrays.
md: autorun ...
md: ... autorun DONE.
yaffs: dev is 187695107 name is "mmcblk0p3" rw
yaffs: passed flags ""
yaffs: dev is 187695107 name is "mmcblk0p3" rw
yaffs: passed flags ""
------------[ cut here ]------------
kernel BUG at fs/yaffs2/yaffs_getblockinfo.h:30!
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
Modules linked in:
CPU: 3 PID: 1 Comm: swapper/0 Not tainted 5.2.24-yocto-standard+ #250
Hardware name: ZynqMP ZCU102 Rev1.0 (DT)
pstate: 80000005 (Nzcv daif -PAN -UAO)
pc : yaffs_rd_chunk_tags_nand+0xf0/0x110
lr : yaffs_rd_chunk_tags_nand+0x108/0x110
sp : ffffff801003b770
x29: ffffff801003b770 x28: ffffffc876fe8000
x27: 00000000000c0000 x26: 0000000000000000
x25: 00000000ffffffe1 x24: 0000000000010000
x23: 0000000000000000 x22: ffffff8011228000
x21: 000000000000005f x20: ffffff801003b890
x19: ffffffc876fe8000 x18: ffffffffffffffff
x17: 0000000000000000 x16: 0000000000000000
x15: ffffff80112285c8 x14: ffffff801137d228
x13: ffffff801137ce74 x12: ffffff8011246000
x11: 0000000000000000 x10: ffffff801137c000
x9 : 0000000000000000 x8 : 0000000000000007
x7 : 000000000000015c x6 : ffffff801137c490
x5 : 0000000000000000 x4 : 0000000000000000
x3 : 00000000ffffffff x2 : 50c80792e0663400
x1 : 0000000000000000 x0 : 0000000000000037
Call trace:
 yaffs_rd_chunk_tags_nand+0xf0/0x110
 yaffs_summary_read+0x10c/0x2e0
 yaffs2_scan_backwards+0x28c/0xf58
 yaffs_guts_initialise+0x71c/0x7a0
 yaffs_internal_read_super.isra.20+0x4ec/0x838
 yaffs2_internal_read_super_mtd+0x2c/0x48
 mount_bdev+0x1a4/0x1e0
 yaffs2_mount+0x44/0x58
 legacy_get_tree+0x34/0x60
 vfs_get_tree+0x34/0x120
 do_mount+0x708/0x980
 ksys_mount+0x9c/0x110
 mount_block_root+0x128/0x29c
 mount_root+0x148/0x17c
 prepare_namespace+0x178/0x1c0
 kernel_init_freeable+0x370/0x390
 kernel_init+0x18/0x110
 ret_from_fork+0x10/0x1c
Code: d65f03c0 f00069c0 b9440400 37f00060 (d4210000)
---[ end trace 68aa0995bdf59f76 ]---
BUG: sleeping function called from invalid context at 
./include/linux/percpu-rwsem.h:34
in_atomic(): 1, irqs_disabled(): 128, pid: 1, name: swapper/0
Preemption disabled at:
[<ffffff80100a4598>] debug_exception_enter+0x30/0x40
CPU: 3 PID: 1 Comm: swapper/0 Tainted: G      D           
5.2.24-yocto-standard+ #250
Hardware name: ZynqMP ZCU102 Rev1.0 (DT)
Call trace:
 dump_backtrace+0x0/0x148
 show_stack+0x24/0x30
 dump_stack+0x98/0xbc
 ___might_sleep+0x130/0x188
 __might_sleep+0x58/0x90
 exit_signals+0x44/0x258
 do_exit+0xb4/0xa38
 die+0x1bc/0x1e0
 bug_handler+0x48/0x98
 call_break_hook+0x7c/0xa8
 brk_handler+0x28/0x68
 do_debug_exception+0xc4/0x188
 el1_dbg+0x18/0x8c
 yaffs_rd_chunk_tags_nand+0xf0/0x110
 yaffs_summary_read+0x10c/0x2e0
 yaffs2_scan_backwards+0x28c/0xf58
 yaffs_guts_initialise+0x71c/0x7a0
 yaffs_internal_read_super.isra.20+0x4ec/0x838
 yaffs2_internal_read_super_mtd+0x2c/0x48
 mount_bdev+0x1a4/0x1e0
 yaffs2_mount+0x44/0x58
 legacy_get_tree+0x34/0x60
 vfs_get_tree+0x34/0x120
 do_mount+0x708/0x980
 ksys_mount+0x9c/0x110
 mount_block_root+0x128/0x29c
 mount_root+0x148/0x17c
 prepare_namespace+0x178/0x1c0
 kernel_init_freeable+0x370/0x390
 kernel_init+0x18/0x110
 ret_from_fork+0x10/0x1c
note: swapper/0[1] exited with preempt_count 1
Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
SMP: stopping secondary CPUs
Kernel Offset: disabled
CPU features: 0x0002,20002004
Memory Limit: none
---[ end Kernel panic - not syncing: Attempted to kill init! 
exitcode=0x0000000b ]---


Quanyang Wang (1):
  yaffs: add strict check when call yaffs_internal_read_super

 fs/yaffs2/yaffs_mtdif.c | 12 ++++++++++--
 fs/yaffs2/yaffs_vfs.c   |  7 ++-----
 2 files changed, 12 insertions(+), 7 deletions(-)

-- 
2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#8147): 
https://lists.yoctoproject.org/g/linux-yocto/message/8147
Mute This Topic: https://lists.yoctoproject.org/mt/65655255/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to