From 08517ae9bd859b2a01011e8bb39dea2c9f735900 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Sun, 27 Jan 2013 00:41:05 +0000 Subject: [PATCH] md: protect against crash upon fsync on ro array (Closes: #696650) svn path=/dists/sid/linux/; revision=19777 --- debian/changelog | 1 + ...against-crash-upon-fsync-on-ro-array.patch | 35 +++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 37 insertions(+) create mode 100644 debian/patches/bugfix/all/md-protect-against-crash-upon-fsync-on-ro-array.patch diff --git a/debian/changelog b/debian/changelog index 3aca8bdff..30f656b98 100644 --- a/debian/changelog +++ b/debian/changelog @@ -99,6 +99,7 @@ linux (3.2.37-1) UNRELEASED; urgency=low - rewrite punch hole to use ext4_ext_remove_space() - fix hole punch failure when depth is greater than 0 - fix kernel BUG on large-scale rm -rf commands + * md: protect against crash upon fsync on ro array (Closes: #696650) [ Aurelien Jarno ] * [armhf/vexpress] Add kernel udebs. diff --git a/debian/patches/bugfix/all/md-protect-against-crash-upon-fsync-on-ro-array.patch b/debian/patches/bugfix/all/md-protect-against-crash-upon-fsync-on-ro-array.patch new file mode 100644 index 000000000..71de97160 --- /dev/null +++ b/debian/patches/bugfix/all/md-protect-against-crash-upon-fsync-on-ro-array.patch @@ -0,0 +1,35 @@ +From: Sebastian Riemer +Date: Fri, 25 Jan 2013 12:46:59 +0100 +Subject: [PATCH] md: protect against crash upon fsync on ro array +Bug-Debian: http://bugs.debian.org/696650 + +If an fsync occurrs on a read-only array, we need to send a +completion for the IO and may not increment the active IO count. +Otherwise, we hit a bug trace and can't stop the MD array anymore. + +As return value -EROFS makes most sense. + +Signed-off-by: Sebastian Riemer +--- + drivers/md/md.c | 5 +++++ + 1 files changed, 5 insertions(+), 0 deletions(-) + +diff --git a/drivers/md/md.c b/drivers/md/md.c +index 3db3d1b..475e0be 100644 +--- a/drivers/md/md.c ++++ b/drivers/md/md.c +@@ -322,6 +322,11 @@ static void md_make_request(struct request_queue *q, struct bio *bio) + } + finish_wait(&mddev->sb_wait, &__wait); + } ++ if (mddev->ro == 1 && unlikely(rw == WRITE)) { ++ rcu_read_unlock(); ++ bio_endio(bio, -EROFS); ++ return; ++ } + atomic_inc(&mddev->active_io); + rcu_read_unlock(); + +-- +1.7.1 + diff --git a/debian/patches/series b/debian/patches/series index 8cc1fc18d..c277f60df 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -471,3 +471,4 @@ bugfix/all/bridge-Pull-ip-header-into-skb-data-before-looking-i.patch bugfix/all/ext4-rewrite-punch-hole-to-use-ext4_ext_remove_space.patch bugfix/all/ext4-fix-hole-punch-failure-when-depth-is-greater-th.patch bugfix/all/ext4-fix-kernel-BUG-on-large-scale-rm-rf-commands.patch +bugfix/all/md-protect-against-crash-upon-fsync-on-ro-array.patch