All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Sami Liedes <sami.liedes@iki.fi>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: Intentionally corrupted vfat fs causing BUG
Date: Mon, 13 Oct 2014 10:22:31 +0200	[thread overview]
Message-ID: <543B8BC7.1040501@nod.at> (raw)
In-Reply-To: <8761fo7667.fsf@devron.myhome.or.jp>

Am 13.10.2014 um 09:57 schrieb OGAWA Hirofumi:
> Richard Weinberger <richard.weinberger@gmail.com> writes:
> 
>>>
>>> We would need the way how make corrupted image like testimg.vfat.24.min,
>>> to find the cause of this problem. Base image for reproducing this bug,
>>> and way to do are very helpful.
>>
>> You misunderstood Sami's issue. He corrupted the vfat fs intentionally
>> to find issues
>> in the vfat driver.
>> And as he reports he found an nasty issue.
>> Any user can trigger a BUG_ON() using a crafted vfat image.
>> Please note, if you mount exactly the same image using msdos fs the issue
>> does not occur.
> 
> Ah. 
> 
> BTW, msdos doesn't allow ".*" as filename, so not trigger this. But root
> cause of this is same as double linked dir, "." should not
> matter. I.e. this issue would be able to reproduce on all FSes if made
> corrupted image intentionally.
> 
> If we want to fix intentional corruption like this seriously, I guess we
> would need something like online-fsck to detect like double link of
> dir. If we want to avoid only Oops, it might be enough to remove
> BUG_ON().
> 
> I'm still not sure whether this is right direction or not though,
> because mount operation is root only and untrusted image should run fsck
> before. But, also, Oops is clearly unexpected. Hmmm...

This limitation is not true anymore. Plug in a USB stick into a recent Linux desktop,
it will automatically mount it...
Also think of user namespaces and FUSE.

Thanks,
//richard

> Al?
> 
> 
> [PATCH] Avoid Oops on corrupted dir in may_delete()
> 
> Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
> ---
> 
>  fs/namei.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff -puN fs/namei.c~fix-oops-on-corrupted-fs fs/namei.c
> --- linux-3.17/fs/namei.c~fix-oops-on-corrupted-fs	2014-10-13 16:34:28.352999516 +0900
> +++ linux-3.17-hirofumi/fs/namei.c	2014-10-13 16:35:19.196803169 +0900
> @@ -2427,7 +2427,10 @@ static int may_delete(struct inode *dir,
>  		return -ENOENT;
>  	BUG_ON(!inode);
>  
> -	BUG_ON(victim->d_parent->d_inode != dir);
> +	/* Easy check of corrupted dir. */
> +	if (victim->d_parent->d_inode != dir)
> +		return -EBUSY;
> +
>  	audit_inode_child(dir, victim, AUDIT_TYPE_CHILD_DELETE);
>  
>  	error = inode_permission(dir, MAY_WRITE | MAY_EXEC);
> _
> 

  reply	other threads:[~2014-10-13  8:22 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-10 20:57 Intentionally corrupted vfat fs causing BUG Sami Liedes
2014-10-11 10:20 ` Richard Weinberger
2014-10-12 12:08 ` OGAWA Hirofumi
2014-10-12 19:04   ` Richard Weinberger
2014-10-12 20:40     ` Sami Liedes
2014-10-13  7:57     ` OGAWA Hirofumi
2014-10-13  8:22       ` Richard Weinberger [this message]
2014-10-13  8:35         ` OGAWA Hirofumi
2014-10-13  8:39           ` Richard Weinberger
2014-10-13  8:59             ` OGAWA Hirofumi
2014-10-13 14:36               ` Richard Weinberger
2014-10-19 16:36               ` Richard Weinberger
2014-10-23 15:28                 ` OGAWA Hirofumi
2014-10-23 16:01                   ` Al Viro
2014-10-23 16:16                     ` Al Viro
2014-10-23 16:45                       ` OGAWA Hirofumi
2014-10-23 16:50                         ` OGAWA Hirofumi
2014-10-23 16:55                           ` Richard Weinberger
2014-10-23 16:55                         ` Al Viro
2014-10-23 17:21                           ` Al Viro
2014-10-23 17:58                             ` OGAWA Hirofumi
2014-10-23 20:46                             ` Sami Liedes
2014-10-23 17:35                           ` OGAWA Hirofumi
2014-10-23 17:54                           ` J. Bruce Fields
2014-10-23 18:05                             ` Al Viro
2014-10-23 18:16                               ` J. Bruce Fields
2014-10-23 16:56                         ` Al Viro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=543B8BC7.1040501@nod.at \
    --to=richard@nod.at \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=sami.liedes@iki.fi \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.