Commit 511e936b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Anna Schumaker

sunrpc: mark all struct rpc_procinfo instances as const

struct rpc_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: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent 9ae7d8ff
...@@ -584,7 +584,7 @@ static int nlm4_xdr_dec_res(struct rpc_rqst *req, ...@@ -584,7 +584,7 @@ static int nlm4_xdr_dec_res(struct rpc_rqst *req,
.p_name = #proc, \ .p_name = #proc, \
} }
static struct rpc_procinfo nlm4_procedures[] = { static const struct rpc_procinfo nlm4_procedures[] = {
PROC(TEST, testargs, testres), PROC(TEST, testargs, testres),
PROC(LOCK, lockargs, res), PROC(LOCK, lockargs, res),
PROC(CANCEL, cancargs, res), PROC(CANCEL, cancargs, res),
......
...@@ -582,7 +582,7 @@ static int nlm_xdr_dec_res(struct rpc_rqst *req, ...@@ -582,7 +582,7 @@ static int nlm_xdr_dec_res(struct rpc_rqst *req,
.p_name = #proc, \ .p_name = #proc, \
} }
static struct rpc_procinfo nlm_procedures[] = { static const struct rpc_procinfo nlm_procedures[] = {
PROC(TEST, testargs, testres), PROC(TEST, testargs, testres),
PROC(LOCK, lockargs, res), PROC(LOCK, lockargs, res),
PROC(CANCEL, cancargs, res), PROC(CANCEL, cancargs, res),
......
...@@ -531,7 +531,7 @@ static int nsm_xdr_dec_stat(struct rpc_rqst *rqstp, ...@@ -531,7 +531,7 @@ static int nsm_xdr_dec_stat(struct rpc_rqst *rqstp,
#define SM_monres_sz 2 #define SM_monres_sz 2
#define SM_unmonres_sz 1 #define SM_unmonres_sz 1
static struct rpc_procinfo nsm_procedures[] = { static const struct rpc_procinfo nsm_procedures[] = {
[NSMPROC_MON] = { [NSMPROC_MON] = {
.p_proc = NSMPROC_MON, .p_proc = NSMPROC_MON,
.p_encode = nsm_xdr_enc_mon, .p_encode = nsm_xdr_enc_mon,
......
...@@ -270,12 +270,12 @@ static inline bool nfs_match_open_context(const struct nfs_open_context *ctx1, ...@@ -270,12 +270,12 @@ static inline bool nfs_match_open_context(const struct nfs_open_context *ctx1,
} }
/* nfs2xdr.c */ /* nfs2xdr.c */
extern struct rpc_procinfo nfs_procedures[]; extern const struct rpc_procinfo nfs_procedures[];
extern int nfs2_decode_dirent(struct xdr_stream *, extern int nfs2_decode_dirent(struct xdr_stream *,
struct nfs_entry *, int); struct nfs_entry *, int);
/* nfs3xdr.c */ /* nfs3xdr.c */
extern struct rpc_procinfo nfs3_procedures[]; extern const struct rpc_procinfo nfs3_procedures[];
extern int nfs3_decode_dirent(struct xdr_stream *, extern int nfs3_decode_dirent(struct xdr_stream *,
struct nfs_entry *, int); struct nfs_entry *, int);
...@@ -292,7 +292,7 @@ extern const u32 nfs41_maxgetdevinfo_overhead; ...@@ -292,7 +292,7 @@ extern const u32 nfs41_maxgetdevinfo_overhead;
/* nfs4proc.c */ /* nfs4proc.c */
#if IS_ENABLED(CONFIG_NFS_V4) #if IS_ENABLED(CONFIG_NFS_V4)
extern struct rpc_procinfo nfs4_procedures[]; extern const struct rpc_procinfo nfs4_procedures[];
#endif #endif
#ifdef CONFIG_NFS_V4_SECURITY_LABEL #ifdef CONFIG_NFS_V4_SECURITY_LABEL
......
...@@ -466,7 +466,7 @@ static int mnt_xdr_dec_mountres3(struct rpc_rqst *req, ...@@ -466,7 +466,7 @@ static int mnt_xdr_dec_mountres3(struct rpc_rqst *req,
return decode_auth_flavors(xdr, res); return decode_auth_flavors(xdr, res);
} }
static struct rpc_procinfo mnt_procedures[] = { static const struct rpc_procinfo mnt_procedures[] = {
[MOUNTPROC_MNT] = { [MOUNTPROC_MNT] = {
.p_proc = MOUNTPROC_MNT, .p_proc = MOUNTPROC_MNT,
.p_encode = mnt_xdr_enc_dirpath, .p_encode = mnt_xdr_enc_dirpath,
...@@ -485,7 +485,7 @@ static struct rpc_procinfo mnt_procedures[] = { ...@@ -485,7 +485,7 @@ static struct rpc_procinfo mnt_procedures[] = {
}, },
}; };
static struct rpc_procinfo mnt3_procedures[] = { static const struct rpc_procinfo mnt3_procedures[] = {
[MOUNTPROC3_MNT] = { [MOUNTPROC3_MNT] = {
.p_proc = MOUNTPROC3_MNT, .p_proc = MOUNTPROC3_MNT,
.p_encode = mnt_xdr_enc_dirpath, .p_encode = mnt_xdr_enc_dirpath,
......
...@@ -1152,7 +1152,7 @@ static int nfs_stat_to_errno(enum nfs_stat status) ...@@ -1152,7 +1152,7 @@ static int nfs_stat_to_errno(enum nfs_stat status)
.p_statidx = NFSPROC_##proc, \ .p_statidx = NFSPROC_##proc, \
.p_name = #proc, \ .p_name = #proc, \
} }
struct rpc_procinfo nfs_procedures[] = { const struct rpc_procinfo nfs_procedures[] = {
PROC(GETATTR, fhandle, attrstat, 1), PROC(GETATTR, fhandle, attrstat, 1),
PROC(SETATTR, sattrargs, attrstat, 0), PROC(SETATTR, sattrargs, attrstat, 0),
PROC(LOOKUP, diropargs, diropres, 2), PROC(LOOKUP, diropargs, diropres, 2),
......
...@@ -2554,7 +2554,7 @@ static int nfs3_stat_to_errno(enum nfs_stat status) ...@@ -2554,7 +2554,7 @@ static int nfs3_stat_to_errno(enum nfs_stat status)
.p_name = #proc, \ .p_name = #proc, \
} }
struct rpc_procinfo nfs3_procedures[] = { const struct rpc_procinfo nfs3_procedures[] = {
PROC(GETATTR, getattr, getattr, 1), PROC(GETATTR, getattr, getattr, 1),
PROC(SETATTR, setattr, setattr, 0), PROC(SETATTR, setattr, setattr, 0),
PROC(LOOKUP, lookup, lookup, 2), PROC(LOOKUP, lookup, lookup, 2),
...@@ -2587,7 +2587,7 @@ const struct rpc_version nfs_version3 = { ...@@ -2587,7 +2587,7 @@ const struct rpc_version nfs_version3 = {
}; };
#ifdef CONFIG_NFS_V3_ACL #ifdef CONFIG_NFS_V3_ACL
static struct rpc_procinfo nfs3_acl_procedures[] = { static const struct rpc_procinfo nfs3_acl_procedures[] = {
[ACLPROC3_GETACL] = { [ACLPROC3_GETACL] = {
.p_proc = ACLPROC3_GETACL, .p_proc = ACLPROC3_GETACL,
.p_encode = nfs3_xdr_enc_getacl3args, .p_encode = nfs3_xdr_enc_getacl3args,
......
...@@ -493,7 +493,7 @@ static inline void nfs4_unregister_sysctl(void) ...@@ -493,7 +493,7 @@ static inline void nfs4_unregister_sysctl(void)
#endif #endif
/* nfs4xdr.c */ /* nfs4xdr.c */
extern struct rpc_procinfo nfs4_procedures[]; extern const struct rpc_procinfo nfs4_procedures[];
struct nfs4_mount_data; struct nfs4_mount_data;
......
...@@ -7594,7 +7594,7 @@ nfs4_stat_to_errno(int stat) ...@@ -7594,7 +7594,7 @@ nfs4_stat_to_errno(int stat)
.p_name = #proc, \ .p_name = #proc, \
} }
struct rpc_procinfo nfs4_procedures[] = { const struct rpc_procinfo nfs4_procedures[] = {
PROC(READ, enc_read, dec_read), PROC(READ, enc_read, dec_read),
PROC(WRITE, enc_write, dec_write), PROC(WRITE, enc_write, dec_write),
PROC(COMMIT, enc_commit, dec_commit), PROC(COMMIT, enc_commit, dec_commit),
......
...@@ -696,7 +696,7 @@ static int nfs4_xdr_dec_cb_notify_lock(struct rpc_rqst *rqstp, ...@@ -696,7 +696,7 @@ static int nfs4_xdr_dec_cb_notify_lock(struct rpc_rqst *rqstp,
.p_name = #proc, \ .p_name = #proc, \
} }
static struct rpc_procinfo nfs4_cb_procedures[] = { static const struct rpc_procinfo nfs4_cb_procedures[] = {
PROC(CB_NULL, NULL, cb_null, cb_null), PROC(CB_NULL, NULL, cb_null, cb_null),
PROC(CB_RECALL, COMPOUND, cb_recall, cb_recall), PROC(CB_RECALL, COMPOUND, cb_recall, cb_recall),
#ifdef CONFIG_NFSD_PNFS #ifdef CONFIG_NFSD_PNFS
......
...@@ -39,7 +39,7 @@ struct rpc_clnt { ...@@ -39,7 +39,7 @@ struct rpc_clnt {
struct list_head cl_tasks; /* List of tasks */ struct list_head cl_tasks; /* List of tasks */
spinlock_t cl_lock; /* spinlock */ spinlock_t cl_lock; /* spinlock */
struct rpc_xprt __rcu * cl_xprt; /* transport */ struct rpc_xprt __rcu * cl_xprt; /* transport */
struct rpc_procinfo * cl_procinfo; /* procedure info */ const struct rpc_procinfo *cl_procinfo; /* procedure info */
u32 cl_prog, /* RPC program number */ u32 cl_prog, /* RPC program number */
cl_vers, /* RPC version number */ cl_vers, /* RPC version number */
cl_maxproc; /* max procedure number */ cl_maxproc; /* max procedure number */
...@@ -87,7 +87,7 @@ struct rpc_program { ...@@ -87,7 +87,7 @@ struct rpc_program {
struct rpc_version { struct rpc_version {
u32 number; /* version number */ u32 number; /* version number */
unsigned int nrprocs; /* number of procs */ unsigned int nrprocs; /* number of procs */
struct rpc_procinfo * procs; /* procedure array */ const struct rpc_procinfo *procs; /* procedure array */
unsigned int *counts; /* call counts */ unsigned int *counts; /* call counts */
}; };
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
struct rpc_procinfo; struct rpc_procinfo;
struct rpc_message { struct rpc_message {
struct rpc_procinfo * rpc_proc; /* Procedure information */ const struct rpc_procinfo *rpc_proc; /* Procedure information */
void * rpc_argp; /* Arguments */ void * rpc_argp; /* Arguments */
void * rpc_resp; /* Result */ void * rpc_resp; /* Result */
struct rpc_cred * rpc_cred; /* Credentials */ struct rpc_cred * rpc_cred; /* Credentials */
......
...@@ -63,7 +63,7 @@ enum { ...@@ -63,7 +63,7 @@ enum {
.p_name = #proc, \ .p_name = #proc, \
} }
static struct rpc_procinfo gssp_procedures[] = { static const struct rpc_procinfo gssp_procedures[] = {
PROC(INDICATE_MECHS, indicate_mechs), PROC(INDICATE_MECHS, indicate_mechs),
PROC(GET_CALL_CONTEXT, get_call_context), PROC(GET_CALL_CONTEXT, get_call_context),
PROC(IMPORT_AND_CANON_NAME, import_and_canon_name), PROC(IMPORT_AND_CANON_NAME, import_and_canon_name),
......
...@@ -1674,7 +1674,7 @@ call_allocate(struct rpc_task *task) ...@@ -1674,7 +1674,7 @@ call_allocate(struct rpc_task *task)
unsigned int slack = task->tk_rqstp->rq_cred->cr_auth->au_cslack; unsigned int slack = task->tk_rqstp->rq_cred->cr_auth->au_cslack;
struct rpc_rqst *req = task->tk_rqstp; struct rpc_rqst *req = task->tk_rqstp;
struct rpc_xprt *xprt = req->rq_xprt; struct rpc_xprt *xprt = req->rq_xprt;
struct rpc_procinfo *proc = task->tk_msg.rpc_proc; const struct rpc_procinfo *proc = task->tk_msg.rpc_proc;
int status; int status;
dprint_status(task); dprint_status(task);
...@@ -2489,7 +2489,7 @@ static int rpcproc_decode_null(struct rpc_rqst *rqstp, struct xdr_stream *xdr, ...@@ -2489,7 +2489,7 @@ static int rpcproc_decode_null(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
return 0; return 0;
} }
static struct rpc_procinfo rpcproc_null = { static const struct rpc_procinfo rpcproc_null = {
.p_encode = rpcproc_encode_null, .p_encode = rpcproc_encode_null,
.p_decode = rpcproc_decode_null, .p_decode = rpcproc_decode_null,
}; };
......
...@@ -128,13 +128,13 @@ struct rpcbind_args { ...@@ -128,13 +128,13 @@ struct rpcbind_args {
int r_status; int r_status;
}; };
static struct rpc_procinfo rpcb_procedures2[]; static const struct rpc_procinfo rpcb_procedures2[];
static struct rpc_procinfo rpcb_procedures3[]; static const struct rpc_procinfo rpcb_procedures3[];
static struct rpc_procinfo rpcb_procedures4[]; static const struct rpc_procinfo rpcb_procedures4[];
struct rpcb_info { struct rpcb_info {
u32 rpc_vers; u32 rpc_vers;
struct rpc_procinfo * rpc_proc; const struct rpc_procinfo *rpc_proc;
}; };
static const struct rpcb_info rpcb_next_version[]; static const struct rpcb_info rpcb_next_version[];
...@@ -620,7 +620,8 @@ int rpcb_v4_register(struct net *net, const u32 program, const u32 version, ...@@ -620,7 +620,8 @@ int rpcb_v4_register(struct net *net, const u32 program, const u32 version,
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
} }
static struct rpc_task *rpcb_call_async(struct rpc_clnt *rpcb_clnt, struct rpcbind_args *map, struct rpc_procinfo *proc) static struct rpc_task *rpcb_call_async(struct rpc_clnt *rpcb_clnt,
struct rpcbind_args *map, const struct rpc_procinfo *proc)
{ {
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = proc, .rpc_proc = proc,
...@@ -671,7 +672,7 @@ static struct rpc_clnt *rpcb_find_transport_owner(struct rpc_clnt *clnt) ...@@ -671,7 +672,7 @@ static struct rpc_clnt *rpcb_find_transport_owner(struct rpc_clnt *clnt)
void rpcb_getport_async(struct rpc_task *task) void rpcb_getport_async(struct rpc_task *task)
{ {
struct rpc_clnt *clnt; struct rpc_clnt *clnt;
struct rpc_procinfo *proc; const struct rpc_procinfo *proc;
u32 bind_version; u32 bind_version;
struct rpc_xprt *xprt; struct rpc_xprt *xprt;
struct rpc_clnt *rpcb_clnt; struct rpc_clnt *rpcb_clnt;
...@@ -994,7 +995,7 @@ static int rpcb_dec_getaddr(struct rpc_rqst *req, struct xdr_stream *xdr, ...@@ -994,7 +995,7 @@ static int rpcb_dec_getaddr(struct rpc_rqst *req, struct xdr_stream *xdr,
* since the Linux kernel RPC code requires only these. * since the Linux kernel RPC code requires only these.
*/ */
static struct rpc_procinfo rpcb_procedures2[] = { static const struct rpc_procinfo rpcb_procedures2[] = {
[RPCBPROC_SET] = { [RPCBPROC_SET] = {
.p_proc = RPCBPROC_SET, .p_proc = RPCBPROC_SET,
.p_encode = rpcb_enc_mapping, .p_encode = rpcb_enc_mapping,
...@@ -1027,7 +1028,7 @@ static struct rpc_procinfo rpcb_procedures2[] = { ...@@ -1027,7 +1028,7 @@ static struct rpc_procinfo rpcb_procedures2[] = {
}, },
}; };
static struct rpc_procinfo rpcb_procedures3[] = { static const struct rpc_procinfo rpcb_procedures3[] = {
[RPCBPROC_SET] = { [RPCBPROC_SET] = {
.p_proc = RPCBPROC_SET, .p_proc = RPCBPROC_SET,
.p_encode = rpcb_enc_getaddr, .p_encode = rpcb_enc_getaddr,
...@@ -1060,7 +1061,7 @@ static struct rpc_procinfo rpcb_procedures3[] = { ...@@ -1060,7 +1061,7 @@ static struct rpc_procinfo rpcb_procedures3[] = {
}, },
}; };
static struct rpc_procinfo rpcb_procedures4[] = { static const struct rpc_procinfo rpcb_procedures4[] = {
[RPCBPROC_SET] = { [RPCBPROC_SET] = {
.p_proc = RPCBPROC_SET, .p_proc = RPCBPROC_SET,
.p_encode = rpcb_enc_getaddr, .p_encode = rpcb_enc_getaddr,
......
...@@ -191,7 +191,7 @@ void rpc_count_iostats(const struct rpc_task *task, struct rpc_iostats *stats) ...@@ -191,7 +191,7 @@ void rpc_count_iostats(const struct rpc_task *task, struct rpc_iostats *stats)
EXPORT_SYMBOL_GPL(rpc_count_iostats); EXPORT_SYMBOL_GPL(rpc_count_iostats);
static void _print_name(struct seq_file *seq, unsigned int op, static void _print_name(struct seq_file *seq, unsigned int op,
struct rpc_procinfo *procs) const struct rpc_procinfo *procs)
{ {
if (procs[op].p_name) if (procs[op].p_name)
seq_printf(seq, "\t%12s: ", procs[op].p_name); seq_printf(seq, "\t%12s: ", procs[op].p_name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment