Skip to content

Commit

Permalink
gru: fix potential use-after-free when purging GRU tlbs
Browse files Browse the repository at this point in the history
Fix potential SGI GRU bug that could cause a use-after-free.  If one
thread in a task is flushing the GRU and another thread destroys the GRU
context, there is the potential to access a table after it has been freed.

Copy the gms pointer to a local variable before unlocking the gts table.
Note that no refcnt is needed for the gms - the reference is held
indirectly by the task's mm_struct.

Signed-off-by: Jack Steiner <steiner@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Jack Steiner authored and Linus Torvalds committed Jun 18, 2009
1 parent b1b19fc commit 1926ee8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/misc/sgi-gru/grufault.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ int gru_user_flush_tlb(unsigned long arg)
{
struct gru_thread_state *gts;
struct gru_flush_tlb_req req;
struct gru_mm_struct *gms;

STAT(user_flush_tlb);
if (copy_from_user(&req, (void __user *)arg, sizeof(req)))
Expand All @@ -714,8 +715,9 @@ int gru_user_flush_tlb(unsigned long arg)
if (!gts)
return -EINVAL;

gru_flush_tlb_range(gts->ts_gms, req.vaddr, req.len);
gms = gts->ts_gms;
gru_unlock_gts(gts);
gru_flush_tlb_range(gms, req.vaddr, req.len);

return 0;
}
Expand Down

0 comments on commit 1926ee8

Please sign in to comment.