Skip to contentSkip to conversation

SUNRPC: Fix loop termination condition in gss_free_in_token_pages()

PATCH In review [email protected] 3 participants 3 messages Jun 2, 2024 – Jun 3, 2024

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 SUNRPC: Fix loop termination condition in gss_free_in_token_pages()

From: Chuck Lever <[email protected]>

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()")
---
 net/sunrpc/auth_gss/svcauth_gss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sunrpc/auth_gss/svcauth_gss.c +1 -1
index 96ab50eda9c2..73a90ad873fb 100644
@@ -1069,7 +1069,7 @@ static int gss_read_proxy_verf(struct svc_rqst *rqstp,
 		goto out_denied_free;
 
 	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)
 		goto out_denied_free;
 	in_token->page_base = 0;
Signature · 1 line
2.44.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · On 2 Jun 2024, at 18:15, [email protected] wrote:

From: Chuck Lever <[email protected]>

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()")

Nice.

Ben

#2 lore raw
Quoted 9 lines · Benjamin Coddington
Quoted 7 lines · On 2 Jun 2024, at 18:15, [email protected] wrote:

From: Chuck Lever <[email protected]>

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]
Quoted 9 lines
Quoted 2 lines
Fixes bafa6b4d95d9 ("SUNRPC: Fix gss_free_in_token_pages()")

Nice.

Ben

Thank you, Ben. Applied to nfsd-fixes (for 6.10-rc).

Signature · 1 line
Chuck Lever