From: Chuck Lever <cel@kernel.org>
To: Chuck Lever <cel@kernel.org>, Christoph Hellwig <hch@lst.de>,
Jeff Layton <jlayton@kernel.org>, NeilBrown <neil@brown.name>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
Sergey Bashirov <sergeybashirov@gmail.com>,
Konstantin Evtushenko <koevtushenko@yandex.com>
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 2/4] NFSD: Allocate the layoutupdate extent array with kvzalloc_objs()
Date: Thu, 19 Nov 2026 13:33:52 -0500 [thread overview]
Message-ID: <20261119-blocklayout-decode-stream-v1-2-d71322f42c28@kernel.org> (raw)
In-Reply-To: <20261119-blocklayout-decode-stream-v1-0-d71322f42c28@kernel.org>
The block and SCSI layoutupdate decoders allocate one struct iomap
per extent with kzalloc_objs(). A struct iomap is larger than a
44-byte block extent or a 16-byte SCSI range, so a lou_body that
fits in the maximum request size can still need an array larger
than KMALLOC_MAX_SIZE. kmalloc() then warns that the request exceeds
KMALLOC_MAX_SIZE, and the decoder returns nfserr_delay. A client that
retries after NFS4ERR_DELAY resends a LAYOUTCOMMIT that NFSD can never
decode. Found by inspection.
The session's ca_maxrequestsize still bounds the size of the array.
Fixes: 8650b8a05850 ("nfsd: pNFS block layout driver")
Fixes: f99d4fbdae67 ("nfsd: add SCSI layout support")
Signed-off-by: Chuck Lever <cel@kernel.org>
---
fs/nfsd/blocklayout.c | 2 +-
fs/nfsd/blocklayoutxdr.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/nfsd/blocklayout.c b/fs/nfsd/blocklayout.c
index b3bb2831cff3..06564f247795 100644
--- a/fs/nfsd/blocklayout.c
+++ b/fs/nfsd/blocklayout.c
@@ -228,7 +228,7 @@ nfsd4_block_commit_blocks(struct inode *inode, struct nfsd4_layoutcommit *lcp,
error = inode->i_sb->s_export_op->block_ops->commit_blocks(inode,
iomaps, nr_iomaps,
lcp->lc_size_chg ? lcp->lc_newsize : 0);
- kfree(iomaps);
+ kvfree(iomaps);
return nfserrno(error);
}
diff --git a/fs/nfsd/blocklayoutxdr.c b/fs/nfsd/blocklayoutxdr.c
index ea9a3f04a560..90ccc07801ca 100644
--- a/fs/nfsd/blocklayoutxdr.c
+++ b/fs/nfsd/blocklayoutxdr.c
@@ -175,7 +175,7 @@ nfsd4_block_decode_layoutupdate(struct xdr_stream *xdr, struct iomap **iomapp,
nr_iomaps != len / PNFS_BLOCK_EXTENT_SIZE)
return nfserr_bad_xdr;
- iomaps = kzalloc_objs(*iomaps, nr_iomaps);
+ iomaps = kvzalloc_objs(*iomaps, nr_iomaps);
if (!iomaps)
return nfserr_delay;
@@ -231,7 +231,7 @@ nfsd4_block_decode_layoutupdate(struct xdr_stream *xdr, struct iomap **iomapp,
*nr_iomapsp = nr_iomaps;
return nfs_ok;
fail:
- kfree(iomaps);
+ kvfree(iomaps);
return nfserr;
}
@@ -269,7 +269,7 @@ nfsd4_scsi_decode_layoutupdate(struct xdr_stream *xdr, struct iomap **iomapp,
nr_iomaps != len / PNFS_SCSI_RANGE_SIZE)
return nfserr_bad_xdr;
- iomaps = kzalloc_objs(*iomaps, nr_iomaps);
+ iomaps = kvzalloc_objs(*iomaps, nr_iomaps);
if (!iomaps)
return nfserr_delay;
@@ -301,6 +301,6 @@ nfsd4_scsi_decode_layoutupdate(struct xdr_stream *xdr, struct iomap **iomapp,
*nr_iomapsp = nr_iomaps;
return nfs_ok;
fail:
- kfree(iomaps);
+ kvfree(iomaps);
return nfserr;
}
--
2.56.0
next prev parent reply other threads:[~2026-11-19 18:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 18:33 [PATCH 0/4] NFSD: More minor XDR restructuring Chuck Lever
2026-11-19 18:33 ` [PATCH 1/4] NFSD: Reject layoutupdate extent counts that wrap the length check Chuck Lever
2026-11-20 16:12 ` Christoph Hellwig
2026-11-19 18:33 ` Chuck Lever [this message]
2026-11-20 16:13 ` [PATCH 2/4] NFSD: Allocate the layoutupdate extent array with kvzalloc_objs() Christoph Hellwig
2026-11-19 18:33 ` [PATCH 3/4] NFSD: Decode block and SCSI layoutupdates from a local xdr_stream Chuck Lever
2026-11-20 16:14 ` Christoph Hellwig
2026-11-19 18:33 ` [PATCH 4/4] NFSD: Remove the svc_rqst argument from proc_layoutcommit Chuck Lever
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=20261119-blocklayout-decode-stream-v1-2-d71322f42c28@kernel.org \
--to=cel@kernel.org \
--cc=Dai.Ngo@oracle.com \
--cc=hch@lst.de \
--cc=jlayton@kernel.org \
--cc=koevtushenko@yandex.com \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=sergeybashirov@gmail.com \
--cc=tom@talpey.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