History

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.

Christoph Hellwig committed 9 years ago

Commit b9c744c1 parent 0becc1112 files · +15 −15Browse files

Unified · Split

12 files
  1. fs/lockd/svc4proc.c +1 −1
  2. fs/lockd/svcproc.c +1 −1
  3. fs/nfs/callback_xdr.c +1 −1
  4. fs/nfsd/nfs2acl.c +1 −1
  5. fs/nfsd/nfs3acl.c +1 −1
  6. fs/nfsd/nfs3proc.c +1 −1
  7. fs/nfsd/nfs4proc.c +1 −1
  8. fs/nfsd/nfsproc.c +1 −1
  9. fs/nfsd/nfssvc.c +2 −2
  10. include/linux/lockd/lockd.h +2 −2
  11. include/linux/sunrpc/svc.h +2 −2
  12. net/sunrpc/svc.c +1 −1
fs/lockd/svc4proc.c+1−1
@@ -507,7 +507,7 @@ struct nlm_void { int dummy; }; · 506 unmodified lines
507507 #define No (1+1024/4) /* netobj */
508508 #define St 1 /* status */
509509 #define Rg 4 /* range (offset + length) */
510−struct svc_procedure nlmsvc_procedures4[] = {
510+const struct svc_procedure nlmsvc_procedures4[] = {
511511 PROC(null, void, void, void, void, 1),
512512 PROC(test, testargs, testres, args, res, Ck+St+2+No+Rg),
513513 PROC(lock, lockargs, res, args, res, Ck+St),
fs/lockd/svcproc.c+1−1
@@ -551,7 +551,7 @@ struct nlm_void { int dummy; }; · 550 unmodified lines
551551 #define No (1+1024/4) /* Net Obj */
552552 #define Rg 2 /* range - offset + size */
553553
554−struct svc_procedure nlmsvc_procedures[] = {
554+const struct svc_procedure nlmsvc_procedures[] = {
555555 PROC(null, void, void, void, void, 1),
556556 PROC(test, testargs, testres, args, res, Ck+St+2+No+Rg),
557557 PROC(lock, lockargs, res, args, res, Ck+St),
fs/nfs/callback_xdr.c+1−1
@@ -995,7 +995,7 @@ static struct callback_op callback_ops[] = { · 994 unmodified lines
995995 /*
996996 * Define NFS4 callback procedures
997997 */
998−static struct svc_procedure nfs4_callback_procedures1[] = {
998+static const struct svc_procedure nfs4_callback_procedures1[] = {
999999 [CB_NULL] = {
10001000 .pc_func = nfs4_callback_null,
10011001 .pc_decode = nfs4_decode_void,
fs/nfsd/nfs2acl.c+1−1
@@ -370,7 +370,7 @@ struct nfsd3_voidargs { int dummy; }; · 369 unmodified lines
370370 #define pAT (1+AT) /* post attributes - conditional */
371371 #define ACL (1+NFS_ACL_MAX_ENTRIES*3) /* Access Control List */
372372
373−static struct svc_procedure nfsd_acl_procedures2[] = {
373+static const struct svc_procedure nfsd_acl_procedures2[] = {
374374 PROC(null, void, void, void, RC_NOCACHE, ST),
375375 PROC(getacl, getacl, getacl, getacl, RC_NOCACHE, ST+1+2*(1+ACL)),
376376 PROC(setacl, setacl, attrstat, attrstat, RC_NOCACHE, ST+AT),
fs/nfsd/nfs3acl.c+1−1
@@ -257,7 +257,7 @@ struct nfsd3_voidargs { int dummy; }; · 256 unmodified lines
257257 #define pAT (1+AT) /* post attributes - conditional */
258258 #define ACL (1+NFS_ACL_MAX_ENTRIES*3) /* Access Control List */
259259
260−static struct svc_procedure nfsd_acl_procedures3[] = {
260+static const struct svc_procedure nfsd_acl_procedures3[] = {
261261 PROC(null, void, void, void, RC_NOCACHE, ST),
262262 PROC(getacl, getacl, getacl, getacl, RC_NOCACHE, ST+1+2*(1+ACL)),
263263 PROC(setacl, setacl, setacl, fhandle, RC_NOCACHE, ST+pAT),
fs/nfsd/nfs3proc.c+1−1
@@ -674,7 +674,7 @@ struct nfsd3_voidargs { int dummy; }; · 673 unmodified lines
674674 #define pAT (1+AT) /* post attributes - conditional */
675675 #define WC (7+pAT) /* WCC attributes */
676676
677−static struct svc_procedure nfsd_procedures3[22] = {
677+static const struct svc_procedure nfsd_procedures3[22] = {
678678 [NFS3PROC_NULL] = {
679679 .pc_func = nfsd3_proc_null,
680680 .pc_encode = nfs3svc_encode_voidres,
fs/nfsd/nfs4proc.c+1−1
@@ -2532,7 +2532,7 @@ static const char *nfsd4_op_name(unsigned opnum) · 2531 unmodified lines
25322532 #define nfsd4_voidres nfsd4_voidargs
25332533 struct nfsd4_voidargs { int dummy; };
25342534
2535−static struct svc_procedure nfsd_procedures4[2] = {
2535+static const struct svc_procedure nfsd_procedures4[2] = {
25362536 [NFSPROC4_NULL] = {
25372537 .pc_func = nfsd4_proc_null,
25382538 .pc_encode = nfs4svc_encode_voidres,
fs/nfsd/nfsproc.c+1−1
@@ -573,7 +573,7 @@ struct nfsd_void { int dummy; }; · 572 unmodified lines
573573 #define FH 8 /* filehandle */
574574 #define AT 18 /* attributes */
575575
576−static struct svc_procedure nfsd_procedures2[18] = {
576+static const struct svc_procedure nfsd_procedures2[18] = {
577577 [NFSPROC_NULL] = {
578578 .pc_func = nfsd_proc_null,
579579 .pc_decode = nfssvc_decode_void,
fs/nfsd/nfssvc.c+2−2
@@ -756,7 +756,7 @@ static __be32 map_new_errors(u32 vers, __be32 nfserr) · 755 unmodified lines
756756 * problem, we enforce these assumptions here:
757757 */
758758 static bool nfs_request_too_big(struct svc_rqst *rqstp,
759− struct svc_procedure *proc)
759+ const struct svc_procedure *proc)
760760 {
761761 /*
762762 * 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
781781 int
782782 nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
783783 {
784− struct svc_procedure *proc;
784+ const struct svc_procedure *proc;
785785 __be32 nfserr;
786786 __be32 *nfserrp;
787787
include/linux/lockd/lockd.h+2−2
@@ -192,9 +192,9 @@ struct nlm_block { · 191 unmodified lines
192192 * Global variables
193193 */
194194 extern const struct rpc_program nlm_program;
195−extern struct svc_procedure nlmsvc_procedures[];
195+extern const struct svc_procedure nlmsvc_procedures[];
196196 #ifdef CONFIG_LOCKD_V4
197−extern struct svc_procedure nlmsvc_procedures4[];
197+extern const struct svc_procedure nlmsvc_procedures4[];
198198 #endif
199199 extern int nlmsvc_grace_period;
200200 extern unsigned long nlmsvc_timeout;
include/linux/sunrpc/svc.h+2−2
@@ -237,7 +237,7 @@ struct svc_rqst { · 236 unmodified lines
237237
238238 struct svc_serv * rq_server; /* RPC service definition */
239239 struct svc_pool * rq_pool; /* thread pool */
240− struct svc_procedure * rq_procinfo; /* procedure info */
240+ const struct svc_procedure *rq_procinfo;/* procedure info */
241241 struct auth_ops * rq_authop; /* authentication flavour */
242242 struct svc_cred rq_cred; /* auth info */
243243 void * rq_xprt_ctxt; /* transport specific context ptr */
@@ -397,7 +397,7 @@ struct svc_program { · 153 unmodified lines
397397 struct svc_version {
398398 u32 vs_vers; /* version number */
399399 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 */
401401 unsigned int *vs_count; /* call counts */
402402 u32 vs_xdrsize; /* xdrsize needed for this version */
403403
net/sunrpc/svc.c+1−1
@@ -1152,7 +1152,7 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv) · 1151 unmodified lines
11521152 {
11531153 struct svc_program *progp;
11541154 struct svc_version *versp = NULL; /* compiler food */
1155− struct svc_procedure *procp = NULL;
1155+ const struct svc_procedure *procp = NULL;
11561156 struct svc_serv *serv = rqstp->rq_server;
11571157 __be32 *statp;
11581158 u32 prog, vers, proc;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t