Skip to content

Commit

Permalink
[PATCH] IB: fix use-after-free in user verbs cleanup
Browse files Browse the repository at this point in the history
Fix a use-after-free bug in userspace verbs cleanup: we can't touch
mr->device after we free mr by calling ib_dereg_mr().

Signed-off-by: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Roland Dreier authored and Linus Torvalds committed Aug 27, 2005
1 parent 1c9cf6f commit e1bcfca
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/infiniband/core/uverbs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,14 @@ static int ib_dealloc_ucontext(struct ib_ucontext *context)

list_for_each_entry_safe(uobj, tmp, &context->mr_list, list) {
struct ib_mr *mr = idr_find(&ib_uverbs_mr_idr, uobj->id);
struct ib_device *mrdev = mr->device;
struct ib_umem_object *memobj;

idr_remove(&ib_uverbs_mr_idr, uobj->id);
ib_dereg_mr(mr);

memobj = container_of(uobj, struct ib_umem_object, uobject);
ib_umem_release_on_close(mr->device, &memobj->umem);
ib_umem_release_on_close(mrdev, &memobj->umem);

list_del(&uobj->list);
kfree(memobj);
Expand Down

0 comments on commit e1bcfca

Please sign in to comment.