File 0017-CVE-2019-14195-nfs-fix-unbounded-me.patch of Package u-boot.25181
From b66bb14e03201036988ad106aef52826aa294eb7 Mon Sep 17 00:00:00 2001
From: "liucheng (G)" <liucheng32@huawei.com>
Date: Thu, 29 Aug 2019 13:47:54 +0000
Subject: [PATCH] CVE-2019-14195: nfs: fix unbounded memcpy with unvalidated
length at nfs_readlink_reply
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This patch adds a check to rpc_pkt.u.reply.data at nfs_readlink_reply.
Signed-off-by: Cheng Liu <liucheng32@huawei.com>
Reported-by: FermÃn Serna <fermin@semmle.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
(cherry picked from commit cf3a4f1e86ecdd24f87b615051b49d8e1968c230)
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
---
net/nfs.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/nfs.c b/net/nfs.c
index b981104e9d..a8bf184874 100644
--- a/net/nfs.c
+++ b/net/nfs.c
@@ -634,6 +634,9 @@ static int nfs_readlink_reply(uchar *pkt, unsigned len)
/* new path length */
rlen = ntohl(rpc_pkt.u.reply.data[1 + nfsv3_data_offset]);
+ if (((uchar *)&(rpc_pkt.u.reply.data[0]) - (uchar *)(&rpc_pkt) + rlen) > len)
+ return -NFS_RPC_DROP;
+
if (*((char *)&(rpc_pkt.u.reply.data[2 + nfsv3_data_offset])) != '/') {
int pathlen;