Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=9700382c3c9ff3e673e587084d76eedb3ba88668
Commit:     9700382c3c9ff3e673e587084d76eedb3ba88668
Parent:     937472b00b666ecbf1464502f857ec63b024af72
Author:     david m. richter <[EMAIL PROTECTED]>
AuthorDate: Tue Jul 31 00:39:12 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Tue Jul 31 15:39:42 2007 -0700

    VFS: fix a race in lease-breaking during truncate
    
    It is possible that another process could acquire a new file lease right
    after break_lease() is called during a truncate, but before lease-granting
    is disabled by the subsequent get_write_access().  Merely switching the
    order of the break_lease() and get_write_access() calls prevents this race.
    
    Signed-off-by: David M. Richter <[EMAIL PROTECTED]>
    Signed-off-by: "J. Bruce Fields" <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 fs/open.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/fs/open.c b/fs/open.c
index e27c205..1d9e5e9 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -256,24 +256,26 @@ static long do_sys_truncate(const char __user * path, 
loff_t length)
        if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
                goto dput_and_out;
 
-       /*
-        * Make sure that there are no leases.
-        */
-       error = break_lease(inode, FMODE_WRITE);
+       error = get_write_access(inode);
        if (error)
                goto dput_and_out;
 
-       error = get_write_access(inode);
+       /*
+        * Make sure that there are no leases.  get_write_access() protects
+        * against the truncate racing with a lease-granting setlease().
+        */
+       error = break_lease(inode, FMODE_WRITE);
        if (error)
-               goto dput_and_out;
+               goto put_write_and_out;
 
        error = locks_verify_truncate(inode, NULL, length);
        if (!error) {
                DQUOT_INIT(inode);
                error = do_truncate(nd.dentry, length, 0, NULL);
        }
-       put_write_access(inode);
 
+put_write_and_out:
+       put_write_access(inode);
 dput_and_out:
        path_release(&nd);
 out:
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to