[3.11.y.z extended stable] Patch "zram: fix race between reset and flushing pending work" has been added to staging queue
Luis Henriques
luis.henriques at canonical.com
Wed Feb 5 13:15:53 UTC 2014
This is a note to let you know that I have just added a patch titled
zram: fix race between reset and flushing pending work
to the linux-3.11.y-queue branch of the 3.11.y.z extended stable tree
which can be found at:
http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.11.y-queue
If you, or anyone else, feels it should not be added to this tree, please
reply to this email.
For more information about the 3.11.y.z tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable
Thanks.
-Luis
------
>From 82af5f24c29a10acade43baa5e1a77ccd77c6a1d Mon Sep 17 00:00:00 2001
From: Minchan Kim <minchan at kernel.org>
Date: Thu, 30 Jan 2014 15:45:58 -0800
Subject: zram: fix race between reset and flushing pending work
commit da4a04126baa3be03bc566d4a2ee0944c5e783d0 upstream.
Dan and Sergey reported that there is a racy between reset and flushing
of pending work so that it could make oops by freeing zram->meta in
reset while zram_slot_free can access zram->meta if new request is
adding during the race window.
This patch moves flush after taking init_lock so it prevents new request
so that it closes the race.
Signed-off-by: Minchan Kim <minchan at kernel.org>
Reported-by: Dan Carpenter <dan.carpenter at oracle.com>
Cc: Nitin Gupta <ngupta at vflare.org>
Cc: Jerome Marchand <jmarchan at redhat.com>
Tested-by: Sergey Senozhatsky <sergey.senozhatsky at gmail.com>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
[ luis: backported to 3.11: zram is still a staging driver in 3.11 ]
Signed-off-by: Luis Henriques <luis.henriques at canonical.com>
---
drivers/staging/zram/zram_drv.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
index dda8771..fc540ea 100644
--- a/drivers/staging/zram/zram_drv.c
+++ b/drivers/staging/zram/zram_drv.c
@@ -551,14 +551,14 @@ static void zram_reset_device(struct zram *zram, bool reset_capacity)
size_t index;
struct zram_meta *meta;
- flush_work(&zram->free_work);
-
down_write(&zram->init_lock);
if (!zram->init_done) {
up_write(&zram->init_lock);
return;
}
+ flush_work(&zram->free_work);
+
meta = zram->meta;
zram->init_done = 0;
--
1.8.3.2
More information about the kernel-team
mailing list