diff options
author | Christoph Hellwig <hch@lst.de> | 2017-05-08 17:46:47 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2017-05-15 11:42:32 -0400 |
commit | bb2a8b0cd116219777b99cb71fe9e24b31d3f521 (patch) | |
tree | 94bd2b3746f948c4c487365354b5eb0d4a4d9786 /fs/nfsd | |
parent | e9679189e34b25a1b9aa77fe37d331559d1544af (diff) |
nfsd4: const-ify nfsd4_ops
nfsd4_ops 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>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfs4proc.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index e814c1946f6e..fe6cb5b6d31c 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -1584,7 +1584,7 @@ struct nfsd4_operation { | |||
1584 | union nfsd4_op_u *); | 1584 | union nfsd4_op_u *); |
1585 | }; | 1585 | }; |
1586 | 1586 | ||
1587 | static struct nfsd4_operation nfsd4_ops[]; | 1587 | static const struct nfsd4_operation nfsd4_ops[]; |
1588 | 1588 | ||
1589 | static const char *nfsd4_op_name(unsigned opnum); | 1589 | static const char *nfsd4_op_name(unsigned opnum); |
1590 | 1590 | ||
@@ -1621,7 +1621,7 @@ static __be32 nfs41_check_op_ordering(struct nfsd4_compoundargs *args) | |||
1621 | return nfs_ok; | 1621 | return nfs_ok; |
1622 | } | 1622 | } |
1623 | 1623 | ||
1624 | static inline struct nfsd4_operation *OPDESC(struct nfsd4_op *op) | 1624 | static inline const struct nfsd4_operation *OPDESC(struct nfsd4_op *op) |
1625 | { | 1625 | { |
1626 | return &nfsd4_ops[op->opnum]; | 1626 | return &nfsd4_ops[op->opnum]; |
1627 | } | 1627 | } |
@@ -1639,10 +1639,9 @@ static bool need_wrongsec_check(struct svc_rqst *rqstp) | |||
1639 | struct nfsd4_compoundargs *argp = rqstp->rq_argp; | 1639 | struct nfsd4_compoundargs *argp = rqstp->rq_argp; |
1640 | struct nfsd4_op *this = &argp->ops[resp->opcnt - 1]; | 1640 | struct nfsd4_op *this = &argp->ops[resp->opcnt - 1]; |
1641 | struct nfsd4_op *next = &argp->ops[resp->opcnt]; | 1641 | struct nfsd4_op *next = &argp->ops[resp->opcnt]; |
1642 | struct nfsd4_operation *thisd; | 1642 | const struct nfsd4_operation *thisd = OPDESC(this); |
1643 | struct nfsd4_operation *nextd; | 1643 | const struct nfsd4_operation *nextd; |
1644 | 1644 | ||
1645 | thisd = OPDESC(this); | ||
1646 | /* | 1645 | /* |
1647 | * Most ops check wronsec on our own; only the putfh-like ops | 1646 | * Most ops check wronsec on our own; only the putfh-like ops |
1648 | * have special rules. | 1647 | * have special rules. |
@@ -1695,7 +1694,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp) | |||
1695 | struct nfsd4_compoundargs *args = rqstp->rq_argp; | 1694 | struct nfsd4_compoundargs *args = rqstp->rq_argp; |
1696 | struct nfsd4_compoundres *resp = rqstp->rq_resp; | 1695 | struct nfsd4_compoundres *resp = rqstp->rq_resp; |
1697 | struct nfsd4_op *op; | 1696 | struct nfsd4_op *op; |
1698 | struct nfsd4_operation *opdesc; | 1697 | const struct nfsd4_operation *opdesc; |
1699 | struct nfsd4_compound_state *cstate = &resp->cstate; | 1698 | struct nfsd4_compound_state *cstate = &resp->cstate; |
1700 | struct svc_fh *current_fh = &cstate->current_fh; | 1699 | struct svc_fh *current_fh = &cstate->current_fh; |
1701 | struct svc_fh *save_fh = &cstate->save_fh; | 1700 | struct svc_fh *save_fh = &cstate->save_fh; |
@@ -2109,7 +2108,7 @@ static inline u32 nfsd4_seek_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) | |||
2109 | return (op_encode_hdr_size + 3) * sizeof(__be32); | 2108 | return (op_encode_hdr_size + 3) * sizeof(__be32); |
2110 | } | 2109 | } |
2111 | 2110 | ||
2112 | static struct nfsd4_operation nfsd4_ops[] = { | 2111 | static const struct nfsd4_operation nfsd4_ops[] = { |
2113 | [OP_ACCESS] = { | 2112 | [OP_ACCESS] = { |
2114 | .op_func = nfsd4_access, | 2113 | .op_func = nfsd4_access, |
2115 | .op_name = "OP_ACCESS", | 2114 | .op_name = "OP_ACCESS", |