diff --git a/SOURCES/nfs-utils-2.5.4-covscan-return-value.patch b/SOURCES/nfs-utils-2.5.4-covscan-return-value.patch new file mode 100644 index 0000000..0d3088a --- /dev/null +++ b/SOURCES/nfs-utils-2.5.4-covscan-return-value.patch @@ -0,0 +1,25 @@ +diff -up nfs-utils-2.5.4/support/export/client.c.orig nfs-utils-2.5.4/support/export/client.c +--- nfs-utils-2.5.4/support/export/client.c.orig 2021-06-10 14:07:47.000000000 -0400 ++++ nfs-utils-2.5.4/support/export/client.c 2023-01-26 11:26:00.279342412 -0500 +@@ -699,6 +699,9 @@ check_netgroup(const nfs_client *clp, co + + /* check whether the IP itself is in the netgroup */ + ip = calloc(INET6_ADDRSTRLEN, 1); ++ if (ip == NULL) ++ goto out; ++ + if (inet_ntop(ai->ai_family, &(((struct sockaddr_in *)ai->ai_addr)->sin_addr), ip, INET6_ADDRSTRLEN) == ip) { + if (innetgr(netgroup, ip, NULL, NULL)) { + free(hname); +diff -up nfs-utils-2.5.4/tools/nfsrahead/main.c.orig nfs-utils-2.5.4/tools/nfsrahead/main.c +--- nfs-utils-2.5.4/tools/nfsrahead/main.c.orig 2023-01-26 11:23:48.941618287 -0500 ++++ nfs-utils-2.5.4/tools/nfsrahead/main.c 2023-01-26 11:26:00.279342412 -0500 +@@ -167,7 +167,7 @@ int main(int argc, char **argv) + if ((ret = get_device_info(argv[optind], &device)) == 0) + break; + +- if (ret != 0) { ++ if (ret != 0 || device.fstype == NULL) { + xlog(D_GENERAL, "unable to find device %s\n", argv[optind]); + goto out; + } diff --git a/SOURCES/nfs-utils-2.5.4-mount-null-ptr.patch b/SOURCES/nfs-utils-2.5.4-mount-null-ptr.patch new file mode 100644 index 0000000..1143018 --- /dev/null +++ b/SOURCES/nfs-utils-2.5.4-mount-null-ptr.patch @@ -0,0 +1,27 @@ +commit ea536a2e641664c8ea439e5e571e757785f587c9 +Author: Zhi Li +Date: Mon Oct 24 13:31:41 2022 -0400 + + mount.nfs: fix NULL pointer derefernce in nfs_parse_square_bracket + + In function nfs_parse_square_bracket, hostname could be NULL, + dereferencing it in free(*hostname) may cause an unexpected segfault. + + Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2136807 + Signed-off-by: Zhi Li + Signed-off-by: Steve Dickson + +diff --git a/utils/mount/parse_dev.c b/utils/mount/parse_dev.c +index 0d3bcb95..2ade5d5d 100644 +--- a/utils/mount/parse_dev.c ++++ b/utils/mount/parse_dev.c +@@ -170,7 +170,8 @@ static int nfs_parse_square_bracket(const char *dev, + if (pathname) { + *pathname = strndup(cbrace, path_len); + if (*pathname == NULL) { +- free(*hostname); ++ if (hostname) ++ free(*hostname); + return nfs_pdn_nomem_err(); + } + } diff --git a/SOURCES/nfs-utils-2.5.4-nfsd-man-4vers.patch b/SOURCES/nfs-utils-2.5.4-nfsd-man-4vers.patch new file mode 100644 index 0000000..4870443 --- /dev/null +++ b/SOURCES/nfs-utils-2.5.4-nfsd-man-4vers.patch @@ -0,0 +1,26 @@ +commit d4de031fbb2d797ec9e738deda50feec97db7593 +Author: Steve Dickson +Date: Fri Oct 28 10:56:36 2022 -0400 + + nfsd.man: Explain that setting nfsv4=n turns off all v4 versions + + Update the man page to explicitly say setting + nfsv4=n turns off all v4 versions + + Signed-off-by: Steve Dickson + +diff --git a/utils/nfsd/nfsd.man b/utils/nfsd/nfsd.man +index 634b8a63..bb99fe2b 100644 +--- a/utils/nfsd/nfsd.man ++++ b/utils/nfsd/nfsd.man +@@ -159,7 +159,9 @@ Enable or disable TCP support. + .B vers3 + .TP + .B vers4 +-Enable or disable a major NFS version. 3 and 4 are normally enabled ++Enable or disable ++.B all ++NFSv4 versions. All versions are normally enabled + by default. + .TP + .B vers4.1 diff --git a/SOURCES/nfs-utils-2.5.4-nfsrahead-cmd.patch b/SOURCES/nfs-utils-2.5.4-nfsrahead-cmd.patch new file mode 100644 index 0000000..8c52c89 --- /dev/null +++ b/SOURCES/nfs-utils-2.5.4-nfsrahead-cmd.patch @@ -0,0 +1,406 @@ +diff --git a/.gitignore b/.gitignore +index c89d1cd2..df791a83 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -61,6 +61,8 @@ utils/statd/statd + tools/locktest/testlk + tools/getiversion/getiversion + tools/nfsconf/nfsconf ++tools/nfsrahead/nfsrahead ++tools/nfsrahead/99-nfs_bdi.rules + support/export/mount.h + support/export/mount_clnt.c + support/export/mount_xdr.c +diff --git a/configure.ac b/configure.ac +index d01ce6e4..3f48bd54 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -251,6 +251,16 @@ AC_ARG_ENABLE(nfsdcld, + enable_nfsdcld=$enableval, + enable_nfsdcld="yes") + ++AC_ARG_ENABLE(nfsrahead, ++ [AS_HELP_STRING([--disable-nfsrahead],[disable nfsrahead command @<:@default=no@:>@])], ++ enable_nfsrahead=$enableval, ++ enable_nfsrahead="yes") ++ AM_CONDITIONAL(CONFIG_NFSRAHEAD, [test "$enable_nfsrahead" = "yes" ]) ++ if test "$enable_nfsrahead" = yes; then ++ dnl Check for -lmount ++ PKG_CHECK_MODULES([LIBMOUNT], [mount]) ++ fi ++ + AC_ARG_ENABLE(nfsdcltrack, + [AC_HELP_STRING([--disable-nfsdcltrack], + [disable NFSv4 clientid tracking programs @<:@default=no@:>@])], +@@ -712,6 +722,7 @@ AC_CONFIG_FILES([ + tools/rpcgen/Makefile + tools/mountstats/Makefile + tools/nfs-iostat/Makefile ++ tools/nfsrahead/Makefile + tools/rpcctl/Makefile + tools/nfsdclnts/Makefile + tools/nfsconf/Makefile +diff --git a/nfs.conf b/nfs.conf +index bc1de8d1..6aec1dd9 100644 +--- a/nfs.conf ++++ b/nfs.conf +@@ -5,6 +5,10 @@ + [general] + # pipefs-directory=/var/lib/nfs/rpc_pipefs + # ++[nfsrahead] ++# nfs=15000 ++# nfs4=16000 ++# + [exports] + # rootdir=/export + # +diff --git a/systemd/nfs.conf.man b/systemd/nfs.conf.man +index be487a11..e74083e9 100644 +--- a/systemd/nfs.conf.man ++++ b/systemd/nfs.conf.man +@@ -294,6 +294,17 @@ Only + .B debug= + is recognized. + ++.TP ++.B nfsrahead ++Recognized values: ++.BR nfs , ++.BR nfsv4 , ++.BR default . ++ ++See ++.BR nfsrahead (5) ++for deatils. ++ + .SH FILES + .TP 10n + .I /etc/nfs.conf +diff --git a/tools/Makefile.am b/tools/Makefile.am +index c3feabbe..48fd0cdf 100644 +--- a/tools/Makefile.am ++++ b/tools/Makefile.am +@@ -12,6 +12,10 @@ if CONFIG_NFSDCLD + OPTDIRS += nfsdclddb + endif + ++if CONFIG_NFSRAHEAD ++OPTDIRS += nfsrahead ++endif ++ + SUBDIRS = locktest rpcdebug nlmtest mountstats nfs-iostat rpcctl nfsdclnts $(OPTDIRS) + + MAINTAINERCLEANFILES = Makefile.in +diff --git a/tools/nfsrahead/99-nfs.rules b/tools/nfsrahead/99-nfs.rules +new file mode 100644 +index 00000000..c74914b2 +--- /dev/null ++++ b/tools/nfsrahead/99-nfs.rules +@@ -0,0 +1 @@ ++SUBSYSTEM=="bdi", ACTION=="add", PROGRAM="/usr/libexec/nfsrahead %k", ATTR{read_ahead_kb}="%c" +diff --git a/tools/nfsrahead/99-nfs.rules.in b/tools/nfsrahead/99-nfs.rules.in +new file mode 100644 +index 00000000..648813c5 +--- /dev/null ++++ b/tools/nfsrahead/99-nfs.rules.in +@@ -0,0 +1 @@ ++SUBSYSTEM=="bdi", ACTION=="add", PROGRAM="_libexecdir_/nfsrahead %k", ATTR{read_ahead_kb}="%c" +diff --git a/tools/nfsrahead/Makefile.am b/tools/nfsrahead/Makefile.am +new file mode 100644 +index 00000000..7e08233a +--- /dev/null ++++ b/tools/nfsrahead/Makefile.am +@@ -0,0 +1,16 @@ ++libexec_PROGRAMS = nfsrahead ++nfsrahead_SOURCES = main.c ++nfsrahead_LDFLAGS= $(LIBMOUNT_LIBS) ++nfsrahead_LDADD = ../../support/nfs/libnfsconf.la ++ ++man5_MANS = nfsrahead.man ++EXTRA_DIST = $(man5_MANS) ++ ++udev_rulesdir = /usr/lib/udev/rules.d/ ++udev_rules_DATA = 99-nfs.rules ++ ++99-nfs.rules: 99-nfs.rules.in $(builddefs) ++ $(SED) "s|_libexecdir_|@libexecdir@|g" 99-nfs.rules.in > $@ ++ ++clean-local: ++ $(RM) 99-nfs.rules +diff --git a/tools/nfsrahead/main.c b/tools/nfsrahead/main.c +new file mode 100644 +index 00000000..c83c6f71 +--- /dev/null ++++ b/tools/nfsrahead/main.c +@@ -0,0 +1,192 @@ ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++#include "xlog.h" ++#include "conffile.h" ++ ++#ifndef MOUNTINFO_PATH ++#define MOUNTINFO_PATH "/proc/self/mountinfo" ++#endif ++ ++#define CONF_NAME "nfsrahead" ++#define NFS_DEFAULT_READAHEAD 128 ++ ++/* Device information from the system */ ++struct device_info { ++ char *device_number; ++ dev_t dev; ++ char *mountpoint; ++ char *fstype; ++}; ++ ++/* Convert a string in the format n:m to a device number */ ++static int fill_device_number(struct device_info *info) ++{ ++ char *s = strdup(info->device_number), *p; ++ char *maj_s, *min_s; ++ unsigned int maj, min; ++ int err = -EINVAL; ++ ++ maj_s = p = s; ++ for ( ; *p != ':' && *p != '\0'; p++) ++ ; ++ ++ if (*p == '\0') ++ goto out_free; ++ ++ err = 0; ++ *p = '\0'; ++ min_s = p + 1; ++ ++ maj = strtol(maj_s, NULL, 10); ++ min = strtol(min_s, NULL, 10); ++ ++ info->dev = makedev(maj, min); ++out_free: ++ free(s); ++ return err; ++} ++ ++#define sfree(ptr) if (ptr) free(ptr) ++ ++/* device_info maintenance */ ++static void init_device_info(struct device_info *di, const char *device_number) ++{ ++ di->device_number = strdup(device_number); ++ di->dev = 0; ++ di->mountpoint = NULL; ++ di->fstype = NULL; ++} ++ ++ ++static void free_device_info(struct device_info *di) ++{ ++ sfree(di->mountpoint); ++ sfree(di->fstype); ++ sfree(di->device_number); ++} ++ ++static int get_mountinfo(const char *device_number, struct device_info *device_info, const char *mountinfo_path) ++{ ++ int ret = 0; ++ struct libmnt_table *mnttbl; ++ struct libmnt_fs *fs; ++ char *target; ++ ++ init_device_info(device_info, device_number); ++ if ((ret = fill_device_number(device_info)) < 0) ++ goto out_free_device_info; ++ ++ mnttbl = mnt_new_table(); ++ ++ if ((ret = mnt_table_parse_file(mnttbl, mountinfo_path)) < 0) { ++ xlog(D_GENERAL, "Failed to parse %s\n", mountinfo_path); ++ goto out_free_tbl; ++ } ++ ++ if ((fs = mnt_table_find_devno(mnttbl, device_info->dev, MNT_ITER_FORWARD)) == NULL) { ++ ret = ENOENT; ++ goto out_free_tbl; ++ } ++ ++ if ((target = (char *)mnt_fs_get_target(fs)) == NULL) { ++ ret = ENOENT; ++ goto out_free_fs; ++ } ++ ++ device_info->mountpoint = strdup(target); ++ target = (char *)mnt_fs_get_fstype(fs); ++ if (target) ++ device_info->fstype = strdup(target); ++ ++out_free_fs: ++ mnt_free_fs(fs); ++out_free_tbl: ++ mnt_free_table(mnttbl); ++out_free_device_info: ++ free(device_info->device_number); ++ device_info->device_number = NULL; ++ return ret; ++} ++ ++static int get_device_info(const char *device_number, struct device_info *device_info) ++{ ++ int ret = ENOENT; ++ for (int retry_count = 0; retry_count < 10 && ret != 0; retry_count++) ++ ret = get_mountinfo(device_number, device_info, MOUNTINFO_PATH); ++ ++ return ret; ++} ++ ++static int conf_get_readahead(const char *kind) { ++ int readahead = 0; ++ ++ if((readahead = conf_get_num(CONF_NAME, kind, -1)) == -1) ++ readahead = conf_get_num(CONF_NAME, "default", NFS_DEFAULT_READAHEAD); ++ ++ return readahead; ++} ++ ++int main(int argc, char **argv) ++{ ++ int ret = 0, retry, opt; ++ struct device_info device; ++ unsigned int readahead = 128, log_level, log_stderr = 0; ++ ++ ++ log_level = D_ALL & ~D_GENERAL; ++ while((opt = getopt(argc, argv, "dF")) != -1) { ++ switch (opt) { ++ case 'd': ++ log_level = D_ALL; ++ break; ++ case 'F': ++ log_stderr = 1; ++ break; ++ } ++ } ++ ++ conf_init_file(NFS_CONFFILE); ++ ++ xlog_stderr(log_stderr); ++ xlog_syslog(~log_stderr); ++ xlog_config(log_level, 1); ++ xlog_open(CONF_NAME); ++ ++ // xlog_err causes the system to exit ++ if ((argc - optind) != 1) ++ xlog_err("expected the device number of a BDI; is udev ok?"); ++ ++ for (retry = 0; retry <= 10; retry++ ) ++ if ((ret = get_device_info(argv[optind], &device)) == 0) ++ break; ++ ++ if (ret != 0) { ++ xlog(D_GENERAL, "unable to find device %s\n", argv[optind]); ++ goto out; ++ } ++ ++ if (strncmp("nfs", device.fstype, 3) != 0) { ++ xlog(D_GENERAL, ++ "not setting readahead for non supported fstype %s on device %s\n", ++ device.fstype, argv[optind]); ++ ret = -EINVAL; ++ goto out; ++ } ++ ++ readahead = conf_get_readahead(device.fstype); ++ ++ xlog(D_FAC7, "setting %s readahead to %d\n", device.mountpoint, readahead); ++ ++ printf("%d\n", readahead); ++ ++out: ++ free_device_info(&device); ++ return ret; ++} +diff --git a/tools/nfsrahead/nfsrahead.man b/tools/nfsrahead/nfsrahead.man +new file mode 100644 +index 00000000..5488f633 +--- /dev/null ++++ b/tools/nfsrahead/nfsrahead.man +@@ -0,0 +1,72 @@ ++.\" Manpage for nfsrahead. ++.nh ++.ad l ++.TH man 5 "08 Mar 2022" "1.0" "nfsrahead man page" ++.SH NAME ++ ++nfsrahead \- Configure the readahead for NFS mounts ++ ++.SH SYNOPSIS ++ ++nfsrahead [-F] [-d] ++ ++.SH DESCRIPTION ++ ++\fInfsrahead\fR is a tool intended to be used with udev to set the \fIread_ahead_kb\fR parameter of NFS mounts, according to the configuration file (see \fICONFIGURATION\fR). \fIdevice\fR is the device number for the NFS backing device as provided by the kernel. ++ ++.SH OPTIONS ++.TP ++.B -F ++Send messages to ++.I stderr ++instead of ++.I syslog ++ ++.TP ++.B -d ++Increase the debugging level. ++ ++.SH CONFIGURATION ++.I nfsrahead ++is configured in ++.IR /etc/nfs.conf , ++in the section titled ++.IR nfsrahead . ++It accepts the following configurations. ++ ++.TP ++.B nfs= ++The readahead value applied to NFSv3 mounts. ++ ++.TP ++.B nfs4= ++The readahead value applied to NFSv4 mounts. ++ ++.TP ++.B default= ++The default configuration when none of the configurations above is set. ++ ++.SH EXAMPLE CONFIGURATION ++[nfsrahead] ++.br ++nfs=15000 # readahead of 15000 for NFSv3 mounts ++.br ++nfs4=16000 # readahead of 16000 for NFSv4 mounts ++.br ++default=128 # default is 128 ++ ++.SH SEE ALSO ++ ++.BR mount.nfs (8), ++.BR nfs (5), ++.BR nfs.conf (5), ++.BR udev (7), ++.BR bcc-readahead (8) ++ ++.SH BUGS ++ ++No known bugs. ++ ++.SH AUTHOR ++ ++Thiago Rafael Becker diff --git a/SPECS/nfs-utils.spec b/SPECS/nfs-utils.spec index d01d891..5ff78bc 100644 --- a/SPECS/nfs-utils.spec +++ b/SPECS/nfs-utils.spec @@ -2,7 +2,7 @@ Summary: NFS utilities and supporting clients and daemons for the kernel NFS ser Name: nfs-utils URL: http://linux-nfs.org/ Version: 2.5.4 -Release: 15%{?dist} +Release: 18%{?dist} Epoch: 1 # group all 32bit related archs @@ -34,6 +34,14 @@ Patch010: nfs-utils-2.5.4-mount-ebusy.patch Patch011: nfs-utils-2.5.4-rpcctl-xprt.patch Patch012: nfs-utils-2.5.4-systemd-rpcstatd.patch +# +# RHEL9.2 +# +Patch013: nfs-utils-2.5.4-nfsd-man-4vers.patch +Patch014: nfs-utils-2.5.4-mount-null-ptr.patch +Patch015: nfs-utils-2.5.4-nfsrahead-cmd.patch +Patch016: nfs-utils-2.5.4-covscan-return-value.patch + Patch100: nfs-utils-1.2.1-statdpath-man.patch Patch101: nfs-utils-1.2.1-exp-subtree-warn-off.patch Patch102: nfs-utils-1.2.5-idmap-errmsg.patch @@ -360,6 +368,8 @@ fi %{_sbindir}/nfsdcld %{_sbindir}/nfsdclddb %{_sbindir}/nfsdclnts +%{_libexecdir}/nfsrahead +%{_udevrulesdir}/99-nfs.rules %{_mandir}/*/* %{_pkgdir}/*/* @@ -396,6 +406,8 @@ fi %{_sbindir}/rpc.gssd %{_sbindir}/start-statd %{_sbindir}/showmount +%{_libexecdir}/nfsrahead +%{_udevrulesdir}/99-nfs.rules %attr(4755,root,root) /sbin/mount.nfs /sbin/mount.nfs4 /sbin/rpc.statd @@ -415,6 +427,7 @@ fi %{_mandir}/*/showmount.8.gz %{_mandir}/*/statd.8.gz %{_mandir}/*/umount.nfs.8.gz +%{_mandir}/*/nfsrahead.5.gz %{_pkgdir}/*/rpc-pipefs-generator %{_pkgdir}/*/auth-rpcgss-module.service %{_pkgdir}/*/nfs-client.target @@ -435,6 +448,8 @@ fi %{_sbindir}/rpcctl %{_sbindir}/nfsidmap %{_sbindir}/nfsstat +%{_libexecdir}/nfsrahead +%{_udevrulesdir}/99-nfs.rules %attr(4755,root,root) /sbin/mount.nfs /sbin/mount.nfs4 /sbin/umount.nfs @@ -442,6 +457,7 @@ fi %{_mandir}/*/nfs.5.gz %{_mandir}/*/nfs.conf.5.gz %{_mandir}/*/nfsmount.conf.5.gz +%{_mandir}/*/nfsrahead.5.gz %{_mandir}/*/gssd.8.gz %{_mandir}/*/mount.nfs.8.gz %{_mandir}/*/nfsconf.8.gz @@ -466,6 +482,16 @@ fi %{_mandir}/*/nfsiostat.8.gz %changelog +* Thu Jan 26 2023 Steve Dickson 2.5.4-18 +- Covscan Scan: Wrong Check of Return Value (bz 2151968) + +* Thu Dec 1 2022 Steve Dickson 2.5.4-17 +- Create the nfsrahead command (bz 2143747) + +* Mon Nov 14 2022 Steve Dickson 2.5.4-16 +- nfsd.man: Explain that setting nfsv4=n turns off all v4 versions (bz 2042362) +- mount.nfs: fix NULL pointer derefernce in nfs_parse_square_bracket (bz 2136807) + * Thu Aug 18 2022 Steve Dickson 2.5.4-15 - Fix uninstall warnings (bz 2048023) - rpc-statd.service: Stop rpcbind and rpc.stat in an exit race (bz 2112941)