diff options
| author | liucheng (G) <[email protected]> | 2019-08-29 13:48:02 +0000 |
|---|---|---|
| committer | Joe Hershberger <[email protected]> | 2019-09-04 11:37:19 -0500 |
| commit | 5d14ee4e53a81055d34ba280cb8fd90330f22a96 (patch) | |
| tree | d38ed9d6724fd99924f1377fec64f930bbc2c452 /net/nfs.c | |
| parent | cf3a4f1e86ecdd24f87b615051b49d8e1968c230 (diff) | |
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: Cheng Liu <[email protected]>
Reported-by: FermÃn Serna <[email protected]>
Acked-by: Joe Hershberger <[email protected]>
Diffstat (limited to 'net/nfs.c')
| -rw-r--r-- | net/nfs.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/net/nfs.c b/net/nfs.c index 915acd95cf8..89952aeb662 100644 --- a/net/nfs.c +++ b/net/nfs.c @@ -566,11 +566,15 @@ static int nfs_lookup_reply(uchar *pkt, unsigned len) } 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); } else { /* NFSV3_FLAG */ filefh3_length = ntohl(rpc_pkt.u.reply.data[1]); if (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); } |
