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
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) */
510struct svc_procedure nlmsvc_procedures4[] = {510const 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),
fs/lockd/svcproc.c+1−1
@@ -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
554struct svc_procedure nlmsvc_procedures[] = {554const 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),
fs/nfs/callback_xdr.c+1−1
@@ -995,7 +995,7 @@ static struct callback_op callback_ops[] = { · 994 unmodified lines
995/*995/*
996 * Define NFS4 callback procedures996 * Define NFS4 callback procedures
997 */997 */
998static struct svc_procedure nfs4_callback_procedures1[] = {998static 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,
fs/nfsd/nfs2acl.c+1−1
@@ -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
373static struct svc_procedure nfsd_acl_procedures2[] = {373static 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),
fs/nfsd/nfs3acl.c+1−1
@@ -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
260static struct svc_procedure nfsd_acl_procedures3[] = {260static 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),
fs/nfsd/nfs3proc.c+1−1
@@ -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
677static struct svc_procedure nfsd_procedures3[22] = {677static 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,
fs/nfsd/nfs4proc.c+1−1
@@ -2532,7 +2532,7 @@ static const char *nfsd4_op_name(unsigned opnum) · 2531 unmodified lines
2532#define nfsd4_voidres nfsd4_voidargs2532#define nfsd4_voidres nfsd4_voidargs
2533struct nfsd4_voidargs { int dummy; };2533struct nfsd4_voidargs { int dummy; };
2534 2534
2535static struct svc_procedure nfsd_procedures4[2] = {2535static 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,
fs/nfsd/nfsproc.c+1−1
@@ -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
576static struct svc_procedure nfsd_procedures2[18] = {576static 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,
fs/nfsd/nfssvc.c+2−2
@@ -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 */
758static bool nfs_request_too_big(struct svc_rqst *rqstp,758static 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 not762 * 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
781int781int
782nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)782nfsd_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
include/linux/lockd/lockd.h+2−2
@@ -192,9 +192,9 @@ struct nlm_block { · 191 unmodified lines
192 * Global variables192 * Global variables
193 */193 */
194extern const struct rpc_program nlm_program;194extern const struct rpc_program nlm_program;
195extern struct svc_procedure nlmsvc_procedures[];195extern const struct svc_procedure nlmsvc_procedures[];
196#ifdef CONFIG_LOCKD_V4196#ifdef CONFIG_LOCKD_V4
197extern struct svc_procedure nlmsvc_procedures4[];197extern const struct svc_procedure nlmsvc_procedures4[];
198#endif198#endif
199extern int nlmsvc_grace_period;199extern int nlmsvc_grace_period;
200extern unsigned long nlmsvc_timeout;200extern unsigned long nlmsvc_timeout;
include/linux/sunrpc/svc.h+2−2
@@ -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
397struct svc_version {397struct 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
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
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;

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