NFS: harden pNFS XDR decoding
Subsystems (3)
v2 cover NFS: harden pNFS XDR decoding
pNFS device and layout replies contain several counts and strings supplied by the server. The current decoders trust some of those values before the reply has proved that the corresponding XDR objects are present. A broken or malicious server can therefore provoke oversized allocations, very long decode loops, malformed data-server ports, or leaked netid strings on temporary-address cleanup paths.
This series makes those paths proportional to the received XDR length. It also validates both decimal port octets and uses the common data-server address destructor wherever a temporary address is discarded.
The last patch adds focused, page-backed KUnit coverage for the address, GETDEVICEINFO, and LAYOUTGET decoders. It covers 16 universal-address cases and six flexfiles cases, including cache reuse and malformed multipath, version, and filehandle counts.
This version is based on v7.3-rc1.
Validation:
- nfs_pnfs_decode KUnit suite: 16/16 passed
- nfs_flexfile_deviceid KUnit suite: 6/6 passed
- GCC 16 W=1 build of fs/nfs/: passed with no NFS diagnostics
- Clang 22 W=1 build of fs/nfs/: passed with no NFS diagnostics
- GCC 16 W=1 build of fs/nfs/ with KUnit disabled: passed
- Sparse C=2 checks of every touched C source: passed with no diagnostics
- GCC 16 W=1 full kernel and modules build: passed
- git diff --check: clean
- per-patch checkpatch: no errors or code warnings; patch 7 reports only the generic FILE_PATH_CHANGES warning for the new test files
Changes in v2:
- rebase from the NFS client linux-next integration commit 10f307e525a1
to v7.3-rc1
- free da_netid on file-layout and flexfiles temporary-address paths
- bound flexfiles GETDEVICEINFO version_count before allocation
- bound flexfiles LAYOUTGET fh_count before allocation
- expand flexfiles KUnit coverage from three to six cases, including the cache-hit and malformed-version cleanup paths
- rename the test patch to reflect the broader XDR coverage
v1: https://lore.kernel.org/r/[email protected]
Prabhakar Pujeri (7):
NFS: free netid when discarding pNFS DS addresses
NFS: bound flexfiles GETDEVICEINFO version count
NFS: bound flexfiles filehandle version count
NFS: validate pNFS data server port octets
NFS: bound multipath address count in file-layout GETDEVICEINFO
NFS: bound multipath address count in flexfiles GETDEVICEINFO
NFS: add KUnit coverage for pNFS XDR decoding
fs/nfs/Kconfig | 34 +++ fs/nfs/Makefile | 3 + fs/nfs/filelayout/filelayoutdev.c | 11 +- fs/nfs/flexfilelayout/Makefile | 3 + fs/nfs/flexfilelayout/flexfilelayout.c | 7 +- fs/nfs/flexfilelayout/flexfilelayout.h | 6 + fs/nfs/flexfilelayout/flexfilelayoutdev.c | 22 +- fs/nfs/flexfilelayout/tests/deviceid_kunit.c | 286 +++++++++++++++++++ fs/nfs/pnfs.h | 9 + fs/nfs/pnfs_nfs.c | 50 ++-- fs/nfs/tests/pnfs_decode_kunit.c | 222 ++++++++++++++ 11 files changed, 619 insertions(+), 34 deletions(-) create mode 100644 fs/nfs/flexfilelayout/tests/deviceid_kunit.c create mode 100644 fs/nfs/tests/pnfs_decode_kunit.c
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
Signature · 1 line
2.54.0
PATCH v2 1/7 NFS: free netid when discarding pNFS DS addresses
nfs4_decode_mp_ds_addr() transfers its r_netid allocation to da_netid. The generic data server destructor releases that field, but the file-layout and flexfiles drivers open-code the disposal of temporary address objects and omit it. Cache hits and later decode failures therefore leak one netid string per discarded address.
Make nfs4_pnfs_ds_addr_free() available to the layout modules and use it for every temporary address list.
--- fs/nfs/filelayout/filelayoutdev.c | 6 ++---- fs/nfs/flexfilelayout/flexfilelayoutdev.c | 6 ++---- fs/nfs/pnfs.h | 1 + fs/nfs/pnfs_nfs.c | 4 ++-- 4 files changed, 7 insertions(+), 10 deletions(-)
fs/nfs/filelayout/filelayoutdev.c +2 -4
@@ -182,8 +182,7 @@ nfs4_fl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, struct nfs4_pnfs_ds_addr, da_node);list_del_init (&da->da_node); -kfree (da->da_remotestr); -kfree (da); +nfs4_pnfs_ds_addr_free (da); } }
@@ -195,8 +194,7 @@ nfs4_fl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, da = list_first_entry(&dsaddrs, struct nfs4_pnfs_ds_addr, da_node);list_del_init (&da->da_node); -kfree (da->da_remotestr); -kfree (da); +nfs4_pnfs_ds_addr_free (da); } out_err_free_deviceid:nfs4_fl_free_deviceid (dsaddr);
fs/nfs/flexfilelayout/flexfilelayoutdev.c +2 -4
@@ -164,8 +164,7 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, struct nfs4_pnfs_ds_addr, da_node);list_del_init (&da->da_node); -kfree (da->da_remotestr); -kfree (da); +nfs4_pnfs_ds_addr_free (da); }folio_put (scratch);
@@ -176,8 +175,7 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, da = list_first_entry(&dsaddrs, struct nfs4_pnfs_ds_addr, da_node);list_del_init (&da->da_node); -kfree (da->da_remotestr); -kfree (da); +nfs4_pnfs_ds_addr_free (da); }kfree (ds_versions);
fs/nfs/pnfs.h +1 -0
@@ -415,6 +415,7 @@ int pnfs_generic_commit_pagelist(struct inode *inode, int how));int pnfs_generic_scan_commit_lists (struct nfs_commit_info *cinfo,int max);void pnfs_generic_write_commit_done (struct rpc_task *task,void *data); +void nfs4_pnfs_ds_addr_free (struct nfs4_pnfs_ds_addr *da);void nfs4_pnfs_ds_put (struct nfs4_pnfs_ds *ds); struct nfs4_pnfs_ds *nfs4_pnfs_ds_add(const struct net *net, struct list_head *dsaddrs,
fs/nfs/pnfs_nfs.c +2 -2
@@ -626,12 +626,13 @@ static struct nfs4_pnfs_ds_addr *nfs4_pnfs_ds_addr_alloc(gfp_t gfp_flags)return da; } -static void nfs4_pnfs_ds_addr_free (struct nfs4_pnfs_ds_addr *da) +void nfs4_pnfs_ds_addr_free (struct nfs4_pnfs_ds_addr *da) {kfree (da->da_remotestr);kfree (da->da_netid);kfree (da); } +EXPORT_SYMBOL_GPL (nfs4_pnfs_ds_addr_free);static void destroy_ds (struct nfs4_pnfs_ds *ds) {
@@ -1230,4 +1231,3 @@ pnfs_nfs_generic_sync(struct inode *inode, bool datasync)return pnfs_layoutcommit_inode (inode, true); }EXPORT_SYMBOL_GPL (pnfs_nfs_generic_sync); -
Signature · 1 line
2.54.0
PATCH v2 2/7 NFS: bound flexfiles GETDEVICEINFO version count
In reply to Prabhakar PujeriThe flexfiles GETDEVICEINFO decoder allocates ds_versions from a server-provided count before proving that the corresponding fixed-size XDR tuples are present. A large count can therefore provoke an oversized allocation from a short reply.
Each version tuple contains five XDR words. Bound the count by the bytes remaining in the stream before allocating the array, and use the same expression when decoding each tuple.
--- fs/nfs/flexfilelayout/flexfilelayoutdev.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/nfs/flexfilelayout/flexfilelayoutdev.c +3 -4
@@ -98,7 +98,8 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, goto out_err_drain_dsaddrs; version_count =be32_to_cpup (p); -if (version_count ==0 ) { +if (version_count ==0 || + version_count >xdr_stream_remaining (&stream) / (5 *XDR_UNIT )) { ret = -EINVAL ; goto out_err_drain_dsaddrs; }
@@ -110,9 +111,7 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, goto out_err_drain_dsaddrs;for (i =0 ; i < version_count; i++) { -/* 20 = version(4) + minor_version(4) + rsize(4) + wsize(4) + -* tightly_coupled(4) */ - p =xdr_inline_decode (&stream,20 ); + p =xdr_inline_decode (&stream,5 *XDR_UNIT );if (unlikely (!p)) goto out_err_drain_dsaddrs; ds_versions[i].version =be32_to_cpup (p++);
Signature · 1 line
2.54.0
PATCH v2 3/7 NFS: bound flexfiles filehandle version count
In reply to Prabhakar Pujeriff_layout_alloc_lseg() allocates a filehandle-version array from the server-provided fh_count before checking that the layout body can contain that many filehandles. A large count in a short reply can therefore trigger an oversized allocation.
Even an empty XDR opaque value consumes a length word. Bound fh_count by the number of length words remaining in the stream before allocating the array.
--- fs/nfs/flexfilelayout/flexfilelayout.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfs/flexfilelayout/flexfilelayout.c +2 -1
@@ -551,7 +551,8 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh,if (!p) goto out_err_free; fh_count =be32_to_cpup (p); -if (fh_count ==0 ) { +if (fh_count ==0 || + fh_count >xdr_stream_remaining (&stream) /XDR_UNIT ) { rc = -EINVAL ; goto out_err_free; }
Signature · 1 line
2.54.0
PATCH v2 4/7 NFS: validate pNFS data server port octets
In reply to Prabhakar Pujerinfs4_decode_mp_ds_addr() parses the two decimal port octets in a server-provided universal address with an unchecked sscanf(). A missing or non-numeric field leaves part of the temporary array uninitialized, while values outside the octet range are silently folded into the resulting port.
Split the two port fields at their delimiters and parse each with kstrtou8(). This rejects missing fields, trailing garbage, integer overflow, and values outside 0 through 255 before constructing the data server socket address.
--- fs/nfs/pnfs_nfs.c | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-)
fs/nfs/pnfs_nfs.c +28 -18
@@ -8,6 +8,7 @@* Tom Haynes <[email protected]> */ +#include <linux/ctype.h> #include <linux/nfs_fs.h> #include <linux/nfs_page.h> #include <linux/sunrpc/addr.h>
@@ -1064,6 +1065,19 @@ int nfs4_pnfs_ds_connect(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds, }EXPORT_SYMBOL_GPL (nfs4_pnfs_ds_connect); +static int +nfs4_parse_port_octet (const char *str,u8 *port) +{ +const char *p; + +if (!*str) +return -EINVAL ; +for (p = str; *p; p++) +if (!isdigit (*p)) +return -EINVAL ; +return kstrtou8 (str,10 , port); +} +/* * Currently only supports ipv4, ipv6 and one multi-path address. */
@@ -1071,10 +1085,10 @@ struct nfs4_pnfs_ds_addr * nfs4_decode_mp_ds_addr(struct net *net, struct xdr_stream *xdr, gfp_t gfp_flags) { struct nfs4_pnfs_ds_addr *da = NULL; -char *buf, *portstr; +char *buf, *portsep;__be16 port;ssize_t nlen, rlen; -int tmp[2 ]; +u8 porthi, portlo;char *netid;size_t len;char *startsep ="" ;
@@ -1094,37 +1108,33 @@ nfs4_decode_mp_ds_addr(struct net *net, struct xdr_stream *xdr, gfp_t gfp_flags)if (unlikely (rlen <=0 )) goto out_free_netid; -/* replace port '.' with '-' */ - portstr =strrchr (buf,'.' ); -if (!portstr) { -dprintk ("%s: Failed finding expected dot in port\n" , - __func__); +/* Parse the low port octet and remove it from the address string. */ + portsep =strrchr (buf,'.' ); +if (!portsep ||nfs4_parse_port_octet (portsep +1 , &portlo)) { +dprintk ("%s: Failed parsing low port octet\n" , __func__); goto out_free_buf; } - *portstr ='-' ; + *portsep ='\0' ; -/* find '.' between address and port */ - portstr =strrchr (buf,'.' ); -if (!portstr) { -dprintk ("%s: Failed finding expected dot between address and " -"port\n" , __func__); +/* Parse the high port octet and terminate the address string. */ + portsep =strrchr (buf,'.' ); +if (!portsep ||nfs4_parse_port_octet (portsep +1 , &porthi)) { +dprintk ("%s: Failed parsing high port octet\n" , __func__); goto out_free_buf; } - *portstr ='\0' ; + *portsep ='\0' ; da =nfs4_pnfs_ds_addr_alloc (gfp_flags);if (unlikely (!da)) goto out_free_buf; -if (!rpc_pton (net, buf, portstr-buf, (struct sockaddr *)&da->da_addr, +if (!rpc_pton (net, buf, portsep - buf, (struct sockaddr *)&da->da_addr,sizeof (da->da_addr))) {dprintk ("%s: error parsing address %s\n" , __func__, buf); goto out_free_da; } - portstr++; -sscanf (portstr,"%d-%d" , &tmp[0 ], &tmp[1 ]); - port =htons ((tmp[0 ] <<8 ) | (tmp[1 ])); + port =htons ((porthi <<8 ) | portlo);switch (da->da_addr.ss_family) {case AF_INET :
Signature · 1 line
2.54.0
PATCH v2 5/7 NFS: bound multipath address count in file-layout GETDEVICEINFO
In reply to Prabhakar Pujerinfs4_fl_alloc_deviceid_node() bounds the number of data-server multipath lists, but not the number of addresses in each list. The latter count is supplied by the server and can be as large as U32_MAX.
Once the XDR stream is exhausted, nfs4_decode_mp_ds_addr() returns NULL without consuming input. The enclosing loop can therefore spin for billions of iterations in kernel context when decoding a malicious GETDEVICEINFO response.
A netaddr4 contains at least the two XDR length words for its netid and universal-address strings. Reject a count when that minimum representation cannot fit in the remaining XDR stream. This makes the loop bound proportional to the reply length without imposing an arbitrary protocol limit.
Keep the existing file-layout multipath-list limit separate because that limit is tied to the u8 stripe-index representation.
--- fs/nfs/filelayout/filelayoutdev.c | 5 +++++ fs/nfs/pnfs.h | 8 ++++++++ 2 files changed, 13 insertions(+)
fs/nfs/filelayout/filelayoutdev.c +5 -0
@@ -159,6 +159,11 @@ nfs4_fl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, goto out_err_free_deviceid; mp_count =be32_to_cpup (p);/* multipath count */ +if (!nfs4_pnfs_ds_addr_count_valid (&stream, mp_count)) { +pr_warn_ratelimited ("NFS: %s: multipath address count %u exceeds XDR capacity\n" , + __func__, mp_count); + goto out_err_drain_dsaddrs; + }for (j =0 ; j < mp_count; j++) { da =nfs4_decode_mp_ds_addr (net, &stream, gfp_flags);if (da)
fs/nfs/pnfs.h +8 -0
@@ -33,11 +33,19 @@#include <linux/refcount.h> #include <linux/nfs_fs.h> #include <linux/nfs_page.h> +#include <linux/sunrpc/xdr.h> #include <linux/workqueue.h> struct nfs4_exception ;struct nfs4_opendata ; +/* A netaddr4 contains at least the length words of its two XDR strings. */ +static inline bool +nfs4_pnfs_ds_addr_count_valid (const struct xdr_stream *xdr,u32 count) +{ +return count <=xdr_stream_remaining (xdr) / (2 *sizeof (__be32)); +} +enum {NFS_LSEG_VALID =0 ,/* cleared when lseg is recalled/returned */ NFS_LSEG_ROC ,/* roc bit received from server */
Signature · 1 line
2.54.0
PATCH v2 6/7 NFS: bound multipath address count in flexfiles GETDEVICEINFO
In reply to Prabhakar Pujerinfs4_ff_alloc_deviceid_node() loops over a server-provided multipath address count without validating it. Once the XDR stream is exhausted, nfs4_decode_mp_ds_addr() returns NULL without consuming input, so a count near U32_MAX can keep the client spinning in kernel context for billions of iterations.
A netaddr4 contains at least the two XDR length words for its netid and universal-address strings. Reject a count when that minimum representation cannot fit in the remaining XDR stream. This makes the loop bound proportional to the reply length without imposing an arbitrary protocol limit, matching the protection in the file-layout decoder.
--- fs/nfs/flexfilelayout/flexfilelayoutdev.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/nfs/flexfilelayout/flexfilelayoutdev.c +5 -0
@@ -78,6 +78,11 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, goto out_err_drain_dsaddrs; mp_count =be32_to_cpup (p);dprintk ("%s: multipath ds count %d\n" , __func__, mp_count); +if (!nfs4_pnfs_ds_addr_count_valid (&stream, mp_count)) { +pr_warn_ratelimited ("NFS: %s: multipath address count %u exceeds XDR capacity\n" , + __func__, mp_count); + goto out_err_drain_dsaddrs; + }for (i =0 ; i < mp_count; i++) {/* multipath ds */
Signature · 1 line
2.54.0
PATCH v2 7/7 NFS: add KUnit coverage for pNFS XDR decoding
In reply to Prabhakar PujeriAdd page-backed tests for nfs4_decode_mp_ds_addr(). Cover valid IPv4 and IPv6 universal addresses, boundary port values, missing fields, non-numeric fields, out-of-range values, integer overflow, and trailing garbage.
Exercise the flexfiles GETDEVICEINFO decoder with valid device data, cache reuse, and zero or oversized multipath and version counts. Exercise the LAYOUTGET decoder with an oversized filehandle-version count. The cache-reuse and malformed-version cases also drive both temporary-address cleanup paths.
Export the flexfiles decoder helpers only when KUnit is enabled and keep the suites behind guideline-compliant Kconfig entries that default with KUNIT_ALL_TESTS.
--- fs/nfs/Kconfig | 34 +++ fs/nfs/Makefile | 3 + fs/nfs/flexfilelayout/Makefile | 3 + fs/nfs/flexfilelayout/flexfilelayout.c | 4 +- fs/nfs/flexfilelayout/flexfilelayout.h | 6 + fs/nfs/flexfilelayout/flexfilelayoutdev.c | 4 + fs/nfs/flexfilelayout/tests/deviceid_kunit.c | 286 +++++++++++++++++++ fs/nfs/tests/pnfs_decode_kunit.c | 222 ++++++++++++++ 8 files changed, 561 insertions(+), 1 deletion(-) create mode 100644 fs/nfs/flexfilelayout/tests/deviceid_kunit.c create mode 100644 fs/nfs/tests/pnfs_decode_kunit.c
fs/nfs/Kconfig +34 -0
@@ -215,3 +215,37 @@ config NFS_V4_2_READ_PLUS default y help Choose Y here to enable use of the NFS v4.2 READ_PLUS operation. + +config NFS_PNFS_DECODE_KUNIT_TEST + tristate "KUnit tests for pNFS data server address decoding" if !KUNIT_ALL_TESTS + depends on NFS_V4 && KUNIT + default KUNIT_ALL_TESTS + help + This builds KUnit tests for the pNFS data server address decoder. + The tests cover valid IPv4 and IPv6 universal addresses and malformed + port fields supplied by an NFS server. They verify that invalid port + octets cannot produce a usable data server socket address. + Results are reported in TAP format when the test module is loaded on a + KUnit-enabled kernel. + + For more information on KUnit and unit tests in general, refer to + Documentation/dev-tools/kunit/. + + If unsure, say N. + +config NFS_FLEXFILE_DEVICEID_KUNIT_TEST + tristate "KUnit tests for flexfiles XDR decoding" if !KUNIT_ALL_TESTS + depends on PNFS_FLEXFILE_LAYOUT && KUNIT + default KUNIT_ALL_TESTS + help + This builds KUnit tests for the flexfiles GETDEVICEINFO and LAYOUTGET + decoders. The tests cover valid device information, data-server cache + reuse, and malformed address, version, and filehandle counts supplied + by an NFS server. + Results are reported in TAP format when the test module is loaded on a + KUnit-enabled kernel. + + For more information on KUnit and unit tests in general, refer to + Documentation/dev-tools/kunit/. + + If unsure, say N.
fs/nfs/Makefile +3 -0
@@ -33,6 +33,9 @@ nfsv4-$(CONFIG_SYSCTL) += nfs4sysctl.o nfsv4-$(CONFIG_NFS_V4_0) += nfs40client.o nfs40proc.o nfsv4-$(CONFIG_NFS_V4_2) += nfs42proc.o nfs42xattr.o +obj-$(CONFIG_NFS_PNFS_DECODE_KUNIT_TEST) += nfs_pnfs_decode_kunit.o +nfs_pnfs_decode_kunit-y := tests/pnfs_decode_kunit.o + obj-$(CONFIG_PNFS_FILE_LAYOUT) += filelayout/ obj-$(CONFIG_PNFS_BLOCK) += blocklayout/ obj-$(CONFIG_PNFS_FLEXFILE_LAYOUT) += flexfilelayout/
fs/nfs/flexfilelayout/Makefile +3 -0
@@ -4,3 +4,6 @@ # obj-$(CONFIG_PNFS_FLEXFILE_LAYOUT) += nfs_layout_flexfiles.o nfs_layout_flexfiles-y := flexfilelayout.o flexfilelayoutdev.o + +obj-$(CONFIG_NFS_FLEXFILE_DEVICEID_KUNIT_TEST) += nfs_flexfile_deviceid_kunit.o +nfs_flexfile_deviceid_kunit-y := tests/deviceid_kunit.o
fs/nfs/flexfilelayout/flexfilelayout.c +3 -1
@@ -13,6 +13,7 @@#include <linux/module.h> #include <linux/file.h> #include <linux/sched/mm.h> +#include <kunit/visibility.h> #include <linux/sunrpc/metrics.h>
@@ -442,7 +443,7 @@ static void ff_layout_sort_mirrors(struct nfs4_ff_layout_segment *fls) } } -static struct pnfs_layout_segment * +VISIBLE_IF_KUNIT struct pnfs_layout_segment *ff_layout_alloc_lseg (struct pnfs_layout_hdr *lh,struct nfs4_layoutget_res *lgr,gfp_t gfp_flags)
@@ -660,6 +661,7 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh,dprintk ("<-- %s (%d)\n" , __func__, rc); goto out_free_page; } +EXPORT_SYMBOL_IF_KUNIT (ff_layout_alloc_lseg);static void ff_layout_free_lseg (struct pnfs_layout_segment *lseg)
fs/nfs/flexfilelayout/flexfilelayout.h +6 -0
@@ -228,6 +228,12 @@ nfs4_ff_layout_calc_dss_id(const u64 stripe_unit, const u32 dss_count, const lofstruct nfs4_ff_layout_ds *nfs4_ff_alloc_deviceid_node (struct nfs_server *server,struct pnfs_device *pdev,gfp_t gfp_flags); +#if IS_ENABLED (CONFIG_KUNIT ) +struct pnfs_layout_segment * +ff_layout_alloc_lseg (struct pnfs_layout_hdr *lh, +struct nfs4_layoutget_res *lgr, +gfp_t gfp_flags); +#endif void nfs4_ff_layout_put_deviceid (struct nfs4_ff_layout_ds *mirror_ds);void nfs4_ff_layout_free_deviceid (struct nfs4_ff_layout_ds *mirror_ds); int ff_layout_track_ds_error(struct nfs4_flexfile_layout *flo,
fs/nfs/flexfilelayout/flexfilelayoutdev.c +4 -0
@@ -12,6 +12,8 @@#include <linux/module.h> #include <linux/sunrpc/addr.h> +#include <kunit/visibility.h> +#include "../internal.h" #include "../nfs4session.h" #include "flexfilelayout.h"
@@ -36,6 +38,7 @@ void nfs4_ff_layout_free_deviceid(struct nfs4_ff_layout_ds *mirror_ds)kfree (mirror_ds->ds_versions);kfree_rcu (mirror_ds, id_node.rcu); } +EXPORT_SYMBOL_IF_KUNIT (nfs4_ff_layout_free_deviceid);/* Decode opaque device data and construct new_ds using it */ struct nfs4_ff_layout_ds *
@@ -191,6 +194,7 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,dprintk ("%s ERROR: returning %d\n" , __func__, ret);return NULL ; } +EXPORT_SYMBOL_IF_KUNIT (nfs4_ff_alloc_deviceid_node);static void extend_ds_error (struct nfs4_ff_layout_ds_err *err,u64 offset,u64 length)
fs/nfs/flexfilelayout/tests/deviceid_kunit.c new file +286 -0
286 lines not on this page · raw message
fs/nfs/tests/pnfs_decode_kunit.c new file +222 -0
222 lines not on this page · raw message
Signature · 1 line
2.54.0