diff mbox series

[U-Boot,v2,4/5] CVE-2019-14195: nfs: fix unbounded memcpy with unvalidated length at nfs_readlink_reply //RE: [PATCH 4/5] CVE-2019-14195: nfs: fix unbounded memcpy with unvalidated length at nfs_readlink_reply

Message ID 869863DB5440B44FB22173F42FC3F3CE01DA3838@dggemm513-mbx.china.huawei.com
State Superseded
Delegated to: Tom Rini
Headers show
Series [U-Boot,v2,1/5] CVE: net: fix unbounded memcpy of UDP packet//RE: [PATCH 1/5] CVE: net: fix unbounded memcpy of UDP packet | expand

Commit Message

liucheng (G) Aug. 22, 2019, 3:28 a.m. UTC
Changes in v2:
- Add reported-by tag for patch 4/5
--------------------------------------------------------------------------------------------------------------
CVE-2019-14195: nfs: fix unbounded memcpy with unvalidated length at nfs_readlink_reply

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>
---
 net/nfs.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/net/nfs.c b/net/nfs.c
index 11941fa..915acd9 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;
 
-- 
1.8.5.6

-----Original Message-----
From: liucheng (G) 
Sent: Wednesday, August 21, 2019 10:48 PM
To: u-boot@lists.denx.de
Cc: liucheng (G) <liucheng32@huawei.com>
Subject: [PATCH 4/5] CVE-2019-14195: nfs: fix unbounded memcpy with unvalidated length at nfs_readlink_reply

CVE-2019-14195: nfs: fix unbounded memcpy with unvalidated length at nfs_readlink_reply

This patch adds a check to rpc_pkt.u.reply.data at nfs_readlink_reply.

Signed-off-by: Cheng Liu <liucheng32@huawei.com>
---
 net/nfs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/nfs.c b/net/nfs.c
index 11941fa..915acd9 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;