On Sun, 20 May 2012 23:24:39 -0500
shirishpargaon...@gmail.com wrote:

> From: Shirish Pargaonkar <shirishpargaon...@gmail.com>
> 
> While traversing the linked list of open file handles, if the identfied
> file handle is invalid, a reopen is attempted and if it fails, we
> resume traversing where we stopped and cifs can oops while accessing
> invalid next element, for list might have changed.
> 
> So mark the invalid file handle and attempt reopen if no
> valid file handle is found in rest of the list.
> If reopen fails, move the invalid file handle to the end of the list
> and start traversing the list again from the begining.
> Repeat this four times before giving up and returning an error if
> file reopen keeps failing.
> 
> Cc: <sta...@vger.kernel.org>
> Signed-off-by: Shirish Pargaonkar <shirishpargaon...@gmail.com>
> 
> ---
>  fs/cifs/cifsglob.h |    1 +
>  fs/cifs/file.c     |   55 +++++++++++++++++++++++++++++----------------------
>  2 files changed, 32 insertions(+), 24 deletions(-)
> 

[...]

> +
> +     if (inv_file) {
> +             rc = cifs_reopen_file(inv_file, false);
> +             if (!rc)
> +                     return inv_file;
> +             else {
> +                     list_move_tail(&inv_file->flist,
> +                                     &cifs_inode->openFileList);


You're modifying this list w/o holding the spinlock. You need to do
this while holding the spinlock.

> +                     cifsFileInfo_put(inv_file);
> +                     spin_lock(&cifs_file_list_lock);
> +                     ++refind;
> +                     goto refind_writable;
> +             }
> +     }
> +
>       return NULL;
>  }
>  


-- 
Jeff Layton <jlay...@redhat.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to