Re: post 2.6.21 regression in F_GETLK



On Thu, 2007-05-10 at 15:38 -0400, J. Bruce Fields wrote:
On Thu, May 10, 2007 at 03:30:50PM -0400, bfields wrote:
On Thu, May 10, 2007 at 02:56:15PM -0400, Doug Chapman wrote:
A recent regression (introduced after 2.6.21) was caught by the LTP test
fcntl11. It appears that F_GETLK is not properly checking for existing
F_RDLCK and allows taking out a write lock.

Ouch.

This can be demonstrated by either running fcntl11 from the LTP suite or
I have hacked up a much shorter version which demonstrates the issue and
am attaching it.

Using git bisect I came up with this commit as the one that introduced
the issue.

Thanks for the report--investigating....

Argh. Looks like a cut-n-paste error. Does this fix it?

--b.

diff --git a/fs/locks.c b/fs/locks.c
index 671a034..909f454 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1632,6 +1632,7 @@ static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl)
flock->l_len = fl->fl_end == OFFSET_MAX ? 0 :
fl->fl_end - fl->fl_start + 1;
flock->l_whence = 0;
+ flock->l_type = fl->fl_type;
return 0;
}


Bruce,

This doesn't fix the problem but it does look like it should be there.
I imagine this would have been the next bug we tripped over once the
original one is fixed.

- Doug


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: post 2.6.21 regression in F_GETLK
    ... fcntl11. ... F_RDLCK and allows taking out a write lock. ... I have hacked up a much shorter version which demonstrates the issue and ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • Re: post 2.6.21 regression in F_GETLK
    ... fcntl11. ... F_RDLCK and allows taking out a write lock. ... I have hacked up a much shorter version which demonstrates the issue and ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • [patch-stable 3/3] pi-futex: Fix exit races and locking problems
    ... My fix works. ... and making all the work in context of process taking lock. ... We are the first waiter - try to look up the real owner and attach ... while (!ret) { ...
    (Linux-Kernel)
  • [patch 05/26] pi-futex: Fix exit races and locking problems
    ... My fix works. ... and making all the work in context of process taking lock. ... We are the first waiter - try to look up the real owner and attach ... while (!ret) { ...
    (Linux-Kernel)
  • Re: [GIT PULL] block/splice bits for 2.6.29
    ... Fix small typo in bio.h's documentation ... This patch is wrong, in fact Vergard has noted this in patch log. ... prefer just unifying the lock ordering. ...
    (Linux-Kernel)