Skip to contentSkip to conversation

Crash with 512 byte blocks on 4K media

PATCH In review One Thousand Gnomes 3 participants 5 messages Jun 2, 2014 – Jun 3, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

A FAT mount of 512 byte block fs on 4K media now crashes. It used to just error. This is of course doubly fun if you've got your own USB key firmware and an automounting distribution 8-)

# mount /dev/sdb /mnt2
[  419.050667] FAT-fs (sdb): logical sector size too small for device
(logical s
ector size = 512)
[  419.051938] BUG: unable to handle kernel NULL pointer dereference at
00000054
[  419.053040] IP: [<c10b63e0>] mount_fs+0x20/0xb0
[  419.053743] *pde = 00000000 
[  419.054207] Oops: 0000 [#1] 
[  419.054671] Modules linked in:
[  419.055160] CPU: 0 PID: 52 Comm: mount Tainted: G          I
3.15.0-rc5-nex
t-20140513+ #58
[  419.056400] task: f6b403f0 ti: f6858000 task.ti: f6858000
[  419.057202] EIP: 0060:[<c10b63e0>] EFLAGS: 00010207 CPU: 0
[  419.058017] EIP is at mount_fs+0x20/0xb0
[  419.058606] EAX: 00000000 EBX: f6b183c0 ECX: 000008e6 EDX: 000008e5
[  419.059534] ESI: 00000000 EDI: c14e80b8 EBP: f6859f14 ESP: f6859ef0
[  419.060461]  DS: 007b ES: 007b FS: 0000 GS: 00e0 SS: 0068
[  419.061263] CR0: 8005003b CR2: 00000054 CR3: 34ecb000 CR4: 00240790
[  419.062190] Stack:
[  419.062504]  00000000 f6b183c0 f6b1844c f6b3a010 f6859f14 c10cb893
f6b183c0 c
14e80b8
[  419.063845]  f6b3a010 f6859f30 c10cba01 00000000 00008000 c14e2540
00000020 c
14e80b8
[  419.065186]  f6859f78 c10ce174 00000000 00008000 c14e80b8 00008000
f6ae8608 f
6b3a010
[  419.066526] Call Trace:
[  419.066904]  [<c10cb893>] ? alloc_vfsmnt+0x83/0x140
[  419.067632]  [<c10cba01>] vfs_kern_mount+0x41/0xe0
[  419.068347]  [<c10ce174>] do_mount+0x1b4/0x8d0
[  419.069013]  [<c1095641>] ? strndup_user+0x31/0xc0
[  419.069728]  [<c10ceb43>] SyS_mount+0x83/0xd0
[  419.070381]  [<c1399ed0>] syscall_call+0x7/0xb
[  419.071046] Code: 01 00 00 00 e8 32 b9 f8 ff 5d c3 55 89 e5 57 89 c7
56 53 8d
 64 24 e8 8b 45 08 89 04 24 8d 07 ff 57 08 3d 00 f0 ff ff 89 c6 77 2e
<8b> 58 54
 85 db 74 32 8b 43 6c 85 c0 74 6a 3d 40 58 4e c1 74 52
[  419.075409] EIP: [<c10b63e0>] mount_fs+0x20/0xb0 SS:ESP 0068:f6859ef0
[  419.076412] CR2: 0000000000000054
[  419.076914] ---[ end trace 6c9f8a78f9e34c70 ]---
maintainer
#1 lore raw
Quoted 3 lines · One Thousand Gnomes

A FAT mount of 512 byte block fs on 4K media now crashes. It used to just error. This is of course doubly fun if you've got your own USB key firmware and an automounting distribution 8-)

This seems to be the bug of recent patch to fatfs. Does the following patch fix this?

Thanks.

Subject: [PATCH] fat: Fix missed error code by "add support for DOS 1.x formatted volumes"

In "add support for DOS 1.x formatted volumes" patch, "error" is overwritten by fat_read_bpb().

This patch reset "error" to -EIO, to return proper error.

---

 fs/fat/inode.c |    1 +
 1 file changed, 1 insertion(+)
fs/fat/inode.c renamed from fs/fat/inode.c~fat-fix-error-handling +1 -0
diff -puN fs/fat/inode.c~fat-fix-error-handling fs/fat/inode.c
@@ -1622,6 +1622,7 @@ int fat_fill_super(struct super_block *s
 	logical_sector_size = bpb.fat_sector_size;
 	sbi->sec_per_clus = bpb.fat_sec_per_clus;
 
+	error = -EIO;
 	if (logical_sector_size < sb->s_blocksize) {
 		fat_msg(sb, KERN_ERR, "logical sector size too small for device"
 		       " (logical sector size = %u)", logical_sector_size);

_

Signature · 1 line
OGAWA Hirofumi <[email protected]>
#2 lore raw
Quoted 37 lines · OGAWA Hirofumi
Quoted 3 lines · One Thousand Gnomes

A FAT mount of 512 byte block fs on 4K media now crashes. It used to just error. This is of course doubly fun if you've got your own USB key firmware and an automounting distribution 8-)

This seems to be the bug of recent patch to fatfs. Does the following patch fix this?

Thanks.

Subject: [PATCH] fat: Fix missed error code by "add support for DOS 1.x formatted volumes"

In "add support for DOS 1.x formatted volumes" patch, "error" is overwritten by fat_read_bpb().

This patch reset "error" to -EIO, to return proper error.

---

 fs/fat/inode.c |    1 +
 1 file changed, 1 insertion(+)

diff -puN fs/fat/inode.c~fat-fix-error-handling fs/fat/inode.c

fs/fat/inode.c 2014-06-03 00:20:08.717435605 +0900 renamed from fs/fat/inode.c~fat-fix-error-handling 2014-06-03 00:20:03.773448083 +0900 +1 -0
@@ -1622,6 +1622,7 @@ int fat_fill_super(struct super_block *s
        logical_sector_size = bpb.fat_sector_size;
        sbi->sec_per_clus = bpb.fat_sec_per_clus;
 
+       error = -EIO;
        if (logical_sector_size < sb->s_blocksize) {
                fat_msg(sb, KERN_ERR, "logical sector size too small for device"
                       " (logical sector size = %u)", logical_sector_size);
Quoted 3 lines

_
--
OGAWA Hirofumi <[email protected]>

Patch LGTM. Apologies for missing this on the first go-around.

Thanks,
Conrad

maintainer
#3 lore raw

PATCH 1/1 fat: Fix missed error code by "add support for DOS 1.x formatted volumes"

Quoted 8 lines
Quoted 4 lines
                       " (logical sector size = %u)", logical_sector_size);

_
--
OGAWA Hirofumi <[email protected]>

Patch LGTM. Apologies for missing this on the first go-around.

Thanks for review.

Please apply the following patch to fix "add support for DOS 1.x formatted volumes" patch.

Thanks.

---
Subject: [PATCH] fat: Fix missed error code by "add support for DOS 1.x formatted volumes"

In "add support for DOS 1.x formatted volumes" patch, "error" is overwritten by fat_read_bpb().

This patch reset "error" to -EIO, to return proper error.

---

 fs/fat/inode.c |    1 +
 1 file changed, 1 insertion(+)
fs/fat/inode.c renamed from fs/fat/inode.c~fat-fix-error-handling +1 -0
diff -puN fs/fat/inode.c~fat-fix-error-handling fs/fat/inode.c
@@ -1622,6 +1622,7 @@ int fat_fill_super(struct super_block *s
 	logical_sector_size = bpb.fat_sector_size;
 	sbi->sec_per_clus = bpb.fat_sec_per_clus;
 
+	error = -EIO;
 	if (logical_sector_size < sb->s_blocksize) {
 		fat_msg(sb, KERN_ERR, "logical sector size too small for device"
 		       " (logical sector size = %u)", logical_sector_size);

_

Signature · 1 line
OGAWA Hirofumi <[email protected]>
author Tested-by Alan Cox on v1 1/1
#4 lore raw

Re: [PATCH] fat: Fix missed error code by "add support for DOS 1.x formatted volumes"

Quoted 5 lines · On Tue, 03 Jun 2014 21:58:47 +0900 OGAWA Hirofumi…
Quoted 5 lines
Quoted 4 lines
                       " (logical sector size = %u)", logical_sector_size);

_
--
OGAWA Hirofumi <[email protected]>

Quoted 8 lines
Quoted 3 lines

Patch LGTM. Apologies for missing this on the first go-around.

Thanks for review.

Please apply the following patch to fix "add support for DOS 1.x formatted volumes" patch