Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sunrpc: mark all struct svc_procinfo instances as const

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.

Signed-off-by: Christoph Hellwig <hch@lst.de>

+15 -15
+1 -1
fs/lockd/svc4proc.c
··· 507 507 #define No (1+1024/4) /* netobj */ 508 508 #define St 1 /* status */ 509 509 #define Rg 4 /* range (offset + length) */ 510 - struct svc_procedure nlmsvc_procedures4[] = { 510 + const struct svc_procedure nlmsvc_procedures4[] = { 511 511 PROC(null, void, void, void, void, 1), 512 512 PROC(test, testargs, testres, args, res, Ck+St+2+No+Rg), 513 513 PROC(lock, lockargs, res, args, res, Ck+St),
+1 -1
fs/lockd/svcproc.c
··· 551 551 #define No (1+1024/4) /* Net Obj */ 552 552 #define Rg 2 /* range - offset + size */ 553 553 554 - struct svc_procedure nlmsvc_procedures[] = { 554 + const struct svc_procedure nlmsvc_procedures[] = { 555 555 PROC(null, void, void, void, void, 1), 556 556 PROC(test, testargs, testres, args, res, Ck+St+2+No+Rg), 557 557 PROC(lock, lockargs, res, args, res, Ck+St),
+1 -1
fs/nfs/callback_xdr.c
··· 995 995 /* 996 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 999 [CB_NULL] = { 1000 1000 .pc_func = nfs4_callback_null, 1001 1001 .pc_decode = nfs4_decode_void,
+1 -1
fs/nfsd/nfs2acl.c
··· 370 370 #define pAT (1+AT) /* post attributes - conditional */ 371 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 374 PROC(null, void, void, void, RC_NOCACHE, ST), 375 375 PROC(getacl, getacl, getacl, getacl, RC_NOCACHE, ST+1+2*(1+ACL)), 376 376 PROC(setacl, setacl, attrstat, attrstat, RC_NOCACHE, ST+AT),
+1 -1
fs/nfsd/nfs3acl.c
··· 257 257 #define pAT (1+AT) /* post attributes - conditional */ 258 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 261 PROC(null, void, void, void, RC_NOCACHE, ST), 262 262 PROC(getacl, getacl, getacl, getacl, RC_NOCACHE, ST+1+2*(1+ACL)), 263 263 PROC(setacl, setacl, setacl, fhandle, RC_NOCACHE, ST+pAT),
+1 -1
fs/nfsd/nfs3proc.c
··· 674 674 #define pAT (1+AT) /* post attributes - conditional */ 675 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 678 [NFS3PROC_NULL] = { 679 679 .pc_func = nfsd3_proc_null, 680 680 .pc_encode = nfs3svc_encode_voidres,
+1 -1
fs/nfsd/nfs4proc.c
··· 2533 2533 #define nfsd4_voidres nfsd4_voidargs 2534 2534 struct nfsd4_voidargs { int dummy; }; 2535 2535 2536 - static struct svc_procedure nfsd_procedures4[2] = { 2536 + static const struct svc_procedure nfsd_procedures4[2] = { 2537 2537 [NFSPROC4_NULL] = { 2538 2538 .pc_func = nfsd4_proc_null, 2539 2539 .pc_encode = nfs4svc_encode_voidres,
+1 -1
fs/nfsd/nfsproc.c
··· 573 573 #define FH 8 /* filehandle */ 574 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 577 [NFSPROC_NULL] = { 578 578 .pc_func = nfsd_proc_null, 579 579 .pc_decode = nfssvc_decode_void,
+2 -2
fs/nfsd/nfssvc.c
··· 756 756 * problem, we enforce these assumptions here: 757 757 */ 758 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 762 * The ACL code has more careful bounds-checking and is not ··· 781 781 int 782 782 nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp) 783 783 { 784 - struct svc_procedure *proc; 784 + const struct svc_procedure *proc; 785 785 __be32 nfserr; 786 786 __be32 *nfserrp; 787 787
+2 -2
include/linux/lockd/lockd.h
··· 192 192 * Global variables 193 193 */ 194 194 extern const struct rpc_program nlm_program; 195 - extern struct svc_procedure nlmsvc_procedures[]; 195 + extern const struct svc_procedure nlmsvc_procedures[]; 196 196 #ifdef CONFIG_LOCKD_V4 197 - extern struct svc_procedure nlmsvc_procedures4[]; 197 + extern const struct svc_procedure nlmsvc_procedures4[]; 198 198 #endif 199 199 extern int nlmsvc_grace_period; 200 200 extern unsigned long nlmsvc_timeout;
+2 -2
include/linux/sunrpc/svc.h
··· 237 237 238 238 struct svc_serv * rq_server; /* RPC service definition */ 239 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 241 struct auth_ops * rq_authop; /* authentication flavour */ 242 242 struct svc_cred rq_cred; /* auth info */ 243 243 void * rq_xprt_ctxt; /* transport specific context ptr */ ··· 396 396 struct svc_version { 397 397 u32 vs_vers; /* version number */ 398 398 u32 vs_nproc; /* number of procedures */ 399 - struct svc_procedure * vs_proc; /* per-procedure info */ 399 + const struct svc_procedure *vs_proc; /* per-procedure info */ 400 400 unsigned int *vs_count; /* call counts */ 401 401 u32 vs_xdrsize; /* xdrsize needed for this version */ 402 402
+1 -1
net/sunrpc/svc.c
··· 1152 1152 { 1153 1153 struct svc_program *progp; 1154 1154 struct svc_version *versp = NULL; /* compiler food */ 1155 - struct svc_procedure *procp = NULL; 1155 + const struct svc_procedure *procp = NULL; 1156 1156 struct svc_serv *serv = rqstp->rq_server; 1157 1157 __be32 *statp; 1158 1158 u32 prog, vers, proc;