sunrpc: Const-ify all instances of struct rpc_xprt_ops
authorChuck Lever <chuck.lever@oracle.com>
Tue, 1 Aug 2017 16:00:39 +0000 (12:00 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Tue, 1 Aug 2017 20:10:35 +0000 (16:10 -0400)
After transport instance creation, these function pointers never
change. Mark them as constant to prevent their use as an attack
vector for code injections.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
include/linux/sunrpc/xprt.h
net/sunrpc/xprtrdma/svc_rdma_backchannel.c
net/sunrpc/xprtrdma/transport.c
net/sunrpc/xprtsock.c

index eab1c749e192b5ba37b050d5fb5592e825d61682..f60c55ca2e2ea4c10c88b10756a998f43495e0db 100644 (file)
@@ -174,7 +174,7 @@ enum xprt_transports {
 
 struct rpc_xprt {
        struct kref             kref;           /* Reference count */
-       struct rpc_xprt_ops *   ops;            /* transport methods */
+       const struct rpc_xprt_ops *ops;         /* transport methods */
 
        const struct rpc_timeout *timeout;      /* timeout parms */
        struct sockaddr_storage addr;           /* server address */
index c676ed0efb5af2cceb6ed59e238a0f7a0109f916..ca41e28d2b36aa2e40b5418986922bf368834f6a 100644 (file)
@@ -266,7 +266,7 @@ xprt_rdma_bc_put(struct rpc_xprt *xprt)
        module_put(THIS_MODULE);
 }
 
-static struct rpc_xprt_ops xprt_rdma_bc_procs = {
+static const struct rpc_xprt_ops xprt_rdma_bc_procs = {
        .reserve_xprt           = xprt_reserve_xprt_cong,
        .release_xprt           = xprt_release_xprt_cong,
        .alloc_slot             = xprt_alloc_slot,
index d1c458e5ec4de25b81f30fa5919cb0b9dfc5ffdf..42752e4cc99674974f5be347e3e97b59eac29647 100644 (file)
@@ -149,7 +149,7 @@ static struct ctl_table sunrpc_table[] = {
 
 #endif
 
-static struct rpc_xprt_ops xprt_rdma_procs;    /*forward reference */
+static const struct rpc_xprt_ops xprt_rdma_procs;
 
 static void
 xprt_rdma_format_addresses4(struct rpc_xprt *xprt, struct sockaddr *sap)
@@ -811,7 +811,7 @@ xprt_rdma_disable_swap(struct rpc_xprt *xprt)
  * Plumbing for rpc transport switch and kernel module
  */
 
-static struct rpc_xprt_ops xprt_rdma_procs = {
+static const struct rpc_xprt_ops xprt_rdma_procs = {
        .reserve_xprt           = xprt_reserve_xprt_cong,
        .release_xprt           = xprt_release_xprt_cong, /* sunrpc/xprt.c */
        .alloc_slot             = xprt_alloc_slot,
index 4f154d3887483e9cf1a6ab151c487e1d6113c1a8..5cf17001f0e2e38a4005c79eb5ff751b5eed3722 100644 (file)
@@ -2724,7 +2724,7 @@ static void bc_destroy(struct rpc_xprt *xprt)
        module_put(THIS_MODULE);
 }
 
-static struct rpc_xprt_ops xs_local_ops = {
+static const struct rpc_xprt_ops xs_local_ops = {
        .reserve_xprt           = xprt_reserve_xprt,
        .release_xprt           = xs_tcp_release_xprt,
        .alloc_slot             = xprt_alloc_slot,
@@ -2742,7 +2742,7 @@ static struct rpc_xprt_ops xs_local_ops = {
        .disable_swap           = xs_disable_swap,
 };
 
-static struct rpc_xprt_ops xs_udp_ops = {
+static const struct rpc_xprt_ops xs_udp_ops = {
        .set_buffer_size        = xs_udp_set_buffer_size,
        .reserve_xprt           = xprt_reserve_xprt_cong,
        .release_xprt           = xprt_release_xprt_cong,
@@ -2764,7 +2764,7 @@ static struct rpc_xprt_ops xs_udp_ops = {
        .inject_disconnect      = xs_inject_disconnect,
 };
 
-static struct rpc_xprt_ops xs_tcp_ops = {
+static const struct rpc_xprt_ops xs_tcp_ops = {
        .reserve_xprt           = xprt_reserve_xprt,
        .release_xprt           = xs_tcp_release_xprt,
        .alloc_slot             = xprt_lock_and_alloc_slot,
@@ -2795,7 +2795,7 @@ static struct rpc_xprt_ops xs_tcp_ops = {
  * The rpc_xprt_ops for the server backchannel
  */
 
-static struct rpc_xprt_ops bc_tcp_ops = {
+static const struct rpc_xprt_ops bc_tcp_ops = {
        .reserve_xprt           = xprt_reserve_xprt,
        .release_xprt           = xprt_release_xprt,
        .alloc_slot             = xprt_alloc_slot,