mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
drivers/block/brd.c: fix brd_lookup_page() race
commit dfd20b2b17
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 <behlendorf1@llnl.gov>
Reported-by: Chris Wedgwood <cw@f00f.org>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
bfd7610d98
commit
60e255daee
1 changed files with 2 additions and 2 deletions
|
@ -117,13 +117,13 @@ static struct page *brd_insert_page(struct brd_device *brd, sector_t sector)
|
|||
|
||||
spin_lock(&brd->brd_lock);
|
||||
idx = sector >> PAGE_SECTORS_SHIFT;
|
||||
page->index = idx;
|
||||
if (radix_tree_insert(&brd->brd_pages, idx, page)) {
|
||||
__free_page(page);
|
||||
page = radix_tree_lookup(&brd->brd_pages, idx);
|
||||
BUG_ON(!page);
|
||||
BUG_ON(page->index != idx);
|
||||
} else
|
||||
page->index = idx;
|
||||
}
|
||||
spin_unlock(&brd->brd_lock);
|
||||
|
||||
radix_tree_preload_end();
|
||||
|
|
Loading…
Reference in a new issue