Skip to content

Commit c899b83

Browse files
J. Bruce Fieldsgregkh
authored andcommitted
rpc: fix NULL dereference on kmalloc failure
[ Upstream commit 0ddc942 ] I think this is unlikely but possible: svc_authenticate sets rq_authop and calls svcauth_gss_accept. The kmalloc(sizeof(*svcdata), GFP_KERNEL) fails, leaving rq_auth_data NULL, and returning SVC_DENIED. This causes svc_process_common to go to err_bad_auth, and eventually call svc_authorise. That calls ->release == svcauth_gss_release, which tries to dereference rq_auth_data. Signed-off-by: J. Bruce Fields <bfields@redhat.com> Link: https://lore.kernel.org/linux-nfs/3F1B347F-B809-478F-A1E9-0BE98E22B0F0@oracle.com/T/#t Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 0e71c59 commit c899b83

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

net/sunrpc/auth_gss/svcauth_gss.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,11 +1782,14 @@ static int
17821782
svcauth_gss_release(struct svc_rqst *rqstp)
17831783
{
17841784
struct gss_svc_data *gsd = (struct gss_svc_data *)rqstp->rq_auth_data;
1785-
struct rpc_gss_wire_cred *gc = &gsd->clcred;
1785+
struct rpc_gss_wire_cred *gc;
17861786
struct xdr_buf *resbuf = &rqstp->rq_res;
17871787
int stat = -EINVAL;
17881788
struct sunrpc_net *sn = net_generic(SVC_NET(rqstp), sunrpc_net_id);
17891789

1790+
if (!gsd)
1791+
goto out;
1792+
gc = &gsd->clcred;
17901793
if (gc->gc_proc != RPC_GSS_PROC_DATA)
17911794
goto out;
17921795
/* Release can be called twice, but we only wrap once. */
@@ -1827,10 +1830,10 @@ svcauth_gss_release(struct svc_rqst *rqstp)
18271830
if (rqstp->rq_cred.cr_group_info)
18281831
put_group_info(rqstp->rq_cred.cr_group_info);
18291832
rqstp->rq_cred.cr_group_info = NULL;
1830-
if (gsd->rsci)
1833+
if (gsd && gsd->rsci) {
18311834
cache_put(&gsd->rsci->h, sn->rsc_cache);
1832-
gsd->rsci = NULL;
1833-
1835+
gsd->rsci = NULL;
1836+
}
18341837
return stat;
18351838
}
18361839

0 commit comments

Comments
 (0)