nfsd: remove legacy tracking methods
Subsystems (3)
Jeff Layton
maintainercover nfsd: remove legacy tracking methods
Around three years ago, we added CONFIG_NFSD_LEGACY_CLIENT_TRACKING with the intent to eventually remove the code that it compiles in when enabled. A little over a year ago, we switched the default for it to "n".
All of the major distros now disable this option, so finish the job by finally removing the config option altogether. With this, nfsdcld becomes the sole way to do v4 recovery tracking.
This also finally gets rid of the dependency on MD5 hashing that the legacy recdir method used, which will mean that FIPS auditors will stop dinging us too.
I think we should shoot for putting this in v7.5. Anyone have objections?
---
Jeff Layton (2):
nfsd: remove the nfsdcltrack usermodehelper tracking backend
nfsd: remove CONFIG_NFSD_LEGACY_CLIENT_TRACKING
arch/s390/configs/debug_defconfig | 1 - arch/s390/configs/defconfig | 1 - fs/nfsd/Kconfig | 17 - fs/nfsd/netns.h | 1 - fs/nfsd/nfs4ctl.h | 8 +- fs/nfsd/nfs4recover.c | 998 +------------------------------------- fs/nfsd/nfsctl.c | 79 --- fs/nfsd/state.h | 4 - fs/nfsd/trace.h | 19 - 9 files changed, 3 insertions(+), 1125 deletions(-)
---
base-commit: cab95e6be3ba82bcf4c8be27c2eb20e55238aa41
change-id: 20260923-nfsd-legacy-468be4ee7773
Best regards,
Signature · 1 line
Jeff Layton <[email protected]>
Jeff Layton
maintainerPATCH 1/2 nfsd: remove the nfsdcltrack usermodehelper tracking backend
The usermodehelper upcall to /sbin/nfsdcltrack was deprecated with the rest of the legacy client tracking methods. It never worked in containers and nfsdcld has superseded it. Remove the backend and the cltrack_prog and cltrack_legacy_disable module parameters.
--- fs/nfsd/nfs4recover.c | 347 +------------------------------------------------- 1 file changed, 1 insertion(+), 346 deletions(-)
fs/nfsd/nfs4recover.c +1 -346
@@ -1611,358 +1611,13 @@ static const struct nfsd4_client_tracking_ops nfsd4_cld_tracking_ops_v2 = { };#ifdef CONFIG_NFSD_LEGACY_CLIENT_TRACKING -/* upcall via usermodehelper */ -static char cltrack_prog[PATH_MAX ] ="/sbin/nfsdcltrack" ; -module_param_string (cltrack_prog, cltrack_prog,sizeof (cltrack_prog), -S_IRUGO |S_IWUSR ); -MODULE_PARM_DESC (cltrack_prog,"Path to the nfsdcltrack upcall program" ); - -static bool cltrack_legacy_disable; -module_param (cltrack_legacy_disable, bool,S_IRUGO |S_IWUSR ); -MODULE_PARM_DESC (cltrack_legacy_disable, -"Disable legacy recoverydir conversion. Default: false" ); - -#define LEGACY_TOPDIR_ENV_PREFIX "NFSDCLTRACK_LEGACY_TOPDIR=" -#define LEGACY_RECDIR_ENV_PREFIX "NFSDCLTRACK_LEGACY_RECDIR=" -#define HAS_SESSION_ENV_PREFIX "NFSDCLTRACK_CLIENT_HAS_SESSION=" -#define GRACE_START_ENV_PREFIX "NFSDCLTRACK_GRACE_START=" - -static char * -nfsd4_cltrack_legacy_topdir (void ) -{ -int copied; -size_t len; -char *result; - -if (cltrack_legacy_disable) -return NULL ; - - len =strlen (LEGACY_TOPDIR_ENV_PREFIX ) + -strlen (nfs4_recoverydir ()) +1 ; - - result =kmalloc (len,GFP_KERNEL ); -if (!result) -return result; - - copied =snprintf (result, len,LEGACY_TOPDIR_ENV_PREFIX "%s" , -nfs4_recoverydir ()); -if (copied >= len) { -/* just return nothing if output was truncated */ -kfree (result); -return NULL ; - } - -return result; -} - -static char * -nfsd4_cltrack_legacy_recdir (const struct xdr_netobj *name) -{ -int copied; -size_t len; -char *result; - -if (cltrack_legacy_disable) -return NULL ; - -/* +1 is for '/' between "topdir" and "recdir" */ - len =strlen (LEGACY_RECDIR_ENV_PREFIX ) + -strlen (nfs4_recoverydir ()) +1 +HEXDIR_LEN ; - - result =kmalloc (len,GFP_KERNEL ); -if (!result) -return result; - - copied =snprintf (result, len,LEGACY_RECDIR_ENV_PREFIX "%s/" , -nfs4_recoverydir ()); -if (copied > (len -HEXDIR_LEN )) { -/* just return nothing if output will be truncated */ -kfree (result); -return NULL ; - } - -nfs4_make_rec_clidname (result + copied, name); - -return result; -} - -static char * -nfsd4_cltrack_client_has_session (struct nfs4_client *clp) -{ -int copied; -size_t len; -char *result; - -/* prefix + Y/N character + terminating NULL */ - len =strlen (HAS_SESSION_ENV_PREFIX ) +1 +1 ; - - result =kmalloc (len,GFP_KERNEL ); -if (!result) -return result; - - copied =snprintf (result, len,HAS_SESSION_ENV_PREFIX "%c" , - clp->cl_minorversion ?'Y' :'N' ); -if (copied >= len) { -/* just return nothing if output was truncated */ -kfree (result); -return NULL ; - } - -return result; -} - -static char * -nfsd4_cltrack_grace_start (time64_t grace_start) -{ -int copied; -size_t len; -char *result; - -/* prefix + max width of int64_t string + terminating NULL */ - len =strlen (GRACE_START_ENV_PREFIX ) +22 +1 ; - - result =kmalloc (len,GFP_KERNEL ); -if (!result) -return result; - - copied =snprintf (result, len,GRACE_START_ENV_PREFIX "%lld" , - grace_start); -if (copied >= len) { -/* just return nothing if output was truncated */ -kfree (result); -return NULL ; - } - -return result; -} - -static int -nfsd4_umh_cltrack_upcall (char *cmd,char *arg,char *env0,char *env1) -{ -char *envp[3 ]; -char *argv[4 ]; -int ret; - -if (unlikely (!cltrack_prog[0 ])) { -dprintk ("%s: cltrack_prog is disabled\n" , __func__); -return -EACCES ; - } - -dprintk ("%s: cmd: %s\n" , __func__, cmd); -dprintk ("%s: arg: %s\n" , __func__, arg ? arg :"(null)" ); -dprintk ("%s: env0: %s\n" , __func__, env0 ? env0 :"(null)" ); -dprintk ("%s: env1: %s\n" , __func__, env1 ? env1 :"(null)" ); - - envp[0 ] = env0; - envp[1 ] = env1; - envp[2 ] =NULL ; - - argv[0 ] = (char *)cltrack_prog; - argv[1 ] = cmd; - argv[2 ] = arg; - argv[3 ] =NULL ; - - ret =call_usermodehelper (argv[0 ], argv, envp,UMH_WAIT_PROC ); -/* -* Disable the upcall mechanism if we're getting an ENOENT or EACCES -* error. The admin can re-enable it on the fly by using sysfs -* once the problem has been fixed. -*/ -if (ret == -ENOENT || ret == -EACCES ) { -dprintk ("NFSD: %s was not found or isn't executable (%d). " -"Setting cltrack_prog to blank string!" , - cltrack_prog, ret); - cltrack_prog[0 ] ='\0' ; - } -dprintk ("%s: %s return value: %d\n" , __func__, cltrack_prog, ret); - -return ret; -} - -static char * -bin_to_hex_dup (const unsigned char *src,int srclen) -{ -char *buf; - -/* +1 for terminating NULL */ - buf =kzalloc ((srclen *2 ) +1 ,GFP_KERNEL ); -if (!buf) -return buf; - -bin2hex (buf, src, srclen); -return buf; -} - -static int -nfsd4_umh_cltrack_init (struct net *net) -{ -int ret; -struct nfsd_net *nn =net_generic (net, nfsd_net_id); -char *grace_start =nfsd4_cltrack_grace_start (nn->boot_time); - -/* XXX: The usermode helper s not working in container yet. */ -if (net != &init_net) { -pr_warn ("NFSD: attempt to initialize umh client tracking in a container ignored.\n" ); -kfree (grace_start); -return -EINVAL ; - } - - ret =nfsd4_umh_cltrack_upcall ("init" ,NULL , grace_start,NULL ); -kfree (grace_start); -if (!ret) -pr_info ("NFSD: Using UMH upcall client tracking operations.\n" ); -return ret; -} - -static void -nfsd4_cltrack_upcall_lock (struct nfs4_client *clp) -{ -wait_on_bit_lock (&clp->cl_flags,NFSD4_CLIENT_UPCALL_LOCK , -TASK_UNINTERRUPTIBLE ); -} - -static void -nfsd4_cltrack_upcall_unlock (struct nfs4_client *clp) -{ -clear_and_wake_up_bit (NFSD4_CLIENT_UPCALL_LOCK , &clp->cl_flags); -} - -static void -nfsd4_umh_cltrack_create (struct nfs4_client *clp) -{ -char *hexid, *has_session, *grace_start; -struct nfsd_net *nn =net_generic (clp->net, nfsd_net_id); - -/* -* With v4.0 clients, there's little difference in outcome between a -* create and check operation, and we can end up calling into this -* function multiple times per client (once for each openowner). So, -* for v4.0 clients skip upcalling once the client has been recorded -* on stable storage. -* -* For v4.1+ clients, the outcome of the two operations is different, -* so we must ensure that we upcall for the create operation. v4.1+ -* clients call this on RECLAIM_COMPLETE though, so we should only end -* up doing a single create upcall per client. -*/ -if (clp->cl_minorversion ==0 && -test_bit (NFSD4_CLIENT_STABLE , &clp->cl_flags)) -return ; - - hexid =bin_to_hex_dup (clp->cl_name.data, clp->cl_name.len); -if (!hexid) { -dprintk ("%s: can't allocate memory for upcall!\n" , __func__); -return ; - } - - has_session =nfsd4_cltrack_client_has_session (clp); - grace_start =nfsd4_cltrack_grace_start (nn->boot_time); - -nfsd4_cltrack_upcall_lock (clp); -if (!nfsd4_umh_cltrack_upcall ("create" , hexid, has_session, grace_start)) -set_bit (NFSD4_CLIENT_STABLE , &clp->cl_flags); -nfsd4_cltrack_upcall_unlock (clp); - -kfree (has_session); -kfree (grace_start); -kfree (hexid); -} - -static void -nfsd4_umh_cltrack_remove (struct nfs4_client *clp) -{ -char *hexid; - -if (!test_bit (NFSD4_CLIENT_STABLE , &clp->cl_flags)) -return ; - - hexid =bin_to_hex_dup (clp->cl_name.data, clp->cl_name.len); -if (!hexid) { -dprintk ("%s: can't allocate memory for upcall!\n" , __func__); -return ; - } - -nfsd4_cltrack_upcall_lock (clp); -if (test_bit (NFSD4_CLIENT_STABLE , &clp->cl_flags) && -nfsd4_umh_cltrack_upcall ("remove" , hexid,NULL ,NULL ) ==0 ) -clear_bit (NFSD4_CLIENT_STABLE , &clp->cl_flags); -nfsd4_cltrack_upcall_unlock (clp); - -kfree (hexid); -} - -static int -nfsd4_umh_cltrack_check (struct nfs4_client *clp) -{ -int ret; -char *hexid, *has_session, *legacy; - -if (test_bit (NFSD4_CLIENT_STABLE , &clp->cl_flags)) -return 0 ; - - hexid =bin_to_hex_dup (clp->cl_name.data, clp->cl_name.len); -if (!hexid) { -dprintk ("%s: can't allocate memory for upcall!\n" , __func__); -return -ENOMEM ; - } - - has_session =nfsd4_cltrack_client_has_session (clp); - legacy =nfsd4_cltrack_legacy_recdir (&clp->cl_name); - -nfsd4_cltrack_upcall_lock (clp); -if (test_bit (NFSD4_CLIENT_STABLE , &clp->cl_flags)) { - ret =0 ; - }else { - ret =nfsd4_umh_cltrack_upcall ("check" , hexid, has_session, legacy); -if (ret ==0 ) -set_bit (NFSD4_CLIENT_STABLE , &clp->cl_flags); - } -nfsd4_cltrack_upcall_unlock (clp); -kfree (has_session); -kfree (legacy); -kfree (hexid); - -return ret; -} - -static void -nfsd4_umh_cltrack_grace_done (struct nfsd_net *nn) -{ -char *legacy; -char timestr[22 ];/* FIXME: better way to determine max size? */ - -sprintf (timestr,"%lld" , nn->boot_time); - legacy =nfsd4_cltrack_legacy_topdir (); -nfsd4_umh_cltrack_upcall ("gracedone" , timestr, legacy,NULL ); -kfree (legacy); -} - -static const struct nfsd4_client_tracking_ops nfsd4_umh_tracking_ops = { - .init = nfsd4_umh_cltrack_init, - .exit =NULL , - .create = nfsd4_umh_cltrack_create, - .remove = nfsd4_umh_cltrack_remove, - .check = nfsd4_umh_cltrack_check, - .grace_done = nfsd4_umh_cltrack_grace_done, - .version =1 , - .msglen =0 , -}; -static inline int check_for_legacy_methods (int status,struct net *net) {struct nfsd_net *nn =net_generic (net, nfsd_net_id);struct path path;/* -* Next, try the UMH upcall. -*/ - nn->client_tracking_ops = &nfsd4_umh_tracking_ops; - status = nn->client_tracking_ops->init (net); -if (!status) -return status; - -/* -* Finally, See if the recoverydir exists and is a directory. +* See if the recoverydir exists and is a directory. * If it is, then use the legacy ops. */ nn->client_tracking_ops = &nfsd4_legacy_tracking_ops;
Signature · 1 line
2.55.0
Jeff Layton
maintainerPATCH 2/2 nfsd: remove CONFIG_NFSD_LEGACY_CLIENT_TRACKING
In reply to Jeff LaytonRemove the deprecated Kconfig option and the last legacy client tracking backend, the on-disk recoverydir, along with the nfsv4recoverydir file, the nfsd_ctl_recoverydir tracepoint, and the MD5-based hashed recdir names. nfsdcld is now the only client tracking method.
--- arch/s390/configs/debug_defconfig | 1 - arch/s390/configs/defconfig | 1 - fs/nfsd/Kconfig | 17 - fs/nfsd/netns.h | 1 - fs/nfsd/nfs4ctl.h | 8 +- fs/nfsd/nfs4recover.c | 653 +------------------------------------- fs/nfsd/nfsctl.c | 79 ----- fs/nfsd/state.h | 4 - fs/nfsd/trace.h | 19 -- 9 files changed, 3 insertions(+), 780 deletions(-)
arch/s390/configs/debug_defconfig +0 -1
@@ -726,7 +726,6 @@ CONFIG_NFSD=m CONFIG_NFSD_V3_ACL=y CONFIG_NFSD_V4=y CONFIG_NFSD_V4_SECURITY_LABEL=y -# CONFIG_NFSD_LEGACY_CLIENT_TRACKING is not set CONFIG_CIFS=m CONFIG_CIFS_UPCALL=y CONFIG_CIFS_XATTR=y
arch/s390/configs/defconfig +0 -1
@@ -712,7 +712,6 @@ CONFIG_NFSD=m CONFIG_NFSD_V3_ACL=y CONFIG_NFSD_V4=y CONFIG_NFSD_V4_SECURITY_LABEL=y -# CONFIG_NFSD_LEGACY_CLIENT_TRACKING is not set CONFIG_CIFS=m CONFIG_CIFS_UPCALL=y CONFIG_CIFS_XATTR=y
fs/nfsd/Kconfig +0 -17
@@ -5,7 +5,6 @@ config NFSD depends on FILE_LOCKING depends on FSNOTIFY select CRC32 - select CRYPTO_LIB_MD5 if NFSD_LEGACY_CLIENT_TRACKING select CRYPTO_LIB_SHA256 if NFSD_V4 select CRYPTO # required by RPCSEC_GSS_KRB5 and signed filehandles select LOCKD
@@ -161,22 +160,6 @@ config NFSD_V4_SECURITY_LABEL If you do not wish to enable fine-grained security labels SELinux or Smack policies on NFSv4 files, say N. -config NFSD_LEGACY_CLIENT_TRACKING - bool "Support legacy NFSv4 client tracking methods (DEPRECATED)" - depends on NFSD_V4 - default n - help - The NFSv4 server needs to store a small amount of information on - stable storage in order to handle state recovery after reboot. Most - modern deployments upcall to a userland daemon for this (nfsdcld), - but older NFS servers may store information directly in a - recoverydir, or spawn a process directly using a usermodehelper - upcall. - - These legacy client tracking methods have proven to be problematic - and will be removed in the future. Say Y here if you need support - for them in the interim. - config NFSD_V4_POSIX_ACLS bool "Support NFSv4 POSIX draft ACLs" depends on NFSD_V4
fs/nfsd/netns.h +0 -1
@@ -135,7 +135,6 @@ struct nfsd_net {/* protects blocked_locks_lru */ spinlock_t blocked_locks_lock; -struct file *rec_file;const struct nfsd4_client_tracking_ops *client_tracking_ops;time64_t nfsd4_lease;
fs/nfsd/nfs4ctl.h +2 -6
@@ -1,8 +1,8 @@/* SPDX-License-Identifier: GPL-2.0 */ /* * Entry points by which the knfsd core drives the optional NFSv4 -* subsystem: state lifecycle, the laundromat workqueue, the recovery -* directory, junctions, the CLD notifier, and leases-net setup. +* subsystem: state lifecycle, the laundromat workqueue, junctions, +* the CLD notifier, and leases-net setup. * * Separated from nfsd.h so that the many translation units that * include nfsd.h but call none of these -- among them the NFSv2 and
@@ -31,8 +31,6 @@ int nfs4_state_start(void);int nfs4_state_start_net (struct net *net);void nfs4_state_shutdown (void );void nfs4_state_shutdown_net (struct net *net); -int nfs4_reset_recoverydir (char *recdir); -char *nfs4_recoverydir (void );bool nfsd4_spo_must_allow (struct svc_rqst *rqstp);int nfsd4_create_laundry_wq (void );void nfsd4_destroy_laundry_wq (void );
@@ -54,8 +52,6 @@ static inline int nfs4_state_start(void) { return 0; }static inline int nfs4_state_start_net (struct net *net) {return 0 ; }static inline void nfs4_state_shutdown (void ) { }static inline void nfs4_state_shutdown_net (struct net *net) { } -static inline int nfs4_reset_recoverydir (char *recdir) {return 0 ; } -static inline char *nfs4_recoverydir (void ) {return NULL ; }static inline bool nfsd4_spo_must_allow (struct svc_rqst *rqstp) {return false;
fs/nfsd/nfs4recover.c +1 -652
719 lines not on this page · raw message
fs/nfsd/nfsctl.c +0 -79
109 lines not on this page · raw message
fs/nfsd/state.h +0 -4
@@ -35,7 +35,6 @@#ifndef _NFSD4_STATE_H#define _NFSD4_STATE_H -#include <crypto/md5.h> #include <linux/filelock.h> #include <linux/idr.h>
@@ -500,9 +499,6 @@ struct nfsd4_sessionid {u32 reserved; }; -/* Length of MD5 digest as hex, plus terminating '\0' */ -#define HEXDIR_LEN (2 * MD5_DIGEST_SIZE + 1) -/* * State Meaning Where set * --------------------------------------------------------------------------
fs/nfsd/trace.h +0 -19
@@ -2310,25 +2310,6 @@ TRACE_EVENT(nfsd_ctl_time, ) ); -TRACE_EVENT (nfsd_ctl_recoverydir, -TP_PROTO ( - const struct net *net, - const char *recdir - ), -TP_ARGS (net, recdir), -TP_STRUCT__entry ( - __field(unsigned int, netns_ino) -__string (recdir, recdir) - ), -TP_fast_assign ( - __entry->netns_ino = net->ns.inum; - __assign_str(recdir); - ), -TP_printk ("recdir=%s" , -__get_str (recdir) - ) -); - TRACE_EVENT(nfsd_end_grace, TP_PROTO( const struct net *net
Signature · 1 line
2.55.0
Chuck Lever
maintainerQuoted 10 lines · Jeff Layton
Around three years ago, we added
CONFIG_NFSD_LEGACY_CLIENT_TRACKINGwith the intent to eventually remove the code that it compiles in when enabled. A little over a year ago, we switched the default for it to "n".All of the major distros now disable this option, so finish the job by finally removing the config option altogether. With this, nfsdcld becomes the sole way to do v4 recovery tracking.
[...]
Applied to nfsd-testing, thanks!
[1/2] nfsd: remove the nfsdcltrack usermodehelper tracking backend
commit: ac71b6474e0a6b62c7075f3745cb8ac9e201ec7b
[2/2] nfsd: remove CONFIG_NFSD_LEGACY_CLIENT_TRACKING
commit: 21c66e2ece97c0ac8139b44051d565b29574f821--
Chuck Lever