From: Sriram Sriram <sriramsriram@linux.microsoft.com>
To: u-boot@lists.u-boot-project.org
Cc: Tom Rini <trini@konsulko.com>,
Jerome Forissier <jerome.forissier@arm.com>,
Drew Kluemke <ankluemk@microsoft.com>,
Daniel Munic <v-dmunic@microsoft.com>,
Sriram Sriram <sriramsriram@linux.microsoft.com>
Subject: [PATCH v2 1/3] net: nfs: add bounds checks on memcpy into stack-allocated rpc_pkt
Date: Tue, 15 Sep 2026 13:52:08 -0700 [thread overview]
Message-ID: <20260915205210.260404-2-sriramsriram@linux.microsoft.com> (raw)
In-Reply-To: <20260915205210.260404-1-sriramsriram@linux.microsoft.com>
From: Drew Kluemke <ankluemk@microsoft.com>
Multiple NFS reply handlers (rpc_lookup_reply, nfs_mount_reply,
nfs_umountall_reply, nfs_lookup_reply, nfs_readlink_reply) copy network
data into a stack-allocated struct rpc_t without verifying that the UDP
payload length fits within the buffer. A malicious or malformed NFS
server response with len > sizeof(rpc_pkt) overwrites the stack frame.
Add a bounds check before each memcpy to drop oversized packets.
Signed-off-by: Drew Kluemke <ankluemk@microsoft.com>
Signed-off-by: Sriram Sriram <sriramsriram@linux.microsoft.com>
---
Changes in v2:
- No change, rebased onto current master.
net/nfs-common.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/net/nfs-common.c b/net/nfs-common.c
index 637fcfd9bb8..226e3fe5798 100644
--- a/net/nfs-common.c
+++ b/net/nfs-common.c
@@ -503,6 +503,8 @@ static int rpc_lookup_reply(int prog, uchar *pkt, unsigned int len)
{
struct rpc_t rpc_pkt;
+ if (len > sizeof(rpc_pkt.u.data))
+ return -NFS_RPC_DROP;
memcpy(&rpc_pkt.u.data[0], pkt, len);
if (ntohl(rpc_pkt.u.reply.id) > rpc_id)
@@ -532,6 +534,8 @@ static int nfs_mount_reply(uchar *pkt, unsigned int len)
struct rpc_t rpc_pkt;
int ret;
+ if (len > sizeof(rpc_pkt.u.data))
+ return -NFS_RPC_DROP;
memcpy(&rpc_pkt.u.data[0], pkt, len);
if (ntohl(rpc_pkt.u.reply.id) > rpc_id)
@@ -561,6 +565,8 @@ static int nfs_umountall_reply(uchar *pkt, unsigned int len)
{
struct rpc_t rpc_pkt;
+ if (len > sizeof(rpc_pkt.u.data))
+ return -NFS_RPC_DROP;
memcpy(&rpc_pkt.u.data[0], pkt, len);
if (ntohl(rpc_pkt.u.reply.id) > rpc_id)
@@ -584,6 +590,8 @@ static int nfs_lookup_reply(uchar *pkt, unsigned int len)
struct rpc_t rpc_pkt;
int ret;
+ if (len > sizeof(rpc_pkt.u.data))
+ return -NFS_RPC_DROP;
memcpy(&rpc_pkt.u.data[0], pkt, len);
if (ntohl(rpc_pkt.u.reply.id) > rpc_id)
@@ -645,6 +653,8 @@ static int nfs_readlink_reply(uchar *pkt, unsigned int len)
int rlen;
int nfsv3_data_offset = 0;
+ if (len > sizeof(rpc_pkt))
+ return -NFS_RPC_DROP;
memcpy((unsigned char *)&rpc_pkt, pkt, len);
if (ntohl(rpc_pkt.u.reply.id) > rpc_id)
--
2.49.0
next prev parent reply other threads:[~2026-09-15 20:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 19:20 [PATCH 0/4] Bounds/overflow hardening in NFS, FIT, TFTP and ext4 Sriram Sriram
2026-09-09 19:20 ` [PATCH 1/4] net: nfs: add bounds checks on memcpy into stack-allocated rpc_pkt Sriram Sriram
2026-09-09 19:20 ` [PATCH 2/4] boot: image-fit: add overflow guard for FIT decompression buffer Sriram Sriram
2026-09-10 19:09 ` Tom Rini
2026-09-09 19:20 ` [PATCH 3/4] net: tftp: use bounded string compare for OACK option parsing Sriram Sriram
2026-09-10 19:25 ` Tom Rini
2026-09-09 19:20 ` [PATCH 4/4] fs: ext4: widen ext4fs_update() block-group loop counter Sriram Sriram
2026-09-15 20:52 ` [PATCH v2 0/3] Bounds hardening in NFS, TFTP and ext4 Sriram Sriram
2026-09-15 20:52 ` Sriram Sriram [this message]
2026-09-17 9:03 ` [PATCH v2 1/3] net: nfs: add bounds checks on memcpy into stack-allocated rpc_pkt Jerome Forissier
2026-09-15 20:52 ` [PATCH v2 2/3] net: tftp: verify the OACK packet is NUL terminated Sriram Sriram
2026-09-17 8:51 ` Jerome Forissier
2026-09-15 20:52 ` [PATCH v2 3/3] fs: ext4: widen ext4fs_update() block-group loop counter Sriram Sriram
2026-09-15 21:23 ` Tony Dinh
2026-10-01 1:20 ` (subset) [PATCH v2 0/3] Bounds hardening in NFS, TFTP and ext4 Tom Rini
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=20260915205210.260404-2-sriramsriram@linux.microsoft.com \
--to=sriramsriram@linux.microsoft.com \
--cc=ankluemk@microsoft.com \
--cc=jerome.forissier@arm.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.org \
--cc=v-dmunic@microsoft.com \
/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;
as well as URLs for NNTP newsgroup(s).