cifs: Replace wrtPending with a real reference count
Currently, cifs_close() tries to wait until all I/O is complete and then frees the file private data. If I/O does not completely in a reasonable amount of time it frees the structure anyway, leaving a potential use- after-free situation. This patch changes the wrtPending counter to a complete reference count and lets the last user free the structure. Signed-off-by: Dave Kleikamp <shaggy@linux.vnet.ibm.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> Tested-by: Shirish Pargaonkar <shirishp@us.ibm.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
This commit is contained in:

committed by
Steve French

parent
1b49c55661
commit
6ab409b53d
@@ -800,7 +800,7 @@ set_via_filehandle:
|
||||
if (open_file == NULL)
|
||||
CIFSSMBClose(xid, pTcon, netfid);
|
||||
else
|
||||
atomic_dec(&open_file->wrtPending);
|
||||
cifsFileInfo_put(open_file);
|
||||
out:
|
||||
return rc;
|
||||
}
|
||||
@@ -1635,7 +1635,7 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,
|
||||
__u32 npid = open_file->pid;
|
||||
rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, nfid,
|
||||
npid, false);
|
||||
atomic_dec(&open_file->wrtPending);
|
||||
cifsFileInfo_put(open_file);
|
||||
cFYI(1, ("SetFSize for attrs rc = %d", rc));
|
||||
if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
|
||||
unsigned int bytes_written;
|
||||
@@ -1790,7 +1790,7 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
|
||||
u16 nfid = open_file->netfid;
|
||||
u32 npid = open_file->pid;
|
||||
rc = CIFSSMBUnixSetFileInfo(xid, pTcon, args, nfid, npid);
|
||||
atomic_dec(&open_file->wrtPending);
|
||||
cifsFileInfo_put(open_file);
|
||||
} else {
|
||||
rc = CIFSSMBUnixSetPathInfo(xid, pTcon, full_path, args,
|
||||
cifs_sb->local_nls,
|
||||
|
Reference in New Issue
Block a user