Commit 5d14ee4e authored by liucheng (G)'s avatar liucheng (G) Committed by Joe Hershberger

CVE-2019-14196: nfs: fix unbounded memcpy with a failed length check at nfs_lookup_reply

This patch adds a check to rpc_pkt.u.reply.data at nfs_lookup_reply.
Signed-off-by: default avatarCheng Liu <liucheng32@huawei.com>
Reported-by: default avatarFermín Serna <fermin@semmle.com>
Acked-by: Joe Hershberger's avatarJoe Hershberger <joe.hershberger@ni.com>
parent cf3a4f1e
...@@ -566,11 +566,15 @@ static int nfs_lookup_reply(uchar *pkt, unsigned len) ...@@ -566,11 +566,15 @@ static int nfs_lookup_reply(uchar *pkt, unsigned len)
} }
if (supported_nfs_versions & NFSV2_FLAG) { if (supported_nfs_versions & NFSV2_FLAG) {
if (((uchar *)&(rpc_pkt.u.reply.data[0]) - (uchar *)(&rpc_pkt) + NFS_FHSIZE) > len)
return -NFS_RPC_DROP;
memcpy(filefh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE); memcpy(filefh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE);
} else { /* NFSV3_FLAG */ } else { /* NFSV3_FLAG */
filefh3_length = ntohl(rpc_pkt.u.reply.data[1]); filefh3_length = ntohl(rpc_pkt.u.reply.data[1]);
if (filefh3_length > NFS3_FHSIZE) if (filefh3_length > NFS3_FHSIZE)
filefh3_length = NFS3_FHSIZE; filefh3_length = NFS3_FHSIZE;
if (((uchar *)&(rpc_pkt.u.reply.data[0]) - (uchar *)(&rpc_pkt) + filefh3_length) > len)
return -NFS_RPC_DROP;
memcpy(filefh, rpc_pkt.u.reply.data + 2, filefh3_length); memcpy(filefh, rpc_pkt.u.reply.data + 2, filefh3_length);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment