]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
SUNRPC: Fix loop termination condition in gss_free_in_token_pages()
authorChuck Lever <chuck.lever@oracle.com>
Sun, 2 Jun 2024 22:15:25 +0000 (18:15 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 16 Jun 2024 11:32:30 +0000 (13:32 +0200)
commit 4a77c3dead97339478c7422eb07bf4bf63577008 upstream.

The in_token->pages[] array is not NULL terminated. This results in
the following KASAN splat:

  KASAN: maybe wild-memory-access in range [0x04a2013400000008-0x04a201340000000f]

Fixes: bafa6b4d95d9 ("SUNRPC: Fix gss_free_in_token_pages()")
Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/sunrpc/auth_gss/svcauth_gss.c

index 23e6ac9cce113634ba9c02f2bdddcee9f0a931eb..784c8b24f1640c2091212b7541951f5dae03e264 100644 (file)
@@ -1156,7 +1156,7 @@ static int gss_read_proxy_verf(struct svc_rqst *rqstp,
        }
 
        pages = DIV_ROUND_UP(inlen, PAGE_SIZE);
-       in_token->pages = kcalloc(pages, sizeof(struct page *), GFP_KERNEL);
+       in_token->pages = kcalloc(pages + 1, sizeof(struct page *), GFP_KERNEL);
        if (!in_token->pages) {
                kfree(in_handle->data);
                return SVC_DENIED;