SUNRPC: svcauth_gss: avoid NULL deref on zero length gss_token in gss_read_proxy_verf
Subsystems (3)
Chuck Lever
maintainerPATCH 1/1 SUNRPC: svcauth_gss: avoid NULL deref on zero length gss_token in gss_read_proxy_verf
From: Joshua Rogers <[email protected]>
A zero length gss_token results in pages == 0 and in_token->pages[0] is NULL. The code unconditionally evaluates page_address(in_token->pages[0]) for the initial memcpy, which can dereference NULL even when the copy length is 0. Guard the first memcpy so it only runs when length > 0.
Fixes 5866efa8cbfb ("SUNRPC: Fix svcauth_gss_proxy_init()")
X-Cc: [email protected]
Signed-off-by Joshua Rogers <[email protected]>
Signed-off-by Chuck Lever <[email protected]>
--- net/sunrpc/auth_gss/svcauth_gss.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sunrpc/auth_gss/svcauth_gss.c +2 -1
@@ -1083,7 +1083,8 @@ static int gss_read_proxy_verf(struct svc_rqst *rqstp, } length = min_t(unsigned int, inlen, (char *)xdr->end - (char *)xdr->p); -memcpy (page_address (in_token->pages[0 ]), xdr->p, length); +if (length) +memcpy (page_address (in_token->pages[0 ]), xdr->p, length); inlen -= length; to_offs = length;
Signature · 1 line
2.51.0