diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2007-11-01 16:56:53 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@citi.umich.edu> | 2008-02-01 16:42:02 -0500 |
commit | 48df020aa17ac95a012ff765b0086ede5996b320 (patch) | |
tree | 52aa9d1ff1e320ead499bddfe98cb05b06df1311 | |
parent | e5cff482c78a35b9f149a06aa777a1bd693864fb (diff) |
NLM: Fix sign of length of NLM variable length strings
According to The Open Group's NLM specification, NLM callers are variable
length strings. XDR variable length strings use an unsigned 32 bit length.
And internally, negative string lengths are not meaningful for the Linux
NLM implementation.
Clean up: Make nlm_lock.len and nlm_reboot.len unsigned integers. This
makes the sign of NLM string lengths consistent with the sign of xdr_netobj
lengths.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Acked-By: NeilBrown <neilb@suse.de>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
-rw-r--r-- | fs/lockd/host.c | 19 | ||||
-rw-r--r-- | include/linux/lockd/lockd.h | 9 | ||||
-rw-r--r-- | include/linux/lockd/xdr.h | 4 |
3 files changed, 19 insertions, 13 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c index 572601e98dcd..ebec0098efbf 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c | |||
@@ -34,10 +34,10 @@ static DEFINE_MUTEX(nlm_host_mutex); | |||
34 | 34 | ||
35 | static void nlm_gc_hosts(void); | 35 | static void nlm_gc_hosts(void); |
36 | static struct nsm_handle * __nsm_find(const struct sockaddr_in *, | 36 | static struct nsm_handle * __nsm_find(const struct sockaddr_in *, |
37 | const char *, int, int); | 37 | const char *, unsigned int, int); |
38 | static struct nsm_handle * nsm_find(const struct sockaddr_in *sin, | 38 | static struct nsm_handle * nsm_find(const struct sockaddr_in *sin, |
39 | const char *hostname, | 39 | const char *hostname, |
40 | int hostname_len); | 40 | unsigned int hostname_len); |
41 | 41 | ||
42 | /* | 42 | /* |
43 | * Common host lookup routine for server & client | 43 | * Common host lookup routine for server & client |
@@ -45,7 +45,8 @@ static struct nsm_handle * nsm_find(const struct sockaddr_in *sin, | |||
45 | static struct nlm_host * | 45 | static struct nlm_host * |
46 | nlm_lookup_host(int server, const struct sockaddr_in *sin, | 46 | nlm_lookup_host(int server, const struct sockaddr_in *sin, |
47 | int proto, int version, const char *hostname, | 47 | int proto, int version, const char *hostname, |
48 | int hostname_len, const struct sockaddr_in *ssin) | 48 | unsigned int hostname_len, |
49 | const struct sockaddr_in *ssin) | ||
49 | { | 50 | { |
50 | struct hlist_head *chain; | 51 | struct hlist_head *chain; |
51 | struct hlist_node *pos; | 52 | struct hlist_node *pos; |
@@ -176,7 +177,7 @@ nlm_destroy_host(struct nlm_host *host) | |||
176 | */ | 177 | */ |
177 | struct nlm_host * | 178 | struct nlm_host * |
178 | nlmclnt_lookup_host(const struct sockaddr_in *sin, int proto, int version, | 179 | nlmclnt_lookup_host(const struct sockaddr_in *sin, int proto, int version, |
179 | const char *hostname, int hostname_len) | 180 | const char *hostname, unsigned int hostname_len) |
180 | { | 181 | { |
181 | struct sockaddr_in ssin = {0}; | 182 | struct sockaddr_in ssin = {0}; |
182 | 183 | ||
@@ -189,7 +190,7 @@ nlmclnt_lookup_host(const struct sockaddr_in *sin, int proto, int version, | |||
189 | */ | 190 | */ |
190 | struct nlm_host * | 191 | struct nlm_host * |
191 | nlmsvc_lookup_host(struct svc_rqst *rqstp, | 192 | nlmsvc_lookup_host(struct svc_rqst *rqstp, |
192 | const char *hostname, int hostname_len) | 193 | const char *hostname, unsigned int hostname_len) |
193 | { | 194 | { |
194 | struct sockaddr_in ssin = {0}; | 195 | struct sockaddr_in ssin = {0}; |
195 | 196 | ||
@@ -307,7 +308,8 @@ void nlm_release_host(struct nlm_host *host) | |||
307 | * Release all resources held by that peer. | 308 | * Release all resources held by that peer. |
308 | */ | 309 | */ |
309 | void nlm_host_rebooted(const struct sockaddr_in *sin, | 310 | void nlm_host_rebooted(const struct sockaddr_in *sin, |
310 | const char *hostname, int hostname_len, | 311 | const char *hostname, |
312 | unsigned int hostname_len, | ||
311 | u32 new_state) | 313 | u32 new_state) |
312 | { | 314 | { |
313 | struct hlist_head *chain; | 315 | struct hlist_head *chain; |
@@ -449,7 +451,7 @@ static DEFINE_MUTEX(nsm_mutex); | |||
449 | 451 | ||
450 | static struct nsm_handle * | 452 | static struct nsm_handle * |
451 | __nsm_find(const struct sockaddr_in *sin, | 453 | __nsm_find(const struct sockaddr_in *sin, |
452 | const char *hostname, int hostname_len, | 454 | const char *hostname, unsigned int hostname_len, |
453 | int create) | 455 | int create) |
454 | { | 456 | { |
455 | struct nsm_handle *nsm = NULL; | 457 | struct nsm_handle *nsm = NULL; |
@@ -503,7 +505,8 @@ out: | |||
503 | } | 505 | } |
504 | 506 | ||
505 | static struct nsm_handle * | 507 | static struct nsm_handle * |
506 | nsm_find(const struct sockaddr_in *sin, const char *hostname, int hostname_len) | 508 | nsm_find(const struct sockaddr_in *sin, const char *hostname, |
509 | unsigned int hostname_len) | ||
507 | { | 510 | { |
508 | return __nsm_find(sin, hostname, hostname_len, 1); | 511 | return __nsm_find(sin, hostname, hostname_len, 1); |
509 | } | 512 | } |
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h index e2d1ce36b367..4babb2a129ac 100644 --- a/include/linux/lockd/lockd.h +++ b/include/linux/lockd/lockd.h | |||
@@ -173,14 +173,17 @@ void nlmclnt_next_cookie(struct nlm_cookie *); | |||
173 | /* | 173 | /* |
174 | * Host cache | 174 | * Host cache |
175 | */ | 175 | */ |
176 | struct nlm_host * nlmclnt_lookup_host(const struct sockaddr_in *, int, int, const char *, int); | 176 | struct nlm_host *nlmclnt_lookup_host(const struct sockaddr_in *, int, int, |
177 | struct nlm_host * nlmsvc_lookup_host(struct svc_rqst *, const char *, int); | 177 | const char *, unsigned int); |
178 | struct nlm_host *nlmsvc_lookup_host(struct svc_rqst *, const char *, | ||
179 | unsigned int); | ||
178 | struct rpc_clnt * nlm_bind_host(struct nlm_host *); | 180 | struct rpc_clnt * nlm_bind_host(struct nlm_host *); |
179 | void nlm_rebind_host(struct nlm_host *); | 181 | void nlm_rebind_host(struct nlm_host *); |
180 | struct nlm_host * nlm_get_host(struct nlm_host *); | 182 | struct nlm_host * nlm_get_host(struct nlm_host *); |
181 | void nlm_release_host(struct nlm_host *); | 183 | void nlm_release_host(struct nlm_host *); |
182 | void nlm_shutdown_hosts(void); | 184 | void nlm_shutdown_hosts(void); |
183 | extern void nlm_host_rebooted(const struct sockaddr_in *, const char *, int, u32); | 185 | extern void nlm_host_rebooted(const struct sockaddr_in *, const char *, |
186 | unsigned int, u32); | ||
184 | void nsm_release(struct nsm_handle *); | 187 | void nsm_release(struct nsm_handle *); |
185 | 188 | ||
186 | 189 | ||
diff --git a/include/linux/lockd/xdr.h b/include/linux/lockd/xdr.h index 83a1f9f6237b..df18fa053bcd 100644 --- a/include/linux/lockd/xdr.h +++ b/include/linux/lockd/xdr.h | |||
@@ -29,7 +29,7 @@ struct svc_rqst; | |||
29 | /* Lock info passed via NLM */ | 29 | /* Lock info passed via NLM */ |
30 | struct nlm_lock { | 30 | struct nlm_lock { |
31 | char * caller; | 31 | char * caller; |
32 | int len; /* length of "caller" */ | 32 | unsigned int len; /* length of "caller" */ |
33 | struct nfs_fh fh; | 33 | struct nfs_fh fh; |
34 | struct xdr_netobj oh; | 34 | struct xdr_netobj oh; |
35 | u32 svid; | 35 | u32 svid; |
@@ -78,7 +78,7 @@ struct nlm_res { | |||
78 | */ | 78 | */ |
79 | struct nlm_reboot { | 79 | struct nlm_reboot { |
80 | char * mon; | 80 | char * mon; |
81 | int len; | 81 | unsigned int len; |
82 | u32 state; | 82 | u32 state; |
83 | __be32 addr; | 83 | __be32 addr; |
84 | __be32 vers; | 84 | __be32 vers; |