aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd
diff options
context:
space:
mode:
Diffstat (limited to 'fs/lockd')
-rw-r--r--fs/lockd/clntlock.c10
-rw-r--r--fs/lockd/clntproc.c7
-rw-r--r--fs/lockd/svclock.c1
-rw-r--r--fs/lockd/xdr.c13
-rw-r--r--fs/lockd/xdr4.c17
5 files changed, 33 insertions, 15 deletions
diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c
index da6354baa0b8..8ae79ae4b998 100644
--- a/fs/lockd/clntlock.c
+++ b/fs/lockd/clntlock.c
@@ -125,7 +125,15 @@ u32 nlmclnt_grant(const struct sockaddr_in *addr, const struct nlm_lock *lock)
125 list_for_each_entry(block, &nlm_blocked, b_list) { 125 list_for_each_entry(block, &nlm_blocked, b_list) {
126 struct file_lock *fl_blocked = block->b_lock; 126 struct file_lock *fl_blocked = block->b_lock;
127 127
128 if (!nlm_compare_locks(fl_blocked, fl)) 128 if (fl_blocked->fl_start != fl->fl_start)
129 continue;
130 if (fl_blocked->fl_end != fl->fl_end)
131 continue;
132 /*
133 * Careful! The NLM server will return the 32-bit "pid" that
134 * we put on the wire: in this case the lockowner "pid".
135 */
136 if (fl_blocked->fl_u.nfs_fl.owner->pid != lock->svid)
129 continue; 137 continue;
130 if (!nlm_cmp_addr(&block->b_host->h_addr, addr)) 138 if (!nlm_cmp_addr(&block->b_host->h_addr, addr))
131 continue; 139 continue;
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index 615a988a92a7..acc3eb13a02b 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -132,8 +132,10 @@ static void nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl)
132 memcpy(&lock->fh, NFS_FH(fl->fl_file->f_dentry->d_inode), sizeof(struct nfs_fh)); 132 memcpy(&lock->fh, NFS_FH(fl->fl_file->f_dentry->d_inode), sizeof(struct nfs_fh));
133 lock->caller = system_utsname.nodename; 133 lock->caller = system_utsname.nodename;
134 lock->oh.data = req->a_owner; 134 lock->oh.data = req->a_owner;
135 lock->oh.len = sprintf(req->a_owner, "%d@%s", 135 lock->oh.len = snprintf(req->a_owner, sizeof(req->a_owner), "%u@%s",
136 current->pid, system_utsname.nodename); 136 (unsigned int)fl->fl_u.nfs_fl.owner->pid,
137 system_utsname.nodename);
138 lock->svid = fl->fl_u.nfs_fl.owner->pid;
137 locks_copy_lock(&lock->fl, fl); 139 locks_copy_lock(&lock->fl, fl);
138} 140}
139 141
@@ -159,6 +161,7 @@ nlmclnt_setgrantargs(struct nlm_rqst *call, struct nlm_lock *lock)
159 161
160 /* set default data area */ 162 /* set default data area */
161 call->a_args.lock.oh.data = call->a_owner; 163 call->a_args.lock.oh.data = call->a_owner;
164 call->a_args.lock.svid = lock->fl.fl_pid;
162 165
163 if (lock->oh.len > NLMCLNT_OHSIZE) { 166 if (lock->oh.len > NLMCLNT_OHSIZE) {
164 void *data = kmalloc(lock->oh.len, GFP_KERNEL); 167 void *data = kmalloc(lock->oh.len, GFP_KERNEL);
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 9cfced65d4a2..a525a141dd3b 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -397,6 +397,7 @@ nlmsvc_testlock(struct nlm_file *file, struct nlm_lock *lock,
397 (long long)fl->fl_end); 397 (long long)fl->fl_end);
398 conflock->caller = "somehost"; /* FIXME */ 398 conflock->caller = "somehost"; /* FIXME */
399 conflock->oh.len = 0; /* don't return OH info */ 399 conflock->oh.len = 0; /* don't return OH info */
400 conflock->svid = fl->fl_pid;
400 conflock->fl = *fl; 401 conflock->fl = *fl;
401 return nlm_lck_denied; 402 return nlm_lck_denied;
402 } 403 }
diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c
index 200fbda2c6d1..1e984ab14d3f 100644
--- a/fs/lockd/xdr.c
+++ b/fs/lockd/xdr.c
@@ -131,10 +131,11 @@ nlm_decode_lock(u32 *p, struct nlm_lock *lock)
131 || !(p = nlm_decode_fh(p, &lock->fh)) 131 || !(p = nlm_decode_fh(p, &lock->fh))
132 || !(p = nlm_decode_oh(p, &lock->oh))) 132 || !(p = nlm_decode_oh(p, &lock->oh)))
133 return NULL; 133 return NULL;
134 lock->svid = ntohl(*p++);
134 135
135 locks_init_lock(fl); 136 locks_init_lock(fl);
136 fl->fl_owner = current->files; 137 fl->fl_owner = current->files;
137 fl->fl_pid = ntohl(*p++); 138 fl->fl_pid = (pid_t)lock->svid;
138 fl->fl_flags = FL_POSIX; 139 fl->fl_flags = FL_POSIX;
139 fl->fl_type = F_RDLCK; /* as good as anything else */ 140 fl->fl_type = F_RDLCK; /* as good as anything else */
140 start = ntohl(*p++); 141 start = ntohl(*p++);
@@ -174,7 +175,7 @@ nlm_encode_lock(u32 *p, struct nlm_lock *lock)
174 else 175 else
175 len = loff_t_to_s32(fl->fl_end - fl->fl_start + 1); 176 len = loff_t_to_s32(fl->fl_end - fl->fl_start + 1);
176 177
177 *p++ = htonl(fl->fl_pid); 178 *p++ = htonl(lock->svid);
178 *p++ = htonl(start); 179 *p++ = htonl(start);
179 *p++ = htonl(len); 180 *p++ = htonl(len);
180 181
@@ -197,7 +198,7 @@ nlm_encode_testres(u32 *p, struct nlm_res *resp)
197 struct file_lock *fl = &resp->lock.fl; 198 struct file_lock *fl = &resp->lock.fl;
198 199
199 *p++ = (fl->fl_type == F_RDLCK)? xdr_zero : xdr_one; 200 *p++ = (fl->fl_type == F_RDLCK)? xdr_zero : xdr_one;
200 *p++ = htonl(fl->fl_pid); 201 *p++ = htonl(resp->lock.svid);
201 202
202 /* Encode owner handle. */ 203 /* Encode owner handle. */
203 if (!(p = xdr_encode_netobj(p, &resp->lock.oh))) 204 if (!(p = xdr_encode_netobj(p, &resp->lock.oh)))
@@ -298,7 +299,8 @@ nlmsvc_decode_shareargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp)
298 299
299 memset(lock, 0, sizeof(*lock)); 300 memset(lock, 0, sizeof(*lock));
300 locks_init_lock(&lock->fl); 301 locks_init_lock(&lock->fl);
301 lock->fl.fl_pid = ~(u32) 0; 302 lock->svid = ~(u32) 0;
303 lock->fl.fl_pid = (pid_t)lock->svid;
302 304
303 if (!(p = nlm_decode_cookie(p, &argp->cookie)) 305 if (!(p = nlm_decode_cookie(p, &argp->cookie))
304 || !(p = xdr_decode_string_inplace(p, &lock->caller, 306 || !(p = xdr_decode_string_inplace(p, &lock->caller,
@@ -415,7 +417,8 @@ nlmclt_decode_testres(struct rpc_rqst *req, u32 *p, struct nlm_res *resp)
415 memset(&resp->lock, 0, sizeof(resp->lock)); 417 memset(&resp->lock, 0, sizeof(resp->lock));
416 locks_init_lock(fl); 418 locks_init_lock(fl);
417 excl = ntohl(*p++); 419 excl = ntohl(*p++);
418 fl->fl_pid = ntohl(*p++); 420 resp->lock.svid = ntohl(*p++);
421 fl->fl_pid = (pid_t)resp->lock.svid;
419 if (!(p = nlm_decode_oh(p, &resp->lock.oh))) 422 if (!(p = nlm_decode_oh(p, &resp->lock.oh)))
420 return -EIO; 423 return -EIO;
421 424
diff --git a/fs/lockd/xdr4.c b/fs/lockd/xdr4.c
index fdcf105a5303..906ddc203186 100644
--- a/fs/lockd/xdr4.c
+++ b/fs/lockd/xdr4.c
@@ -130,10 +130,11 @@ nlm4_decode_lock(u32 *p, struct nlm_lock *lock)
130 || !(p = nlm4_decode_fh(p, &lock->fh)) 130 || !(p = nlm4_decode_fh(p, &lock->fh))
131 || !(p = nlm4_decode_oh(p, &lock->oh))) 131 || !(p = nlm4_decode_oh(p, &lock->oh)))
132 return NULL; 132 return NULL;
133 lock->svid = ntohl(*p++);
133 134
134 locks_init_lock(fl); 135 locks_init_lock(fl);
135 fl->fl_owner = current->files; 136 fl->fl_owner = current->files;
136 fl->fl_pid = ntohl(*p++); 137 fl->fl_pid = (pid_t)lock->svid;
137 fl->fl_flags = FL_POSIX; 138 fl->fl_flags = FL_POSIX;
138 fl->fl_type = F_RDLCK; /* as good as anything else */ 139 fl->fl_type = F_RDLCK; /* as good as anything else */
139 p = xdr_decode_hyper(p, &start); 140 p = xdr_decode_hyper(p, &start);
@@ -167,7 +168,7 @@ nlm4_encode_lock(u32 *p, struct nlm_lock *lock)
167 || (fl->fl_end > NLM4_OFFSET_MAX && fl->fl_end != OFFSET_MAX)) 168 || (fl->fl_end > NLM4_OFFSET_MAX && fl->fl_end != OFFSET_MAX))
168 return NULL; 169 return NULL;
169 170
170 *p++ = htonl(fl->fl_pid); 171 *p++ = htonl(lock->svid);
171 172
172 start = loff_t_to_s64(fl->fl_start); 173 start = loff_t_to_s64(fl->fl_start);
173 if (fl->fl_end == OFFSET_MAX) 174 if (fl->fl_end == OFFSET_MAX)
@@ -198,7 +199,7 @@ nlm4_encode_testres(u32 *p, struct nlm_res *resp)
198 struct file_lock *fl = &resp->lock.fl; 199 struct file_lock *fl = &resp->lock.fl;
199 200
200 *p++ = (fl->fl_type == F_RDLCK)? xdr_zero : xdr_one; 201 *p++ = (fl->fl_type == F_RDLCK)? xdr_zero : xdr_one;
201 *p++ = htonl(fl->fl_pid); 202 *p++ = htonl(resp->lock.svid);
202 203
203 /* Encode owner handle. */ 204 /* Encode owner handle. */
204 if (!(p = xdr_encode_netobj(p, &resp->lock.oh))) 205 if (!(p = xdr_encode_netobj(p, &resp->lock.oh)))
@@ -212,8 +213,8 @@ nlm4_encode_testres(u32 *p, struct nlm_res *resp)
212 213
213 p = xdr_encode_hyper(p, start); 214 p = xdr_encode_hyper(p, start);
214 p = xdr_encode_hyper(p, len); 215 p = xdr_encode_hyper(p, len);
215 dprintk("xdr: encode_testres (status %d pid %d type %d start %Ld end %Ld)\n", 216 dprintk("xdr: encode_testres (status %u pid %d type %d start %Ld end %Ld)\n",
216 resp->status, fl->fl_pid, fl->fl_type, 217 resp->status, (int)resp->lock.svid, fl->fl_type,
217 (long long)fl->fl_start, (long long)fl->fl_end); 218 (long long)fl->fl_start, (long long)fl->fl_end);
218 } 219 }
219 220
@@ -303,7 +304,8 @@ nlm4svc_decode_shareargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp)
303 304
304 memset(lock, 0, sizeof(*lock)); 305 memset(lock, 0, sizeof(*lock));
305 locks_init_lock(&lock->fl); 306 locks_init_lock(&lock->fl);
306 lock->fl.fl_pid = ~(u32) 0; 307 lock->svid = ~(u32) 0;
308 lock->fl.fl_pid = (pid_t)lock->svid;
307 309
308 if (!(p = nlm4_decode_cookie(p, &argp->cookie)) 310 if (!(p = nlm4_decode_cookie(p, &argp->cookie))
309 || !(p = xdr_decode_string_inplace(p, &lock->caller, 311 || !(p = xdr_decode_string_inplace(p, &lock->caller,
@@ -420,7 +422,8 @@ nlm4clt_decode_testres(struct rpc_rqst *req, u32 *p, struct nlm_res *resp)
420 memset(&resp->lock, 0, sizeof(resp->lock)); 422 memset(&resp->lock, 0, sizeof(resp->lock));
421 locks_init_lock(fl); 423 locks_init_lock(fl);
422 excl = ntohl(*p++); 424 excl = ntohl(*p++);
423 fl->fl_pid = ntohl(*p++); 425 resp->lock.svid = ntohl(*p++);
426 fl->fl_pid = (pid_t)resp->lock.svid;
424 if (!(p = nlm4_decode_oh(p, &resp->lock.oh))) 427 if (!(p = nlm4_decode_oh(p, &resp->lock.oh)))
425 return -EIO; 428 return -EIO;
426 429