From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Cc: "Claude Opus 4.6 (1M context)" <noreply@anthropic.com>
Subject: Re: [PATCH 2/2] fs: nfs: fix NULL dereference in nfs_read_req on truncated packets
Date: Thu, 2 Apr 2026 12:39:01 +0200 [thread overview]
Message-ID: <ac5HRUnLUdx2oFUy@pengutronix.de> (raw)
In-Reply-To: <20260402-net-nfs-buffer-overflows-v1-2-5dc46ef1da81@pengutronix.de>
On Thu, Apr 02, 2026 at 09:55:24AM +0200, Sascha Hauer wrote:
> nfs_read_req() reads the data length (rlen) from the server's READ3res
> response and uses it to extract the payload via nfs_packet_read(). If a
> malicious server sends an rlen larger than the remaining packet data,
> nfs_packet_read() returns NULL. The subsequent kfifo_put() with a NULL
> source pointer causes a NULL pointer dereference.
>
> Add a NULL check after nfs_packet_read() to catch truncated responses.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fixes: 5be38817bc77 ("fs: nfs: do not read past packets")
Sascha
> ---
> fs/nfs.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/nfs.c b/fs/nfs.c
> index edc15e0ce6..d42ef6bc86 100644
> --- a/fs/nfs.c
> +++ b/fs/nfs.c
> @@ -1194,6 +1194,10 @@ static int nfs_read_req(struct file_priv *priv, uint64_t offset,
> }
>
> p = nfs_packet_read(nfs_packet, rlen);
> + if (!p) {
> + ret = -EINVAL;
> + goto err_free_packet;
> + }
>
> kfifo_put(priv->fifo, (char *)p, rlen);
>
>
> --
> 2.47.3
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2026-04-02 10:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 7:55 [PATCH 0/2] nfs: protect against corrupt packets and userdata Sascha Hauer
2026-04-02 7:55 ` [PATCH 1/2] fs: nfs: fix stack and packet buffer overflows from long NFS paths Sascha Hauer
2026-04-02 7:55 ` [PATCH 2/2] fs: nfs: fix NULL dereference in nfs_read_req on truncated packets Sascha Hauer
2026-04-02 10:39 ` Sascha Hauer [this message]
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=ac5HRUnLUdx2oFUy@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=noreply@anthropic.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