diff options
author | Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> | 2011-09-30 11:39:11 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2011-10-05 10:52:31 -0500 |
commit | e4fc8781db7c49b0c5ac5d24762e17c59dfe0871 (patch) | |
tree | 4ba5d1094292e2456e5299ad42674b7f56cfac83 /block/qed.c | |
parent | d11cf8cc80d946dfc9a23597cd9a0bb1c487cfa7 (diff) |
qed: fix use-after-free during l2 cache commit
QED's metadata caching strategy allows two parallel requests to race for
metadata lookup. The first one to complete will populate the metadata
cache and the second one will drop the data it just read in favor of the
cached data.
There is a use-after-free in qed_read_l2_table_cb() and
qed_commit_l2_update() where l2_table->offset was used after the
l2_table may have been freed due to a metadata lookup race. Fix this by
keeping the l2_offset in a local variable and not reaching into the
possibly freed l2_table.
Reported-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'block/qed.c')
-rw-r--r-- | block/qed.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/block/qed.c b/block/qed.c index 624e261b35..e87dc4decf 100644 --- a/block/qed.c +++ b/block/qed.c @@ -911,14 +911,14 @@ static void qed_commit_l2_update(void *opaque, int ret) QEDAIOCB *acb = opaque; BDRVQEDState *s = acb_to_s(acb); CachedL2Table *l2_table = acb->request.l2_table; + uint64_t l2_offset = l2_table->offset; qed_commit_l2_cache_entry(&s->l2_cache, l2_table); /* This is guaranteed to succeed because we just committed the entry to the * cache. */ - acb->request.l2_table = qed_find_l2_cache_entry(&s->l2_cache, - l2_table->offset); + acb->request.l2_table = qed_find_l2_cache_entry(&s->l2_cache, l2_offset); assert(acb->request.l2_table != NULL); qed_aio_next_io(opaque, ret); |