Commit 619a67aa authored by Andries E. Brouwer's avatar Andries E. Brouwer Committed by Linus Torvalds

[PATCH] fcntl fix

Today we return EINVAL for fcntl with a lock with negative length.
POSIX-2001 says that the lock covers start .. start+len-1 if len >= 0
and start+len .. start-1 if len < 0.
parent 3eebeb8e
......@@ -297,11 +297,20 @@ static int flock_to_posix_lock(struct file *filp, struct file_lock *fl,
return -EINVAL;
}
if (((start += l->l_start) < 0) || (l->l_len < 0))
return -EINVAL;
/* POSIX-1996 leaves the case l->l_len < 0 undefined;
POSIX-2001 defines it. */
start += l->l_start;
end = start + l->l_len - 1;
if (l->l_len < 0) {
end = start - 1;
start += l->l_len;
}
if (start < 0)
return -EINVAL;
if (l->l_len > 0 && end < 0)
return -EOVERFLOW;
fl->fl_start = start; /* we record the absolute position */
fl->fl_end = end;
if (l->l_len == 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment