SUNRPC: Fix crasher in gss_unwrap_resp_integ()
authorChuck Lever <chuck.lever@oracle.com>
Sat, 8 Oct 2022 18:58:29 +0000 (14:58 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Thu, 27 Oct 2022 19:52:10 +0000 (15:52 -0400)
If a zero length is passed to kmalloc() it returns 0x10, which is
not a valid address. gss_unwrap_resp_integ() subsequently crashes
when it attempts to dereference that pointer.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
net/sunrpc/auth_gss/auth_gss.c

index a31a278..7bb247c 100644 (file)
@@ -1989,7 +1989,7 @@ gss_unwrap_resp_integ(struct rpc_task *task, struct rpc_cred *cred,
                goto unwrap_failed;
        mic.len = len;
        mic.data = kmalloc(len, GFP_KERNEL);
-       if (!mic.data)
+       if (ZERO_OR_NULL_PTR(mic.data))
                goto unwrap_failed;
        if (read_bytes_from_xdr_buf(rcv_buf, offset, mic.data, mic.len))
                goto unwrap_failed;