Skip to content

Commit d4b69a6

Browse files
Joshua Rogerschucklever
authored andcommitted
SUNRPC: svcauth_gss: avoid NULL deref on zero length gss_token in gss_read_proxy_verf
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: 5866efa ("SUNRPC: Fix svcauth_gss_proxy_init()") Cc: stable@vger.kernel.org Signed-off-by: Joshua Rogers <linux@joshua.hu> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent df8c841 commit d4b69a6

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

net/sunrpc/auth_gss/svcauth_gss.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,8 @@ static int gss_read_proxy_verf(struct svc_rqst *rqstp,
10831083
}
10841084

10851085
length = min_t(unsigned int, inlen, (char *)xdr->end - (char *)xdr->p);
1086-
memcpy(page_address(in_token->pages[0]), xdr->p, length);
1086+
if (length)
1087+
memcpy(page_address(in_token->pages[0]), xdr->p, length);
10871088
inlen -= length;
10881089

10891090
to_offs = length;

0 commit comments

Comments
 (0)