diff options
author | J. Bruce Fields <bfields@redhat.com> | 2011-09-21 10:58:13 -0400 |
---|---|---|
committer | root <root@serles.lst.de> | 2011-10-28 08:59:00 -0400 |
commit | f3c7691e8d30d88899b514675c7c86d19057b5fd (patch) | |
tree | 0065bcc05b19a99d8785ce523f992a48fe573e79 /fs/open.c | |
parent | 79835a710d6ff811659c8de46f89c7577c3b8cc6 (diff) |
leases: fix write-open/read-lease race
In setlease, we use i_writecount to decide whether we can give out a
read lease.
In open, we break leases before incrementing i_writecount.
There is therefore a window between the break lease and the i_writecount
increment when setlease could add a new read lease.
This would leave us with a simultaneous write open and read lease, which
shouldn't happen.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/open.c')
-rw-r--r-- | fs/open.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -685,6 +685,10 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt, | |||
685 | if (error) | 685 | if (error) |
686 | goto cleanup_all; | 686 | goto cleanup_all; |
687 | 687 | ||
688 | error = break_lease(inode, f->f_flags); | ||
689 | if (error) | ||
690 | goto cleanup_all; | ||
691 | |||
688 | if (!open && f->f_op) | 692 | if (!open && f->f_op) |
689 | open = f->f_op->open; | 693 | open = f->f_op->open; |
690 | if (open) { | 694 | if (open) { |