struct svc_procinfo contains function pointers, and marking it as constant avoids it being able to be used as an attach vector for code injections.
Unified · Split
| @@ -507,7 +507,7 @@ struct nlm_void { int dummy; }; · 506 unmodified lines | |||
| 507 | #define No (1+1024/4) /* netobj */ | 507 | #define No (1+1024/4) /* netobj */ |
| 508 | #define St 1 /* status */ | 508 | #define St 1 /* status */ |
| 509 | #define Rg 4 /* range (offset + length) */ | 509 | #define Rg 4 /* range (offset + length) */ |
| 510 | struct svc_procedure nlmsvc_procedures4[] = { | 510 | const struct svc_procedure nlmsvc_procedures4[] = { |
| 511 | PROC(null, void, void, void, void, 1), | 511 | PROC(null, void, void, void, void, 1), |
| 512 | PROC(test, testargs, testres, args, res, Ck+St+2+No+Rg), | 512 | PROC(test, testargs, testres, args, res, Ck+St+2+No+Rg), |
| 513 | PROC(lock, lockargs, res, args, res, Ck+St), | 513 | PROC(lock, lockargs, res, args, res, Ck+St), |
| @@ -551,7 +551,7 @@ struct nlm_void { int dummy; }; · 550 unmodified lines | |||
| 551 | #define No (1+1024/4) /* Net Obj */ | 551 | #define No (1+1024/4) /* Net Obj */ |
| 552 | #define Rg 2 /* range - offset + size */ | 552 | #define Rg 2 /* range - offset + size */ |
| 553 | 553 | ||
| 554 | struct svc_procedure nlmsvc_procedures[] = { | 554 | const struct svc_procedure nlmsvc_procedures[] = { |
| 555 | PROC(null, void, void, void, void, 1), | 555 | PROC(null, void, void, void, void, 1), |
| 556 | PROC(test, testargs, testres, args, res, Ck+St+2+No+Rg), | 556 | PROC(test, testargs, testres, args, res, Ck+St+2+No+Rg), |
| 557 | PROC(lock, lockargs, res, args, res, Ck+St), | 557 | PROC(lock, lockargs, res, args, res, Ck+St), |
| @@ -995,7 +995,7 @@ static struct callback_op callback_ops[] = { · 994 unmodified lines | |||
| 995 | /* | 995 | /* |
| 996 | * Define NFS4 callback procedures | 996 | * Define NFS4 callback procedures |
| 997 | */ | 997 | */ |
| 998 | static struct svc_procedure nfs4_callback_procedures1[] = { | 998 | static const struct svc_procedure nfs4_callback_procedures1[] = { |
| 999 | [CB_NULL] = { | 999 | [CB_NULL] = { |
| 1000 | .pc_func = nfs4_callback_null, | 1000 | .pc_func = nfs4_callback_null, |
| 1001 | .pc_decode = nfs4_decode_void, | 1001 | .pc_decode = nfs4_decode_void, |
| @@ -370,7 +370,7 @@ struct nfsd3_voidargs { int dummy; }; · 369 unmodified lines | |||
| 370 | #define pAT (1+AT) /* post attributes - conditional */ | 370 | #define pAT (1+AT) /* post attributes - conditional */ |
| 371 | #define ACL (1+NFS_ACL_MAX_ENTRIES*3) /* Access Control List */ | 371 | #define ACL (1+NFS_ACL_MAX_ENTRIES*3) /* Access Control List */ |
| 372 | 372 | ||
| 373 | static struct svc_procedure nfsd_acl_procedures2[] = { | 373 | static const struct svc_procedure nfsd_acl_procedures2[] = { |
| 374 | PROC(null, void, void, void, RC_NOCACHE, ST), | 374 | PROC(null, void, void, void, RC_NOCACHE, ST), |
| 375 | PROC(getacl, getacl, getacl, getacl, RC_NOCACHE, ST+1+2*(1+ACL)), | 375 | PROC(getacl, getacl, getacl, getacl, RC_NOCACHE, ST+1+2*(1+ACL)), |
| 376 | PROC(setacl, setacl, attrstat, attrstat, RC_NOCACHE, ST+AT), | 376 | PROC(setacl, setacl, attrstat, attrstat, RC_NOCACHE, ST+AT), |
| @@ -257,7 +257,7 @@ struct nfsd3_voidargs { int dummy; }; · 256 unmodified lines | |||
| 257 | #define pAT (1+AT) /* post attributes - conditional */ | 257 | #define pAT (1+AT) /* post attributes - conditional */ |
| 258 | #define ACL (1+NFS_ACL_MAX_ENTRIES*3) /* Access Control List */ | 258 | #define ACL (1+NFS_ACL_MAX_ENTRIES*3) /* Access Control List */ |
| 259 | 259 | ||
| 260 | static struct svc_procedure nfsd_acl_procedures3[] = { | 260 | static const struct svc_procedure nfsd_acl_procedures3[] = { |
| 261 | PROC(null, void, void, void, RC_NOCACHE, ST), | 261 | PROC(null, void, void, void, RC_NOCACHE, ST), |
| 262 | PROC(getacl, getacl, getacl, getacl, RC_NOCACHE, ST+1+2*(1+ACL)), | 262 | PROC(getacl, getacl, getacl, getacl, RC_NOCACHE, ST+1+2*(1+ACL)), |
| 263 | PROC(setacl, setacl, setacl, fhandle, RC_NOCACHE, ST+pAT), | 263 | PROC(setacl, setacl, setacl, fhandle, RC_NOCACHE, ST+pAT), |
| @@ -674,7 +674,7 @@ struct nfsd3_voidargs { int dummy; }; · 673 unmodified lines | |||
| 674 | #define pAT (1+AT) /* post attributes - conditional */ | 674 | #define pAT (1+AT) /* post attributes - conditional */ |
| 675 | #define WC (7+pAT) /* WCC attributes */ | 675 | #define WC (7+pAT) /* WCC attributes */ |
| 676 | 676 | ||
| 677 | static struct svc_procedure nfsd_procedures3[22] = { | 677 | static const struct svc_procedure nfsd_procedures3[22] = { |
| 678 | [NFS3PROC_NULL] = { | 678 | [NFS3PROC_NULL] = { |
| 679 | .pc_func = nfsd3_proc_null, | 679 | .pc_func = nfsd3_proc_null, |
| 680 | .pc_encode = nfs3svc_encode_voidres, | 680 | .pc_encode = nfs3svc_encode_voidres, |
| @@ -2532,7 +2532,7 @@ static const char *nfsd4_op_name(unsigned opnum) · 2531 unmodified lines | |||
| 2532 | #define nfsd4_voidres nfsd4_voidargs | 2532 | #define nfsd4_voidres nfsd4_voidargs |
| 2533 | struct nfsd4_voidargs { int dummy; }; | 2533 | struct nfsd4_voidargs { int dummy; }; |
| 2534 | 2534 | ||
| 2535 | static struct svc_procedure nfsd_procedures4[2] = { | 2535 | static const struct svc_procedure nfsd_procedures4[2] = { |
| 2536 | [NFSPROC4_NULL] = { | 2536 | [NFSPROC4_NULL] = { |
| 2537 | .pc_func = nfsd4_proc_null, | 2537 | .pc_func = nfsd4_proc_null, |
| 2538 | .pc_encode = nfs4svc_encode_voidres, | 2538 | .pc_encode = nfs4svc_encode_voidres, |
| @@ -573,7 +573,7 @@ struct nfsd_void { int dummy; }; · 572 unmodified lines | |||
| 573 | #define FH 8 /* filehandle */ | 573 | #define FH 8 /* filehandle */ |
| 574 | #define AT 18 /* attributes */ | 574 | #define AT 18 /* attributes */ |
| 575 | 575 | ||
| 576 | static struct svc_procedure nfsd_procedures2[18] = { | 576 | static const struct svc_procedure nfsd_procedures2[18] = { |
| 577 | [NFSPROC_NULL] = { | 577 | [NFSPROC_NULL] = { |
| 578 | .pc_func = nfsd_proc_null, | 578 | .pc_func = nfsd_proc_null, |
| 579 | .pc_decode = nfssvc_decode_void, | 579 | .pc_decode = nfssvc_decode_void, |
| @@ -756,7 +756,7 @@ static __be32 map_new_errors(u32 vers, __be32 nfserr) · 755 unmodified lines | |||
| 756 | * problem, we enforce these assumptions here: | 756 | * problem, we enforce these assumptions here: |
| 757 | */ | 757 | */ |
| 758 | static bool nfs_request_too_big(struct svc_rqst *rqstp, | 758 | static bool nfs_request_too_big(struct svc_rqst *rqstp, |
| 759 | struct svc_procedure *proc) | 759 | const struct svc_procedure *proc) |
| 760 | { | 760 | { |
| 761 | /* | 761 | /* |
| 762 | * The ACL code has more careful bounds-checking and is not | 762 | * The ACL code has more careful bounds-checking and is not |
| @@ -781,7 +781,7 @@ static bool nfs_request_too_big(struct svc_rqst *rqstp, · 18 unmodified lines | |||
| 781 | int | 781 | int |
| 782 | nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp) | 782 | nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp) |
| 783 | { | 783 | { |
| 784 | struct svc_procedure *proc; | 784 | const struct svc_procedure *proc; |
| 785 | __be32 nfserr; | 785 | __be32 nfserr; |
| 786 | __be32 *nfserrp; | 786 | __be32 *nfserrp; |
| 787 | 787 | ||
| @@ -192,9 +192,9 @@ struct nlm_block { · 191 unmodified lines | |||
| 192 | * Global variables | 192 | * Global variables |
| 193 | */ | 193 | */ |
| 194 | extern const struct rpc_program nlm_program; | 194 | extern const struct rpc_program nlm_program; |
| 195 | extern struct svc_procedure nlmsvc_procedures[]; | 195 | extern const struct svc_procedure nlmsvc_procedures[]; |
| 196 | #ifdef CONFIG_LOCKD_V4 | 196 | #ifdef CONFIG_LOCKD_V4 |
| 197 | extern struct svc_procedure nlmsvc_procedures4[]; | 197 | extern const struct svc_procedure nlmsvc_procedures4[]; |
| 198 | #endif | 198 | #endif |
| 199 | extern int nlmsvc_grace_period; | 199 | extern int nlmsvc_grace_period; |
| 200 | extern unsigned long nlmsvc_timeout; | 200 | extern unsigned long nlmsvc_timeout; |
| @@ -237,7 +237,7 @@ struct svc_rqst { · 236 unmodified lines | |||
| 237 | 237 | ||
| 238 | struct svc_serv * rq_server; /* RPC service definition */ | 238 | struct svc_serv * rq_server; /* RPC service definition */ |
| 239 | struct svc_pool * rq_pool; /* thread pool */ | 239 | struct svc_pool * rq_pool; /* thread pool */ |
| 240 | struct svc_procedure * rq_procinfo; /* procedure info */ | 240 | const struct svc_procedure *rq_procinfo;/* procedure info */ |
| 241 | struct auth_ops * rq_authop; /* authentication flavour */ | 241 | struct auth_ops * rq_authop; /* authentication flavour */ |
| 242 | struct svc_cred rq_cred; /* auth info */ | 242 | struct svc_cred rq_cred; /* auth info */ |
| 243 | void * rq_xprt_ctxt; /* transport specific context ptr */ | 243 | void * rq_xprt_ctxt; /* transport specific context ptr */ |
| @@ -397,7 +397,7 @@ struct svc_program { · 153 unmodified lines | |||
| 397 | struct svc_version { | 397 | struct svc_version { |
| 398 | u32 vs_vers; /* version number */ | 398 | u32 vs_vers; /* version number */ |
| 399 | u32 vs_nproc; /* number of procedures */ | 399 | u32 vs_nproc; /* number of procedures */ |
| 400 | struct svc_procedure * vs_proc; /* per-procedure info */ | 400 | const struct svc_procedure *vs_proc; /* per-procedure info */ |
| 401 | unsigned int *vs_count; /* call counts */ | 401 | unsigned int *vs_count; /* call counts */ |
| 402 | u32 vs_xdrsize; /* xdrsize needed for this version */ | 402 | u32 vs_xdrsize; /* xdrsize needed for this version */ |
| 403 | 403 | ||
| @@ -1152,7 +1152,7 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv) · 1151 unmodified lines | |||
| 1152 | { | 1152 | { |
| 1153 | struct svc_program *progp; | 1153 | struct svc_program *progp; |
| 1154 | struct svc_version *versp = NULL; /* compiler food */ | 1154 | struct svc_version *versp = NULL; /* compiler food */ |
| 1155 | struct svc_procedure *procp = NULL; | 1155 | const struct svc_procedure *procp = NULL; |
| 1156 | struct svc_serv *serv = rqstp->rq_server; | 1156 | struct svc_serv *serv = rqstp->rq_server; |
| 1157 | __be32 *statp; | 1157 | __be32 *statp; |
| 1158 | u32 prog, vers, proc; | 1158 | u32 prog, vers, proc; |