linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* general protection fault in mount_fs
@ 2018-04-05  2:02 syzbot
  2018-05-15 10:08 ` [PATCH] hfsplus: don't return 0 when fill_super() failed Tetsuo Handa
  0 siblings, 1 reply; 5+ messages in thread
From: syzbot @ 2018-04-05  2:02 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel, syzkaller-bugs, viro

Hello,

syzbot hit the following crash on upstream commit
3e968c9f1401088abc9a19ae6ff571644d37a355 (Wed Apr 4 21:19:24 2018 +0000)
Merge tag 'ext4_for_linus' of  
git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
syzbot dashboard link:  
https://syzkaller.appspot.com/bug?extid=01ffaf5d9568dd1609f7

C reproducer: https://syzkaller.appspot.com/x/repro.c?id=6269272955289600
syzkaller reproducer:  
https://syzkaller.appspot.com/x/repro.syz?id=5190169938362368
Raw console output:  
https://syzkaller.appspot.com/x/log.txt?id=5077254979715072
Kernel config:  
https://syzkaller.appspot.com/x/.config?id=9118669095563550941
compiler: gcc (GCC) 7.1.1 20170620

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+01ffaf5d9568dd1609f7@syzkaller.appspotmail.com
It will help syzbot understand when the bug is fixed. See footer for  
details.
If you forward the report, please keep this part and the footer.

hfsplus: failed to load root directory
hfsplus: failed to load root directory
hfsplus: failed to load root directory
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP KASAN
Dumping ftrace buffer:
    (ftrace buffer empty)
Modules linked in:
CPU: 1 PID: 5704 Comm: syzkaller335224 Not tainted 4.16.0+ #15
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011
RIP: 0010:mount_fs+0x92/0x2d0 fs/super.c:1227
RSP: 0018:ffff8801acc9fad0 EFLAGS: 00010202
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff81b2ddaa
RDX: 0000000000000019 RSI: 0000000000000000 RDI: 00000000000000c8
RBP: ffff8801acc9fb00 R08: 1ffff10035993e87 R09: ffffed0035993efc
R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff886b29c0
R13: ffff8801c6243000 R14: ffff8801ac942ac0 R15: 0000000000000000
FS:  00007f8ca5272700(0000) GS:ffff8801db100000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000004c5198 CR3: 00000001af14e000 CR4: 00000000001406e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
  vfs_kern_mount.part.26+0xc6/0x4a0 fs/namespace.c:1037
  vfs_kern_mount fs/namespace.c:2514 [inline]
  do_new_mount fs/namespace.c:2517 [inline]
  do_mount+0xea4/0x2b90 fs/namespace.c:2847
  ksys_mount+0xab/0x120 fs/namespace.c:3063
  SYSC_mount fs/namespace.c:3077 [inline]
  SyS_mount+0x39/0x50 fs/namespace.c:3074
  do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
  entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x44a34a
RSP: 002b:00007f8ca5271d38 EFLAGS: 00000297 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 0000000020000318 RCX: 000000000044a34a
RDX: 0000000020000000 RSI: 0000000020000100 RDI: 00007f8ca5271d50
RBP: 00000000006e39c4 R08: 0000000020000140 R09: 000000000000000a
R10: 0000000000000000 R11: 0000000000000297 R12: 0000000000000003
R13: 0000000000000004 R14: 00000000006e39c0 R15: 0073756c70736668
Code: 3d 00 f0 ff ff 48 89 c3 0f 87 eb 01 00 00 e8 66 c6 be ff 48 8d bb c8  
00 00 00 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00  
0f 85 08 02 00 00 4c 8b b3 c8 00 00 00 4d 85 f6 0f
RIP: mount_fs+0x92/0x2d0 fs/super.c:1227 RSP: ffff8801acc9fad0
---[ end trace 81f30bb7bca06fe8 ]---
Kernel panic - not syncing: Fatal exception
Dumping ftrace buffer:
    (ftrace buffer empty)
Kernel Offset: disabled
Rebooting in 86400 seconds..


---
This bug is generated by a dumb bot. It may contain errors.
See https://goo.gl/tpsmEJ for details.
Direct all questions to syzkaller@googlegroups.com.

syzbot will keep track of this bug report.
If you forgot to add the Reported-by tag, once the fix for this bug is  
merged
into any tree, please reply to this email with:
#syz fix: exact-commit-title
If you want to test a patch for this bug, please reply with:
#syz test: git://repo/address.git branch
and provide the patch inline or as an attachment.
To mark this as a duplicate of another syzbot report, please reply with:
#syz dup: exact-subject-of-another-report
If it's a one-off invalid bug report, please reply with:
#syz invalid
Note: if the crash happens again, it will cause creation of a new bug  
report.
Note: all commands must start from beginning of the line in the email body.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] hfsplus: don't return 0 when fill_super() failed
  2018-04-05  2:02 general protection fault in mount_fs syzbot
@ 2018-05-15 10:08 ` Tetsuo Handa
       [not found]   ` <20180515164221.57cbosgvu6ahslon@eaf>
  2018-06-21  1:45   ` Ernesto A. Fernández
  0 siblings, 2 replies; 5+ messages in thread
From: Tetsuo Handa @ 2018-05-15 10:08 UTC (permalink / raw)
  To: syzbot, syzkaller-bugs, viro; +Cc: linux-fsdevel, linux-kernel

>From f78a5fe168290cb9e009f4d907d04b5bfe277831 Mon Sep 17 00:00:00 2001
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Date: Tue, 15 May 2018 11:38:38 +0900
Subject: [PATCH] hfsplus: don't return 0 when fill_super() failed

syzbot is reporting NULL pointer dereference at mount_fs() [1].
This is because hfsplus_fill_super() is by error returning 0 when
hfsplus_fill_super() detected invalid filesystem image, and mount_bdev()
is returning NULL because dget(s->s_root) == NULL if s->s_root == NULL,
and mount_fs() is accessing root->d_sb because IS_ERR(root) == false
if root == NULL. Fix this by returning -EINVAL when hfsplus_fill_super()
detected invalid filesystem image.

[1] https://syzkaller.appspot.com/bug?id=21acb6850cecbc960c927229e597158cf35f33d0

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reported-by: syzbot <syzbot+01ffaf5d9568dd1609f7@syzkaller.appspotmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/hfsplus/super.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 513c357..9e690ae 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -524,8 +524,10 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
 		goto out_put_root;
 	if (!hfs_brec_read(&fd, &entry, sizeof(entry))) {
 		hfs_find_exit(&fd);
-		if (entry.type != cpu_to_be16(HFSPLUS_FOLDER))
+		if (entry.type != cpu_to_be16(HFSPLUS_FOLDER)) {
+			err = -EINVAL;
 			goto out_put_root;
+		}
 		inode = hfsplus_iget(sb, be32_to_cpu(entry.folder.id));
 		if (IS_ERR(inode)) {
 			err = PTR_ERR(inode);
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hfsplus: don't return 0 when fill_super() failed
       [not found]     ` <201805192255.CAD48427.HLtFMOFVOSOQJF@I-love.SAKURA.ne.jp>
@ 2018-05-19 23:25       ` Ernesto A. Fernández
  2018-05-19 23:47         ` Al Viro
  0 siblings, 1 reply; 5+ messages in thread
From: Ernesto A. Fernández @ 2018-05-19 23:25 UTC (permalink / raw)
  To: Tetsuo Handa
  Cc: ernesto.mnd.fernandez, akpm, viro, syzkaller-bugs,
	syzbot+01ffaf5d9568dd1609f7, linux-fsdevel

On Sat, May 19, 2018 at 10:55:04PM +0900, Tetsuo Handa wrote:
> Ernesto A. Fernandez wrote:
> > On Tue, May 15, 2018 at 07:08:24PM +0900, Tetsuo Handa wrote:
> > > From f78a5fe168290cb9e009f4d907d04b5bfe277831 Mon Sep 17 00:00:00 2001
> > > From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> > > Date: Tue, 15 May 2018 11:38:38 +0900
> > > Subject: [PATCH] hfsplus: don't return 0 when fill_super() failed
> > > 
> > > syzbot is reporting NULL pointer dereference at mount_fs() [1].
> > > This is because hfsplus_fill_super() is by error returning 0 when
> > > hfsplus_fill_super() detected invalid filesystem image, and mount_bdev()
> > > is returning NULL because dget(s->s_root) == NULL if s->s_root == NULL,
> > > and mount_fs() is accessing root->d_sb because IS_ERR(root) == false
> > > if root == NULL. Fix this by returning -EINVAL when hfsplus_fill_super()
> > > detected invalid filesystem image.
> > > 
> > > [1] https://syzkaller.appspot.com/bug?id=21acb6850cecbc960c927229e597158cf35f33d0
> > > 
> > > Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> > > Reported-by: syzbot <syzbot+01ffaf5d9568dd1609f7@syzkaller.appspotmail.com>
> > > Cc: Al Viro <viro@zeniv.linux.org.uk>
> > > ---
> > >  fs/hfsplus/super.c | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
> > > index 513c357..9e690ae 100644
> > > --- a/fs/hfsplus/super.c
> > > +++ b/fs/hfsplus/super.c
> > > @@ -524,8 +524,10 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
> > >  		goto out_put_root;
> > >  	if (!hfs_brec_read(&fd, &entry, sizeof(entry))) {
> > >  		hfs_find_exit(&fd);
> > > -		if (entry.type != cpu_to_be16(HFSPLUS_FOLDER))
> > > +		if (entry.type != cpu_to_be16(HFSPLUS_FOLDER)) {
> > > +			err = -EINVAL;
> > >  			goto out_put_root;
> > > +		}
> > >  		inode = hfsplus_iget(sb, be32_to_cpu(entry.folder.id));
> > >  		if (IS_ERR(inode)) {
> > >  			err = PTR_ERR(inode);
> > > -- 
> > > 1.8.3.1
> > > 
> > > 
> > 
> > I sent this same patch some time ago:
> > 
> > https://www.spinics.net/lists/linux-fsdevel/msg125241.html
> > 
> > This syzbot report did not reach me, though. I don't know why.
> > 
> Oh, I didn't notice that you already wrote that patch.
> Anyway, whom to ask for merge? Al Viro? Andrew Morton?

I think Andrew Morton, but only one of my patches for hfsplus has been
picked up so far, so I can't tell you for sure.

Al Viro wasn't happy with this patchset and thought it was better to let
->put_super() handle the cleanup. I made a second version but I don't
think he had the time to look at it yet.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hfsplus: don't return 0 when fill_super() failed
  2018-05-19 23:25       ` Ernesto A. Fernández
@ 2018-05-19 23:47         ` Al Viro
  0 siblings, 0 replies; 5+ messages in thread
From: Al Viro @ 2018-05-19 23:47 UTC (permalink / raw)
  To: Ernesto A. Fernández
  Cc: Tetsuo Handa, akpm, syzkaller-bugs, syzbot+01ffaf5d9568dd1609f7,
	linux-fsdevel

On Sat, May 19, 2018 at 08:25:04PM -0300, Ernesto A. Fern�ndez wrote:

> > Oh, I didn't notice that you already wrote that patch.
> > Anyway, whom to ask for merge? Al Viro? Andrew Morton?
> 
> I think Andrew Morton, but only one of my patches for hfsplus has been
> picked up so far, so I can't tell you for sure.
> 
> Al Viro wasn't happy with this patchset and thought it was better to let
> ->put_super() handle the cleanup. I made a second version but I don't
> think he had the time to look at it yet.

Sorry, buried under fs/aio.c review (aio-poll stuff) and assorted shite
around mkdir/open-by-handle right now ;-/  I'll get to that tonight or
tomorrow morning.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hfsplus: don't return 0 when fill_super() failed
  2018-05-15 10:08 ` [PATCH] hfsplus: don't return 0 when fill_super() failed Tetsuo Handa
       [not found]   ` <20180515164221.57cbosgvu6ahslon@eaf>
@ 2018-06-21  1:45   ` Ernesto A. Fernández
  1 sibling, 0 replies; 5+ messages in thread
From: Ernesto A. Fernández @ 2018-06-21  1:45 UTC (permalink / raw)
  To: Tetsuo Handa
  Cc: syzbot, syzkaller-bugs, viro, linux-fsdevel, linux-kernel, akpm

On Tue, May 15, 2018 at 07:08:24PM +0900, Tetsuo Handa wrote:
> From f78a5fe168290cb9e009f4d907d04b5bfe277831 Mon Sep 17 00:00:00 2001
> From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> Date: Tue, 15 May 2018 11:38:38 +0900
> Subject: [PATCH] hfsplus: don't return 0 when fill_super() failed
> 
> syzbot is reporting NULL pointer dereference at mount_fs() [1].
> This is because hfsplus_fill_super() is by error returning 0 when
> hfsplus_fill_super() detected invalid filesystem image, and mount_bdev()
> is returning NULL because dget(s->s_root) == NULL if s->s_root == NULL,
> and mount_fs() is accessing root->d_sb because IS_ERR(root) == false
> if root == NULL. Fix this by returning -EINVAL when hfsplus_fill_super()
> detected invalid filesystem image.
> 
> [1] https://syzkaller.appspot.com/bug?id=21acb6850cecbc960c927229e597158cf35f33d0
> 
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> Reported-by: syzbot <syzbot+01ffaf5d9568dd1609f7@syzkaller.appspotmail.com>
> Cc: Al Viro <viro@zeniv.linux.org.uk>

It's been too long. I think I should give up on my patch. Maybe a review
can help your version get merged.

Reviewed-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>

> ---
>  fs/hfsplus/super.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
> index 513c357..9e690ae 100644
> --- a/fs/hfsplus/super.c
> +++ b/fs/hfsplus/super.c
> @@ -524,8 +524,10 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
>  		goto out_put_root;
>  	if (!hfs_brec_read(&fd, &entry, sizeof(entry))) {
>  		hfs_find_exit(&fd);
> -		if (entry.type != cpu_to_be16(HFSPLUS_FOLDER))
> +		if (entry.type != cpu_to_be16(HFSPLUS_FOLDER)) {
> +			err = -EINVAL;
>  			goto out_put_root;
> +		}
>  		inode = hfsplus_iget(sb, be32_to_cpu(entry.folder.id));
>  		if (IS_ERR(inode)) {
>  			err = PTR_ERR(inode);
> -- 
> 1.8.3.1
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-06-21  1:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-05  2:02 general protection fault in mount_fs syzbot
2018-05-15 10:08 ` [PATCH] hfsplus: don't return 0 when fill_super() failed Tetsuo Handa
     [not found]   ` <20180515164221.57cbosgvu6ahslon@eaf>
     [not found]     ` <201805192255.CAD48427.HLtFMOFVOSOQJF@I-love.SAKURA.ne.jp>
2018-05-19 23:25       ` Ernesto A. Fernández
2018-05-19 23:47         ` Al Viro
2018-06-21  1:45   ` Ernesto A. Fernández

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).