Linux: Fix conversion of whole-file locks

An overflow bug in commit 49b7bbdd3b
caused whole-file locks to be treated as byte-range locks, which fail
to be propagated to other machines.

Fix this by setting l_len = 0 for locks that range to the end of the
file.

FIXES 126561

Change-Id: Ie2dc9d04f33559c73b3b86b64152c549b785f8ad
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Reviewed-on: http://gerrit.openafs.org/1352
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit d3abbebcb0)
Reviewed-on: http://gerrit.openafs.org/1372
This commit is contained in:
Anders Kaseorg 2010-02-20 20:28:42 -05:00 committed by Derrick Brashear
parent fd82293843
commit 2057e796df

View File

@ -491,7 +491,10 @@ afs_linux_lock(struct file *fp, int cmd, struct file_lock *flp)
flock.l_pid = flp->fl_pid;
flock.l_whence = 0;
flock.l_start = flp->fl_start;
flock.l_len = flp->fl_end - flp->fl_start + 1;
if (flp->fl_end == OFFSET_MAX)
flock.l_len = 0; /* Lock to end of file */
else
flock.l_len = flp->fl_end - flp->fl_start + 1;
/* Safe because there are no large files, yet */
#if defined(F_GETLK64) && (F_GETLK != F_GETLK64)
@ -558,7 +561,10 @@ afs_linux_lock(struct file *fp, int cmd, struct file_lock *flp)
flp->fl_type = flock.l_type;
flp->fl_pid = flock.l_pid;
flp->fl_start = flock.l_start;
flp->fl_end = flock.l_start + flock.l_len - 1;
if (flock.l_len == 0)
flp->fl_end = OFFSET_MAX; /* Lock to end of file */
else
flp->fl_end = flock.l_start + flock.l_len - 1;
crfree(credp);
return afs_convert_code(code);
@ -577,7 +583,7 @@ afs_linux_flock(struct file *fp, int cmd, struct file_lock *flp) {
flock.l_pid = flp->fl_pid;
flock.l_whence = 0;
flock.l_start = 0;
flock.l_len = OFFSET_MAX;
flock.l_len = 0;
/* Safe because there are no large files, yet */
#if defined(F_GETLK64) && (F_GETLK != F_GETLK64)