]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
sunrpc: mark all struct svc_procinfo instances as const
authorChristoph Hellwig <hch@lst.de>
Fri, 12 May 2017 14:11:49 +0000 (16:11 +0200)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Thu, 13 Jul 2017 19:58:02 +0000 (15:58 -0400)
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>
12 files changed:
fs/lockd/svc4proc.c
fs/lockd/svcproc.c
fs/nfs/callback_xdr.c
fs/nfsd/nfs2acl.c
fs/nfsd/nfs3acl.c
fs/nfsd/nfs3proc.c
fs/nfsd/nfs4proc.c
fs/nfsd/nfsproc.c
fs/nfsd/nfssvc.c
include/linux/lockd/lockd.h
include/linux/sunrpc/svc.h
net/sunrpc/svc.c

index fed016155791767436bc8e7f90e7cf5ef5bc9103..82925f17ec45f554378696cfcb3faacb4f0544b8 100644 (file)
@@ -507,7 +507,7 @@ struct nlm_void                     { int dummy; };
 #define        No      (1+1024/4)                              /* netobj */
 #define        St      1                                       /* status */
 #define        Rg      4                                       /* range (offset + length) */
-struct svc_procedure           nlmsvc_procedures4[] = {
+const struct svc_procedure nlmsvc_procedures4[] = {
   PROC(null,           void,           void,           void,   void, 1),
   PROC(test,           testargs,       testres,        args,   res, Ck+St+2+No+Rg),
   PROC(lock,           lockargs,       res,            args,   res, Ck+St),
index 14648b051eba087027187d397da7092e41191975..07915162581d62fcb58538dbf147d72ef8dcc81e 100644 (file)
@@ -551,7 +551,7 @@ struct nlm_void                     { int dummy; };
 #define        No      (1+1024/4)                      /* Net Obj */
 #define        Rg      2                               /* range - offset + size */
 
-struct svc_procedure           nlmsvc_procedures[] = {
+const struct svc_procedure nlmsvc_procedures[] = {
   PROC(null,           void,           void,           void,   void, 1),
   PROC(test,           testargs,       testres,        args,   res, Ck+St+2+No+Rg),
   PROC(lock,           lockargs,       res,            args,   res, Ck+St),
index ecd46b8c098517a83aace2d3556f59477d280af6..ae249f27297f94f1e3b56fe55365c4e664a5094f 100644 (file)
@@ -995,7 +995,7 @@ static struct callback_op callback_ops[] = {
 /*
  * Define NFS4 callback procedures
  */
-static struct svc_procedure nfs4_callback_procedures1[] = {
+static const struct svc_procedure nfs4_callback_procedures1[] = {
        [CB_NULL] = {
                .pc_func = nfs4_callback_null,
                .pc_decode = nfs4_decode_void,
index 026edfe73fd5b132aff70279e89858f4e340c67e..c3f6b8a6b659c5d7a091ea5ad6c566ea5ee3d552 100644 (file)
@@ -370,7 +370,7 @@ struct nfsd3_voidargs { int dummy; };
 #define pAT (1+AT)     /* post attributes - conditional */
 #define ACL (1+NFS_ACL_MAX_ENTRIES*3)  /* Access Control List */
 
-static struct svc_procedure            nfsd_acl_procedures2[] = {
+static const struct svc_procedure nfsd_acl_procedures2[] = {
   PROC(null,   void,           void,           void,     RC_NOCACHE, ST),
   PROC(getacl, getacl,         getacl,         getacl,   RC_NOCACHE, ST+1+2*(1+ACL)),
   PROC(setacl, setacl,         attrstat,       attrstat, RC_NOCACHE, ST+AT),
index 73c0970ccefb458d6250054634545924cd86f166..1a482ac9d4e953082bcb1746ba9413ca5b1ba1a9 100644 (file)
@@ -257,7 +257,7 @@ struct nfsd3_voidargs { int dummy; };
 #define pAT (1+AT)     /* post attributes - conditional */
 #define ACL (1+NFS_ACL_MAX_ENTRIES*3)  /* Access Control List */
 
-static struct svc_procedure            nfsd_acl_procedures3[] = {
+static const struct svc_procedure nfsd_acl_procedures3[] = {
   PROC(null,   void,           void,           void,     RC_NOCACHE, ST),
   PROC(getacl, getacl,         getacl,         getacl,   RC_NOCACHE, ST+1+2*(1+ACL)),
   PROC(setacl, setacl,         setacl,         fhandle,  RC_NOCACHE, ST+pAT),
index b5823802e2785fa2605fe43cc7b9540a81743cfd..96e0e6a2af5109f9f8e97a34a1da7355fb2f996c 100644 (file)
@@ -674,7 +674,7 @@ struct nfsd3_voidargs { int dummy; };
 #define pAT (1+AT)     /* post attributes - conditional */
 #define WC (7+pAT)     /* WCC attributes */
 
-static struct svc_procedure            nfsd_procedures3[22] = {
+static const struct svc_procedure nfsd_procedures3[22] = {
        [NFS3PROC_NULL] = {
                .pc_func = nfsd3_proc_null,
                .pc_encode = nfs3svc_encode_voidres,
index 4de6a995072264bab23477d741f750b7edfcef28..68aa175b1cb32149ef5119f5a33c7611bf40344f 100644 (file)
@@ -2532,7 +2532,7 @@ static const char *nfsd4_op_name(unsigned opnum)
 #define nfsd4_voidres                  nfsd4_voidargs
 struct nfsd4_voidargs { int dummy; };
 
-static struct svc_procedure            nfsd_procedures4[2] = {
+static const struct svc_procedure nfsd_procedures4[2] = {
        [NFSPROC4_NULL] = {
                .pc_func = nfsd4_proc_null,
                .pc_encode = nfs4svc_encode_voidres,
index 44b157553733754264c1f481b19a2977ef5a8e7a..a68b686fda121fba4f1088808a95502c9eeeb842 100644 (file)
@@ -573,7 +573,7 @@ struct nfsd_void { int dummy; };
 #define FH 8           /* filehandle */
 #define        AT 18           /* attributes */
 
-static struct svc_procedure            nfsd_procedures2[18] = {
+static const struct svc_procedure nfsd_procedures2[18] = {
        [NFSPROC_NULL] = {
                .pc_func = nfsd_proc_null,
                .pc_decode = nfssvc_decode_void,
index 5552336641246e376573956bfa667d2d4cea3c3a..379b310c445d3c0352dc00d951da1a27f9dce341 100644 (file)
@@ -756,7 +756,7 @@ static __be32 map_new_errors(u32 vers, __be32 nfserr)
  * problem, we enforce these assumptions here:
  */
 static bool nfs_request_too_big(struct svc_rqst *rqstp,
-                               struct svc_procedure *proc)
+                               const struct svc_procedure *proc)
 {
        /*
         * 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,
 int
 nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
 {
-       struct svc_procedure    *proc;
+       const struct svc_procedure *proc;
        __be32                  nfserr;
        __be32                  *nfserrp;
 
index 41f7b6a04d6914841a155d4734d308f6b4cc8d00..3eca6772836660a74097fc1d459e3ff716d00088 100644 (file)
@@ -192,9 +192,9 @@ struct nlm_block {
  * Global variables
  */
 extern const struct rpc_program        nlm_program;
-extern struct svc_procedure    nlmsvc_procedures[];
+extern const struct svc_procedure nlmsvc_procedures[];
 #ifdef CONFIG_LOCKD_V4
-extern struct svc_procedure    nlmsvc_procedures4[];
+extern const struct svc_procedure nlmsvc_procedures4[];
 #endif
 extern int                     nlmsvc_grace_period;
 extern unsigned long           nlmsvc_timeout;
index bcd114f038ef185bb62bfa62763020828a74059e..992ea34197958a8c56cb99b8ee8df2947c5d8da6 100644 (file)
@@ -237,7 +237,7 @@ struct svc_rqst {
 
        struct svc_serv *       rq_server;      /* RPC service definition */
        struct svc_pool *       rq_pool;        /* thread pool */
-       struct svc_procedure *  rq_procinfo;    /* procedure info */
+       const struct svc_procedure *rq_procinfo;/* procedure info */
        struct auth_ops *       rq_authop;      /* authentication flavour */
        struct svc_cred         rq_cred;        /* auth info */
        void *                  rq_xprt_ctxt;   /* transport specific context ptr */
@@ -397,7 +397,7 @@ struct svc_program {
 struct svc_version {
        u32                     vs_vers;        /* version number */
        u32                     vs_nproc;       /* number of procedures */
-       struct svc_procedure *  vs_proc;        /* per-procedure info */
+       const struct svc_procedure *vs_proc;    /* per-procedure info */
        unsigned int            *vs_count;      /* call counts */
        u32                     vs_xdrsize;     /* xdrsize needed for this version */
 
index 6452592194ac05654b4d78de9e8c5553f47c07e4..049963d676a79fc05d983e1bd093ba03cb080cc4 100644 (file)
@@ -1152,7 +1152,7 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
 {
        struct svc_program      *progp;
        struct svc_version      *versp = NULL;  /* compiler food */
-       struct svc_procedure    *procp = NULL;
+       const struct svc_procedure *procp = NULL;
        struct svc_serv         *serv = rqstp->rq_server;
        __be32                  *statp;
        u32                     prog, vers, proc;