UBIFS: fix oops when R/O file-system is fsync'ed
commit4f4f117c9b75a3df8bfd552f1c4020a9206fdca5
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Wed, 13 Apr 2011 07:31:52 +0000 (13 10:31 +0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 22 Apr 2011 15:44:17 +0000 (22 08:44 -0700)
treeb1dce568247da6cf9f6b33f80cca57acb5a466d7
parent286ef426e335e89a43e63ee5b8ad129b651f9793
UBIFS: fix oops when R/O file-system is fsync'ed

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>
fs/ubifs/file.c