mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 06:10:53 +07:00
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>
This commit is contained in:
parent
79835a710d
commit
f3c7691e8d
@ -2035,10 +2035,7 @@ static int may_open(struct path *path, int acc_mode, int flag)
|
|||||||
if (flag & O_NOATIME && !inode_owner_or_capable(inode))
|
if (flag & O_NOATIME && !inode_owner_or_capable(inode))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
/*
|
return 0;
|
||||||
* Ensure there are no outstanding leases on the file.
|
|
||||||
*/
|
|
||||||
return break_lease(inode, flag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handle_truncate(struct file *filp)
|
static int handle_truncate(struct file *filp)
|
||||||
|
@ -685,6 +685,10 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
|
|||||||
if (error)
|
if (error)
|
||||||
goto cleanup_all;
|
goto cleanup_all;
|
||||||
|
|
||||||
|
error = break_lease(inode, f->f_flags);
|
||||||
|
if (error)
|
||||||
|
goto cleanup_all;
|
||||||
|
|
||||||
if (!open && f->f_op)
|
if (!open && f->f_op)
|
||||||
open = f->f_op->open;
|
open = f->f_op->open;
|
||||||
if (open) {
|
if (open) {
|
||||||
|
Loading…
Reference in New Issue
Block a user