Brad Bishop | 00e122a | 2019-10-05 11:10:57 -0400 | [diff] [blame] | 1 | From 74c468caa95c86cdb12c4b8073e154c435ac0bf7 Mon Sep 17 00:00:00 2001 |
| 2 | From: "liucheng (G)" <liucheng32@huawei.com> |
| 3 | Date: Thu, 29 Aug 2019 13:48:02 +0000 |
| 4 | Subject: [PATCH 9/9] CVE-2019-14196: nfs: fix unbounded memcpy with a failed |
| 5 | length check at nfs_lookup_reply |
| 6 | MIME-Version: 1.0 |
| 7 | Content-Type: text/plain; charset=UTF-8 |
| 8 | Content-Transfer-Encoding: 8bit |
| 9 | |
| 10 | This patch adds a check to rpc_pkt.u.reply.data at nfs_lookup_reply. |
| 11 | |
| 12 | Signed-off-by: Cheng Liu <liucheng32@huawei.com> |
| 13 | Reported-by: Fermín Serna <fermin@semmle.com> |
| 14 | Acked-by: Joe Hershberger <joe.hershberger@ni.com> |
| 15 | |
| 16 | Upstream-Status: Backport[http://git.denx.de/?p=u-boot.git;a=commit; |
| 17 | h=5d14ee4e53a81055d34ba280cb8fd90330f22a96] |
| 18 | |
| 19 | CVE: CVE-2019-14196 |
| 20 | |
| 21 | Signed-off-by: Meng Li <Meng.Li@windriver.com> |
| 22 | --- |
| 23 | net/nfs.c | 4 ++++ |
| 24 | 1 file changed, 4 insertions(+) |
| 25 | |
| 26 | diff --git a/net/nfs.c b/net/nfs.c |
| 27 | index 915acd95cf..89952aeb66 100644 |
| 28 | --- a/net/nfs.c |
| 29 | +++ b/net/nfs.c |
| 30 | @@ -566,11 +566,15 @@ static int nfs_lookup_reply(uchar *pkt, unsigned len) |
| 31 | } |
| 32 | |
| 33 | if (supported_nfs_versions & NFSV2_FLAG) { |
| 34 | + if (((uchar *)&(rpc_pkt.u.reply.data[0]) - (uchar *)(&rpc_pkt) + NFS_FHSIZE) > len) |
| 35 | + return -NFS_RPC_DROP; |
| 36 | memcpy(filefh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE); |
| 37 | } else { /* NFSV3_FLAG */ |
| 38 | filefh3_length = ntohl(rpc_pkt.u.reply.data[1]); |
| 39 | if (filefh3_length > NFS3_FHSIZE) |
| 40 | filefh3_length = NFS3_FHSIZE; |
| 41 | + if (((uchar *)&(rpc_pkt.u.reply.data[0]) - (uchar *)(&rpc_pkt) + filefh3_length) > len) |
| 42 | + return -NFS_RPC_DROP; |
| 43 | memcpy(filefh, rpc_pkt.u.reply.data + 2, filefh3_length); |
| 44 | } |
| 45 | |
| 46 | -- |
| 47 | 2.17.1 |
| 48 | |