From: Sebastian Alba Vives <sebasjosue84@gmail.com>
To: u-boot@lists.denx.de
Cc: trini@konsulko.com, jerome.forissier@linaro.org,
stable@vger.kernel.org,
Sebastian Josue Alba Vives <sebasjosue84@gmail.com>
Subject: [PATCH] net: nfs: fix buffer overflow in nfs_readlink_reply()
Date: Thu, 9 Apr 2026 10:44:40 -0600 [thread overview]
Message-ID: <20260409164440.323405-1-sebasjosue84@gmail.com> (raw)
From: Sebastian Josue Alba Vives <sebasjosue84@gmail.com>
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 in fd6e3d34097f addressed 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>
---
net/nfs-common.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/nfs-common.c b/net/nfs-common.c
index 4fbde67a..72d8fd82 100644
--- a/net/nfs-common.c
+++ b/net/nfs-common.c
@@ -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);
--
2.43.0
reply other threads:[~2026-04-09 16:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260409164440.323405-1-sebasjosue84@gmail.com \
--to=sebasjosue84@gmail.com \
--cc=jerome.forissier@linaro.org \
--cc=stable@vger.kernel.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox