From: Valentine Fatiev <valentinef@nvidia.com>
Subject: [PATCH] BACKPORT: net/sunrpc/xprtrdma/svc_rdma.c

Change-Id: Ie8b2886b865b398a8b6cc3a24595e6d4b90bb763
---
 net/sunrpc/xprtrdma/svc_rdma.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

--- a/net/sunrpc/xprtrdma/svc_rdma.c
+++ b/net/sunrpc/xprtrdma/svc_rdma.c
@@ -75,7 +75,11 @@ enum {
 };
 
 static int svcrdma_counter_handler(struct ctl_table *table, int write,
+#ifdef HAVE_CGROUP_BPF_RUN_FILTER_SYSCTL_7_PARAMETERS
 				   void *buffer, size_t *lenp, loff_t *ppos)
+#else
+				   void __user *buffer, size_t *lenp, loff_t *ppos)
+#endif
 {
 	struct percpu_counter *stat = (struct percpu_counter *)table->data;
 	char tmp[SVCRDMA_COUNTER_BUFSIZ + 1];
@@ -98,8 +102,13 @@ static int svcrdma_counter_handler(struc
 	len -= *ppos;
 	if (len > *lenp)
 		len = *lenp;
+#ifdef HAVE_CGROUP_BPF_RUN_FILTER_SYSCTL_7_PARAMETERS
 	if (len)
 		memcpy(buffer, tmp, len);
+#else
+	if (len && copy_to_user(buffer, tmp, len))
+		return -EFAULT;
+#endif
 	*lenp = len;
 	*ppos += len;
 
@@ -276,6 +285,9 @@ out_err:
 void svc_rdma_cleanup(void)
 {
 	dprintk("SVCRDMA Module Removed, deregister RPC RDMA transport\n");
+#if defined(CONFIG_SUNRPC_BACKCHANNEL) && defined(HAVE_RPC_XPRT_OPS_BC_UP)
+	svc_unreg_xprt_class(&svc_rdma_bc_class);
+#endif
 	svc_unreg_xprt_class(&svc_rdma_class);
 	svc_rdma_proc_cleanup();
 }
@@ -296,5 +308,8 @@ int svc_rdma_init(void)
 
 	/* Register RDMA with the SVC transport switch */
 	svc_reg_xprt_class(&svc_rdma_class);
+#if defined(CONFIG_SUNRPC_BACKCHANNEL) && defined(HAVE_RPC_XPRT_OPS_BC_UP)
+	svc_reg_xprt_class(&svc_rdma_bc_class);
+#endif
 	return 0;
 }
