Commit ff694527 authored by Steve French's avatar Steve French

[CIFS] Make cifs_unlink consistent in checks for null inode

Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent ff54250a
Version 1.58
------------
Guard against buffer overruns in various UCS-2 to UTF-8 string conversions
when the UTF-8 string is composed of unusually long (more than 4 byte) converted
characters.
Version 1.57 Version 1.57
------------ ------------
Improve support for multiple security contexts to the same server. We Improve support for multiple security contexts to the same server. We
......
...@@ -100,5 +100,5 @@ extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg); ...@@ -100,5 +100,5 @@ extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
extern const struct export_operations cifs_export_ops; extern const struct export_operations cifs_export_ops;
#endif /* EXPERIMENTAL */ #endif /* EXPERIMENTAL */
#define CIFS_VERSION "1.57" #define CIFS_VERSION "1.58"
#endif /* _CIFSFS_H */ #endif /* _CIFSFS_H */
...@@ -962,13 +962,21 @@ cifs_rename_pending_delete(char *full_path, struct dentry *dentry, int xid) ...@@ -962,13 +962,21 @@ cifs_rename_pending_delete(char *full_path, struct dentry *dentry, int xid)
goto out_close; goto out_close;
} }
/*
* If dentry->d_inode is null (usually meaning the cached dentry
* is a negative dentry) then we would attempt a standard SMB delete, but
* if that fails we can not attempt the fall back mechanisms on EACESS
* but will return the EACESS to the caller. Note that the VFS does not call
* unlink on negative dentries currently.
*/
int cifs_unlink(struct inode *dir, struct dentry *dentry) int cifs_unlink(struct inode *dir, struct dentry *dentry)
{ {
int rc = 0; int rc = 0;
int xid; int xid;
char *full_path = NULL; char *full_path = NULL;
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
struct cifsInodeInfo *cifsInode = CIFS_I(inode); struct cifsInodeInfo *cifs_inode;
struct super_block *sb = dir->i_sb; struct super_block *sb = dir->i_sb;
struct cifs_sb_info *cifs_sb = CIFS_SB(sb); struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
struct cifsTconInfo *tcon = cifs_sb->tcon; struct cifsTconInfo *tcon = cifs_sb->tcon;
...@@ -1012,7 +1020,7 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -1012,7 +1020,7 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
rc = cifs_rename_pending_delete(full_path, dentry, xid); rc = cifs_rename_pending_delete(full_path, dentry, xid);
if (rc == 0) if (rc == 0)
drop_nlink(inode); drop_nlink(inode);
} else if (rc == -EACCES && dosattr == 0) { } else if ((rc == -EACCES) && (dosattr == 0) && inode) {
attrs = kzalloc(sizeof(*attrs), GFP_KERNEL); attrs = kzalloc(sizeof(*attrs), GFP_KERNEL);
if (attrs == NULL) { if (attrs == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
...@@ -1020,7 +1028,8 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -1020,7 +1028,8 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
} }
/* try to reset dos attributes */ /* try to reset dos attributes */
origattr = cifsInode->cifsAttrs; cifs_inode = CIFS_I(inode);
origattr = cifs_inode->cifsAttrs;
if (origattr == 0) if (origattr == 0)
origattr |= ATTR_NORMAL; origattr |= ATTR_NORMAL;
dosattr = origattr & ~ATTR_READONLY; dosattr = origattr & ~ATTR_READONLY;
...@@ -1041,13 +1050,13 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -1041,13 +1050,13 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
out_reval: out_reval:
if (inode) { if (inode) {
cifsInode = CIFS_I(inode); cifs_inode = CIFS_I(inode);
cifsInode->time = 0; /* will force revalidate to get info cifs_inode->time = 0; /* will force revalidate to get info
when needed */ when needed */
inode->i_ctime = current_fs_time(sb); inode->i_ctime = current_fs_time(sb);
} }
dir->i_ctime = dir->i_mtime = current_fs_time(sb); dir->i_ctime = dir->i_mtime = current_fs_time(sb);
cifsInode = CIFS_I(dir); cifs_inode = CIFS_I(dir);
CIFS_I(dir)->time = 0; /* force revalidate of dir as well */ CIFS_I(dir)->time = 0; /* force revalidate of dir as well */
kfree(full_path); kfree(full_path);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment