mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-02 09:46:37 +03:00
net: nfs: fix buffer overflow in nfs_readlink_reply()
nfs_readlink_reply() validates rlen only against the incoming packet length (inherited from CVE-2019-14195), but not against the destination buffer nfs_path_buff[2048]. A malicious NFS server can send a valid READLINK reply where pathlen + rlen exceeds sizeof(nfs_path_buff), overflowing the BSS buffer into adjacent memory. The recent fix infd6e3d3409addressed the same overflow class in net/lwip/nfs.c but left the legacy path in net/nfs-common.c unpatched. Add bounds checks before both memcpy calls in nfs_readlink_reply(): - relative path branch: reject if pathlen + rlen >= sizeof(nfs_path_buff) - absolute path branch: reject if rlen >= sizeof(nfs_path_buff) Fixes:cf3a4f1e86("net: nfs: Fix CVE-2019-14195") Cc: stable@vger.kernel.org Signed-off-by: Sebastian Alba Vives <sebasjosue84@gmail.com> Reviewed-by: Jerome Forissier <jerome.forissier@arm.com>
This commit is contained in:
committed by
Jerome Forissier
parent
e86d1c0b88
commit
d6694018ea
@@ -674,11 +674,15 @@ static int nfs_readlink_reply(uchar *pkt, unsigned int len)
|
||||
|
||||
strcat(nfs_path, "/");
|
||||
pathlen = strlen(nfs_path);
|
||||
if (pathlen + rlen >= sizeof(nfs_path_buff))
|
||||
return -NFS_RPC_DROP;
|
||||
memcpy(nfs_path + pathlen,
|
||||
(uchar *)&rpc_pkt.u.reply.data[2 + nfsv3_data_offset],
|
||||
rlen);
|
||||
nfs_path[pathlen + rlen] = 0;
|
||||
} else {
|
||||
if (rlen >= sizeof(nfs_path_buff))
|
||||
return -NFS_RPC_DROP;
|
||||
memcpy(nfs_path,
|
||||
(uchar *)&rpc_pkt.u.reply.data[2 + nfsv3_data_offset],
|
||||
rlen);
|
||||
|
||||
Reference in New Issue
Block a user