Skip to contentSkip to conversation

cramfs: fix potential "unable to mount root fs" problem

PATCH In review lizhe 2 participants 3 messages Apr 22, 2021 – Apr 23, 2021 Cramfs filesystem

lore
Share & tools
lore

lizhe

author
#0 lore raw

PATCH 1/1 cramfs: fix potential "unable to mount root fs" problem

We may encounter panic problem without "rootfstype=" options in bootargs. The logs are listed below.

[0.551962] RAMDISK: squashfs filesystem found at block 0
[0.551977] RAMDISK: Loading 18117KiB [1 disk] into ram disk...
[0.719465] done.
[0.748379] VFS: Cannot open root device "ram0" or unknown-block(1,0): error -92
[0.748390] Please append a correct "root=" boot option; here are the available partitions:
[0.748408] 0100           65536 ram0
[0.748413]  (driver?)
[0.748430] 0101           65536 ram1
[0.748434]  (driver?)
[0.748450] 0102
[0.748454]  (driver?)
[0.748470] 0103           65536 ram3
[0.748475]  (driver?)
[0.748498] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0)
[0.847579] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.10.0 #68
[0.847598] Call trace:
[0.847616]  dump_backtrace+0x0/0x1f8
[0.847627]  show_stack+0x30/0x40
[0.847638]  dump_stack+0xdc/0x13c
[0.847650]  panic+0x144/0x35c
[0.847665]  mount_block_root+0x2c0/0x36c
[0.847676]  mount_root+0x7c/0x90
[0.847686]  prepare_namespace+0x178/0x188
[0.847697]  kernel_init_freeable+0x220/0x28c
[0.847708]  kernel_init+0x1c/0xf8
[0.847719]  ret_from_fork+0x10/0x30

If we set CONFIG_CRAMFS_MTD and CONFIG_CRAMFS_BLOCKDEV to n, CONFIG_CRAMFS to y, function cramfs_get_tree return -ENOPROTOOPT, which breaks loops in function mount_block_root and we have no chance to try other filesystem type. In my opinion, ENOPROTOOPT is not an appropriate return value for cramfs mount function, so change it to EINVAL.

Fixes 99c18ce58 (cramfs: direct memory access support)
---
 fs/cramfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cramfs/inode.c +1 -1
index 2be6526..9942955 100644
@@ -951,7 +951,7 @@ static const struct super_operations cramfs_ops = {
 
 static int cramfs_get_tree(struct fs_context *fc)
 {
-	int ret = -ENOPROTOOPT;
+	int ret = -EINVAL;
 
 	if (IS_ENABLED(CONFIG_CRAMFS_MTD)) {
 		ret = get_tree_mtd(fc, cramfs_mtd_fill_super);
Signature · 1 line
2.7.4
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 37 lines · lizhe

We may encounter panic problem without "rootfstype=" options in bootargs. The logs are listed below.

[0.551962] RAMDISK: squashfs filesystem found at block 0
[0.551977] RAMDISK: Loading 18117KiB [1 disk] into ram disk...
[0.719465] done.
[0.748379] VFS: Cannot open root device "ram0" or unknown-block(1,0): error -92
[0.748390] Please append a correct "root=" boot option; here are the available partitions:
[0.748408] 0100           65536 ram0
[0.748413]  (driver?)
[0.748430] 0101           65536 ram1
[0.748434]  (driver?)
[0.748450] 0102
[0.748454]  (driver?)
[0.748470] 0103           65536 ram3
[0.748475]  (driver?)
[0.748498] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0)
[0.847579] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.10.0 #68
[0.847598] Call trace:
[0.847616]  dump_backtrace+0x0/0x1f8
[0.847627]  show_stack+0x30/0x40
[0.847638]  dump_stack+0xdc/0x13c
[0.847650]  panic+0x144/0x35c
[0.847665]  mount_block_root+0x2c0/0x36c
[0.847676]  mount_root+0x7c/0x90
[0.847686]  prepare_namespace+0x178/0x188
[0.847697]  kernel_init_freeable+0x220/0x28c
[0.847708]  kernel_init+0x1c/0xf8
[0.847719]  ret_from_fork+0x10/0x30

If we set CONFIG_CRAMFS_MTD and CONFIG_CRAMFS_BLOCKDEV to n, CONFIG_CRAMFS to y, function cramfs_get_tree return -ENOPROTOOPT, which breaks loops in function mount_block_root and we have no chance to try other filesystem type. In my opinion, ENOPROTOOPT is not an appropriate return value for cramfs mount function, so change it to EINVAL.

Quoted 2 lines
Fixes 99c18ce58 (cramfs: direct memory access support)

Please send this to Al Viro for merging.

Quoted 21 lines
---
 fs/cramfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cramfs/inode.c +1 -1
index 2be6526..9942955 100644
@@ -951,7 +951,7 @@ static const struct super_operations cramfs_ops = {
 
 static int cramfs_get_tree(struct fs_context *fc)
 {
-	int ret = -ENOPROTOOPT;
+	int ret = -EINVAL;
 
 	if (IS_ENABLED(CONFIG_CRAMFS_MTD)) {
 		ret = get_tree_mtd(fc, cramfs_mtd_fill_super);
Signature · 1 line
2.7.4
author
#2 lore raw
Quoted 39 lines · Pitre
Quoted 37 lines · lizhe

We may encounter panic problem without "rootfstype=" options in bootargs. The logs are listed below.

[0.551962] RAMDISK: squashfs filesystem found at block 0
[0.551977] RAMDISK: Loading 18117KiB [1 disk] into ram disk...
[0.719465] done.
[0.748379] VFS: Cannot open root device "ram0" or unknown-block(1,0): error -92
[0.748390] Please append a correct "root=" boot option; here are the available partitions:
[0.748408] 0100           65536 ram0
[0.748413]  (driver?)
[0.748430] 0101           65536 ram1
[0.748434]  (driver?)
[0.748450] 0102
[0.748454]  (driver?)
[0.748470] 0103           65536 ram3
[0.748475]  (driver?)
[0.748498] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0)
[0.847579] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.10.0 #68
[0.847598] Call trace:
[0.847616]  dump_backtrace+0x0/0x1f8
[0.847627]  show_stack+0x30/0x40
[0.847638]  dump_stack+0xdc/0x13c
[0.847650]  panic+0x144/0x35c
[0.847665]  mount_block_root+0x2c0/0x36c
[0.847676]  mount_root+0x7c/0x90
[0.847686]  prepare_namespace+0x178/0x188
[0.847697]  kernel_init_freeable+0x220/0x28c
[0.847708]  kernel_init+0x1c/0xf8
[0.847719]  ret_from_fork+0x10/0x30

If we set CONFIG_CRAMFS_MTD and CONFIG_CRAMFS_BLOCKDEV to n, CONFIG_CRAMFS to y, function cramfs_get_tree return -ENOPROTOOPT, which breaks loops in function mount_block_root and we have no chance to try other filesystem type. In my opinion, ENOPROTOOPT is not an appropriate return value for cramfs mount function, so change it to EINVAL.

Quoted 6 lines
Quoted 2 lines
Fixes 99c18ce58 (cramfs: direct memory access support)

Please send this to Al Viro for merging.

Hi Viro, please review my patch. Thank you.

Quoted 22 lines
Quoted 22 lines
---
 fs/cramfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cramfs/inode.c +1 -1
index 2be6526..9942955 100644
@@ -951,7 +951,7 @@ static const struct super_operations cramfs_ops = {
 
 static int cramfs_get_tree(struct fs_context *fc)
 {
-	int ret = -ENOPROTOOPT;
+	int ret = -EINVAL;
 
 	if (IS_ENABLED(CONFIG_CRAMFS_MTD)) {
 		ret = get_tree_mtd(fc, cramfs_mtd_fill_super);
Signature · 1 line
2.7.4