Patchwork [3.5.y.z,extended,stable] Patch "drivers/block/brd.c: fix brd_lookup_page() race" has been added to staging queue

mail settings
Submitter Luis Henriques
Date May 28, 2013, 9:51 a.m.
Message ID <>
Download mbox | patch
Permalink /patch/246794/
State New
Headers show


Luis Henriques - May 28, 2013, 9:51 a.m.
This is a note to let you know that I have just added a patch titled

    drivers/block/brd.c: fix brd_lookup_page() race

to the linux-3.5.y-queue branch of the 3.5.y.z extended stable tree 
which can be found at:;a=shortlog;h=refs/heads/linux-3.5.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.5.y.z tree, see



From 16b1038e4a5ab8fa141c912b60671c7189cf2d98 Mon Sep 17 00:00:00 2001
From: Brian Behlendorf <>
Date: Fri, 24 May 2013 15:55:28 -0700
Subject: [PATCH] drivers/block/brd.c: fix brd_lookup_page() race

commit dfd20b2b174d3a9b258ea3b7a35ead33576587b1 upstream.

The index on the page must be set before it is inserted in the radix
tree.  Otherwise there is a small race which can occur during lookup
where the page can be found with the incorrect index.  This will trigger
the BUG_ON() in brd_lookup_page().

Signed-off-by: Brian Behlendorf <>
Reported-by: Chris Wedgwood <>
Cc: Jens Axboe <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
Signed-off-by: Luis Henriques <>
 drivers/block/brd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)



diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 531ceb3..4e8213a 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -117,13 +117,13 @@  static struct page *brd_insert_page(struct brd_device *brd, sector_t sector)

 	idx = sector >> PAGE_SECTORS_SHIFT;
+	page->index = idx;
 	if (radix_tree_insert(&brd->brd_pages, idx, page)) {
 		page = radix_tree_lookup(&brd->brd_pages, idx);
 		BUG_ON(page->index != idx);
-	} else
-		page->index = idx;
+	}