From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt0-f195.google.com ([209.85.216.195]:33528 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754093AbeFUBqC (ORCPT ); Wed, 20 Jun 2018 21:46:02 -0400 Date: Wed, 20 Jun 2018 22:45:56 -0300 From: Ernesto =?utf-8?Q?A=2E_Fern=C3=A1ndez?= To: Tetsuo Handa Cc: syzbot , syzkaller-bugs@googlegroups.com, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Subject: Re: [PATCH] hfsplus: don't return 0 when fill_super() failed Message-ID: <20180621014555.4ul7w7wwkzbeifr6@eaf> References: <001a114467485371b605691053fc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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 > 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 > Reported-by: syzbot > Cc: Al Viro 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 > --- > 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 > >