UBIFS: fix oops when R/O file-system is fsync'ed
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Wed, 13 Apr 2011 07:31:52 +0000 (10:31 +0300)
committerBrad Figg <brad.figg@canonical.com>
Wed, 27 Apr 2011 18:42:11 +0000 (11:42 -0700)
commite64c48ee3dc3107bbfca2b2d6c869fc22b0d7720
tree3ed6562d5ef8e5cc3ed1a6dfd511e5dedbac2bcb
parent2d8db61418e095b06048cbbf8a021a593220f0c3
UBIFS: fix oops when R/O file-system is fsync'ed

BugLink: http://bugs.launchpad.net/bugs/769042

commit 78530bf7f2559b317c04991b52217c1608d5a58d upstream.

This patch fixes severe UBIFS bug: UBIFS oopses when we 'fsync()' an
file on R/O-mounter file-system. We (the UBIFS authors) incorrectly
thought that VFS would not propagate 'fsync()' down to the file-system
if it is read-only, but this is not the case.

It is easy to exploit this bug using the following simple perl script:

use strict;
use File::Sync qw(fsync sync);

die "File path is not specified" if not defined $ARGV[0];
my $path = $ARGV[0];

open FILE, "<", "$path" or die "Cannot open $path: $!";
fsync(\*FILE) or die "cannot fsync $path: $!";
close FILE or die "Cannot close $path: $!";

Thanks to Reuben Dowle <Reuben.Dowle@navico.com> for reporting about this
issue.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Reported-by: Reuben Dowle <Reuben.Dowle@navico.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Leann Ogasawara <leann.ogasawara@canonical.com>
fs/ubifs/file.c