Skip to contentSkip to conversation

nfs:Fix deadlock occurrence issue on error path in the function nfs_vm_page_mkwrite

PATCH Trond Myklebust 1 participant 1 message Aug 24, 2015 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 27 lines · Nicholas Krause

This fixes a possible deadlock occurrence issue on the error path in the function nfs_vm_page_mkwrite for checking if the calls to the functions nfs_flus_incompatible and nfs_updatepage have failed by incorrectly not jumping to the correct goto label out_unlock for unlocking the locked structure page pointer thus causing a deadlock due to not correctly unlocking the internal structure page pointer used by the function nfs_vm_page_mkwrite that had been previously locked with the function lock_page. Further more we also remove the goto label out as no error paths in this function now use this label and this label should be removed to avoid build warnings related to having a undefined label.

---
 fs/nfs/file.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/nfs/file.c +0 -0
index cc4fa1e..fe68ecc 100644
@@ -629,12 +629,11 @@ static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
        ret = VM_FAULT_LOCKED;
        if (nfs_flush_incompatible(filp, page) == 0 &&
            nfs_updatepage(filp, page, 0, pagelen) == 0)

fs/nfs/file.c static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) · line 639

Quoted 10 lines
fs/nfs/file.c +1 -2
-               goto out;
+               goto out_unlock;
 
        ret = VM_FAULT_SIGBUS;
 out_unlock:
        unlock_page(page);
-out:
        return ret;
 }
 

That's the success path that you are modifying, not the error path. Furthermore, the return value is still VM_FAULT_LOCKED, which means the caller expects the page to be returned in the locked state.

So NACK....

Trond