Skip to content

Commit

Permalink
svcrpc: fix memory leak in gssp_accept_sec_context_upcall
Browse files Browse the repository at this point in the history
Our UC-KLEE tool found a kernel memory leak of 512 bytes (on x86_64) for
each call to gssp_accept_sec_context_upcall()
(net/sunrpc/auth_gss/gss_rpc_upcall.c). Since it appears that this call
can be triggered by remote connections (at least, from a cursory a
glance at the call chain), it may be exploitable to cause kernel memory
exhaustion. We found the bug in kernel 3.16.3, but it appears to date
back to commit 9dfd87d (2013-08-20).

The gssp_accept_sec_context_upcall() function performs a pair of calls
to gssp_alloc_receive_pages() and gssp_free_receive_pages().  The first
allocates memory for arg->pages.  The second then frees the pages
pointed to by the arg->pages array, but not the array itself.

Reported-by: David A. Ramos <daramos@stanford.edu>
Fixes: 9dfd87d ("rpc: fix huge kmalloc's in gss-proxy”)
Signed-off-by: David A. Ramos <daramos@stanford.edu>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
  • Loading branch information
David Ramos authored and J. Bruce Fields committed Feb 17, 2015
1 parent a51f25a commit a1d1e9b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/sunrpc/auth_gss/gss_rpc_upcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ static void gssp_free_receive_pages(struct gssx_arg_accept_sec_context *arg)

for (i = 0; i < arg->npages && arg->pages[i]; i++)
__free_page(arg->pages[i]);

kfree(arg->pages);
}

static int gssp_alloc_receive_pages(struct gssx_arg_accept_sec_context *arg)
Expand Down

0 comments on commit a1d1e9b

Please sign in to comment.