Skip to content

Commit b9c744c

Browse files
Christoph Hellwigamschuma-ntap
authored andcommitted
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. Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 0becc11 commit b9c744c

12 files changed

Lines changed: 15 additions & 15 deletions

File tree

fs/lockd/svc4proc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ struct nlm_void { int dummy; };
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ struct nlm_void { int dummy; };
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ static struct callback_op callback_ops[] = {
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ struct nfsd3_voidargs { int dummy; };
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ struct nfsd3_voidargs { int dummy; };
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ struct nfsd3_voidargs { int dummy; };
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2532,7 +2532,7 @@ static const char *nfsd4_op_name(unsigned opnum)
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ struct nfsd_void { int dummy; };
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ static __be32 map_new_errors(u32 vers, __be32 nfserr)
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,
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ struct nlm_block {
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;

0 commit comments

Comments
 (0)