diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2017-08-01 12:00:06 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2017-08-24 22:13:50 -0400 |
commit | afea5657c20b11ec9f895ac5cc33b560fb1e0276 (patch) | |
tree | 33068b83b4eabc452bd4a69b5fa6f31a16ce9354 | |
parent | c1df609d9dcec5dcb89ee3091edc3671da1c9996 (diff) |
sunrpc: Const-ify struct sv_serv_ops
Close an attack vector by moving the arrays of per-server methods to
read-only memory.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r-- | fs/lockd/svc.c | 2 | ||||
-rw-r--r-- | fs/nfs/callback.c | 10 | ||||
-rw-r--r-- | fs/nfsd/nfssvc.c | 2 | ||||
-rw-r--r-- | include/linux/sunrpc/svc.h | 6 | ||||
-rw-r--r-- | net/sunrpc/svc.c | 6 |
5 files changed, 13 insertions, 13 deletions
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 726b6cecf430..b995bdc13976 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c | |||
@@ -396,7 +396,7 @@ out_rqst: | |||
396 | return error; | 396 | return error; |
397 | } | 397 | } |
398 | 398 | ||
399 | static struct svc_serv_ops lockd_sv_ops = { | 399 | static const struct svc_serv_ops lockd_sv_ops = { |
400 | .svo_shutdown = svc_rpcb_cleanup, | 400 | .svo_shutdown = svc_rpcb_cleanup, |
401 | .svo_enqueue_xprt = svc_xprt_do_enqueue, | 401 | .svo_enqueue_xprt = svc_xprt_do_enqueue, |
402 | }; | 402 | }; |
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index 34323877ec13..2cddf7f437e6 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c | |||
@@ -226,26 +226,26 @@ err_bind: | |||
226 | return ret; | 226 | return ret; |
227 | } | 227 | } |
228 | 228 | ||
229 | static struct svc_serv_ops nfs40_cb_sv_ops = { | 229 | static const struct svc_serv_ops nfs40_cb_sv_ops = { |
230 | .svo_function = nfs4_callback_svc, | 230 | .svo_function = nfs4_callback_svc, |
231 | .svo_enqueue_xprt = svc_xprt_do_enqueue, | 231 | .svo_enqueue_xprt = svc_xprt_do_enqueue, |
232 | .svo_setup = svc_set_num_threads_sync, | 232 | .svo_setup = svc_set_num_threads_sync, |
233 | .svo_module = THIS_MODULE, | 233 | .svo_module = THIS_MODULE, |
234 | }; | 234 | }; |
235 | #if defined(CONFIG_NFS_V4_1) | 235 | #if defined(CONFIG_NFS_V4_1) |
236 | static struct svc_serv_ops nfs41_cb_sv_ops = { | 236 | static const struct svc_serv_ops nfs41_cb_sv_ops = { |
237 | .svo_function = nfs41_callback_svc, | 237 | .svo_function = nfs41_callback_svc, |
238 | .svo_enqueue_xprt = svc_xprt_do_enqueue, | 238 | .svo_enqueue_xprt = svc_xprt_do_enqueue, |
239 | .svo_setup = svc_set_num_threads_sync, | 239 | .svo_setup = svc_set_num_threads_sync, |
240 | .svo_module = THIS_MODULE, | 240 | .svo_module = THIS_MODULE, |
241 | }; | 241 | }; |
242 | 242 | ||
243 | static struct svc_serv_ops *nfs4_cb_sv_ops[] = { | 243 | static const struct svc_serv_ops *nfs4_cb_sv_ops[] = { |
244 | [0] = &nfs40_cb_sv_ops, | 244 | [0] = &nfs40_cb_sv_ops, |
245 | [1] = &nfs41_cb_sv_ops, | 245 | [1] = &nfs41_cb_sv_ops, |
246 | }; | 246 | }; |
247 | #else | 247 | #else |
248 | static struct svc_serv_ops *nfs4_cb_sv_ops[] = { | 248 | static const struct svc_serv_ops *nfs4_cb_sv_ops[] = { |
249 | [0] = &nfs40_cb_sv_ops, | 249 | [0] = &nfs40_cb_sv_ops, |
250 | [1] = NULL, | 250 | [1] = NULL, |
251 | }; | 251 | }; |
@@ -254,8 +254,8 @@ static struct svc_serv_ops *nfs4_cb_sv_ops[] = { | |||
254 | static struct svc_serv *nfs_callback_create_svc(int minorversion) | 254 | static struct svc_serv *nfs_callback_create_svc(int minorversion) |
255 | { | 255 | { |
256 | struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion]; | 256 | struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion]; |
257 | const struct svc_serv_ops *sv_ops; | ||
257 | struct svc_serv *serv; | 258 | struct svc_serv *serv; |
258 | struct svc_serv_ops *sv_ops; | ||
259 | 259 | ||
260 | /* | 260 | /* |
261 | * Check whether we're already up and running. | 261 | * Check whether we're already up and running. |
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 063ae7de2c12..7e3af3ef0917 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c | |||
@@ -475,7 +475,7 @@ static int nfsd_get_default_max_blksize(void) | |||
475 | return ret; | 475 | return ret; |
476 | } | 476 | } |
477 | 477 | ||
478 | static struct svc_serv_ops nfsd_thread_sv_ops = { | 478 | static const struct svc_serv_ops nfsd_thread_sv_ops = { |
479 | .svo_shutdown = nfsd_last_thread, | 479 | .svo_shutdown = nfsd_last_thread, |
480 | .svo_function = nfsd, | 480 | .svo_function = nfsd, |
481 | .svo_enqueue_xprt = svc_xprt_do_enqueue, | 481 | .svo_enqueue_xprt = svc_xprt_do_enqueue, |
diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index a3f8af9bd543..38f561b2dda3 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h | |||
@@ -99,7 +99,7 @@ struct svc_serv { | |||
99 | 99 | ||
100 | unsigned int sv_nrpools; /* number of thread pools */ | 100 | unsigned int sv_nrpools; /* number of thread pools */ |
101 | struct svc_pool * sv_pools; /* array of thread pools */ | 101 | struct svc_pool * sv_pools; /* array of thread pools */ |
102 | struct svc_serv_ops *sv_ops; /* server operations */ | 102 | const struct svc_serv_ops *sv_ops; /* server operations */ |
103 | #if defined(CONFIG_SUNRPC_BACKCHANNEL) | 103 | #if defined(CONFIG_SUNRPC_BACKCHANNEL) |
104 | struct list_head sv_cb_list; /* queue for callback requests | 104 | struct list_head sv_cb_list; /* queue for callback requests |
105 | * that arrive over the same | 105 | * that arrive over the same |
@@ -465,7 +465,7 @@ int svc_rpcb_setup(struct svc_serv *serv, struct net *net); | |||
465 | void svc_rpcb_cleanup(struct svc_serv *serv, struct net *net); | 465 | void svc_rpcb_cleanup(struct svc_serv *serv, struct net *net); |
466 | int svc_bind(struct svc_serv *serv, struct net *net); | 466 | int svc_bind(struct svc_serv *serv, struct net *net); |
467 | struct svc_serv *svc_create(struct svc_program *, unsigned int, | 467 | struct svc_serv *svc_create(struct svc_program *, unsigned int, |
468 | struct svc_serv_ops *); | 468 | const struct svc_serv_ops *); |
469 | struct svc_rqst *svc_rqst_alloc(struct svc_serv *serv, | 469 | struct svc_rqst *svc_rqst_alloc(struct svc_serv *serv, |
470 | struct svc_pool *pool, int node); | 470 | struct svc_pool *pool, int node); |
471 | struct svc_rqst *svc_prepare_thread(struct svc_serv *serv, | 471 | struct svc_rqst *svc_prepare_thread(struct svc_serv *serv, |
@@ -475,7 +475,7 @@ void svc_exit_thread(struct svc_rqst *); | |||
475 | unsigned int svc_pool_map_get(void); | 475 | unsigned int svc_pool_map_get(void); |
476 | void svc_pool_map_put(void); | 476 | void svc_pool_map_put(void); |
477 | struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int, | 477 | struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int, |
478 | struct svc_serv_ops *); | 478 | const struct svc_serv_ops *); |
479 | int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int); | 479 | int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int); |
480 | int svc_set_num_threads_sync(struct svc_serv *, struct svc_pool *, int); | 480 | int svc_set_num_threads_sync(struct svc_serv *, struct svc_pool *, int); |
481 | int svc_pool_stats_open(struct svc_serv *serv, struct file *file); | 481 | int svc_pool_stats_open(struct svc_serv *serv, struct file *file); |
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index 85ce0db5b0a6..aa04666f929d 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c | |||
@@ -421,7 +421,7 @@ __svc_init_bc(struct svc_serv *serv) | |||
421 | */ | 421 | */ |
422 | static struct svc_serv * | 422 | static struct svc_serv * |
423 | __svc_create(struct svc_program *prog, unsigned int bufsize, int npools, | 423 | __svc_create(struct svc_program *prog, unsigned int bufsize, int npools, |
424 | struct svc_serv_ops *ops) | 424 | const struct svc_serv_ops *ops) |
425 | { | 425 | { |
426 | struct svc_serv *serv; | 426 | struct svc_serv *serv; |
427 | unsigned int vers; | 427 | unsigned int vers; |
@@ -486,7 +486,7 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools, | |||
486 | 486 | ||
487 | struct svc_serv * | 487 | struct svc_serv * |
488 | svc_create(struct svc_program *prog, unsigned int bufsize, | 488 | svc_create(struct svc_program *prog, unsigned int bufsize, |
489 | struct svc_serv_ops *ops) | 489 | const struct svc_serv_ops *ops) |
490 | { | 490 | { |
491 | return __svc_create(prog, bufsize, /*npools*/1, ops); | 491 | return __svc_create(prog, bufsize, /*npools*/1, ops); |
492 | } | 492 | } |
@@ -494,7 +494,7 @@ EXPORT_SYMBOL_GPL(svc_create); | |||
494 | 494 | ||
495 | struct svc_serv * | 495 | struct svc_serv * |
496 | svc_create_pooled(struct svc_program *prog, unsigned int bufsize, | 496 | svc_create_pooled(struct svc_program *prog, unsigned int bufsize, |
497 | struct svc_serv_ops *ops) | 497 | const struct svc_serv_ops *ops) |
498 | { | 498 | { |
499 | struct svc_serv *serv; | 499 | struct svc_serv *serv; |
500 | unsigned int npools = svc_pool_map_get(); | 500 | unsigned int npools = svc_pool_map_get(); |