lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Fri, 10 May 2013 09:48:04 -0700
From:	Brian Behlendorf <behlendorf1@...l.gov>
To:	Nick Piggin <npiggin@...nel.dk>
CC:	LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH] brd: Fix brd_lookup_page() race

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().

Reported-by: Chris Wedgwood <cw@...f.org>
Signed-off-by: Brian Behlendorf <behlendorf1@...l.gov>

---
  drivers/block/brd.c |    4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index f1a29f8..9bf4371 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -117,13 +117,13 @@ static struct page *brd_insert_page(struct 
brd_device *b, 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();
-- 
1.7.4.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ