aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGoldwyn Rodrigues <rgoldwyn@suse.com>2016-04-18 07:41:52 -0400
committerSteve French <smfrench@gmail.com>2016-05-17 15:09:33 -0400
commit1f1735cb75ab31ed948a7fce65beaaa6c0ed4ed4 (patch)
tree35d88237f7ab55df1bf394d5c214185c2be03bd0
parent7f427d3a6029331304f91ef4d7cf646f054216d2 (diff)
cifs: Use file_dentry()
CIFS may be used as lower layer of overlayfs and accessing f_path.dentry can lead to a crash. Fix by replacing direct access of file->f_path.dentry with the file_dentry() accessor, which will always return a native object. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Acked-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com> Signed-off-by: Steve French <smfrench@gmail.com>
-rw-r--r--fs/cifs/file.c4
-rw-r--r--fs/cifs/readdir.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index c03d0744648b..489ddc797105 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -271,7 +271,7 @@ struct cifsFileInfo *
271cifs_new_fileinfo(struct cifs_fid *fid, struct file *file, 271cifs_new_fileinfo(struct cifs_fid *fid, struct file *file,
272 struct tcon_link *tlink, __u32 oplock) 272 struct tcon_link *tlink, __u32 oplock)
273{ 273{
274 struct dentry *dentry = file->f_path.dentry; 274 struct dentry *dentry = file_dentry(file);
275 struct inode *inode = d_inode(dentry); 275 struct inode *inode = d_inode(dentry);
276 struct cifsInodeInfo *cinode = CIFS_I(inode); 276 struct cifsInodeInfo *cinode = CIFS_I(inode);
277 struct cifsFileInfo *cfile; 277 struct cifsFileInfo *cfile;
@@ -461,7 +461,7 @@ int cifs_open(struct inode *inode, struct file *file)
461 tcon = tlink_tcon(tlink); 461 tcon = tlink_tcon(tlink);
462 server = tcon->ses->server; 462 server = tcon->ses->server;
463 463
464 full_path = build_path_from_dentry(file->f_path.dentry); 464 full_path = build_path_from_dentry(file_dentry(file));
465 if (full_path == NULL) { 465 if (full_path == NULL) {
466 rc = -ENOMEM; 466 rc = -ENOMEM;
467 goto out; 467 goto out;
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 867439c21001..65cf85dcda09 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -303,7 +303,7 @@ initiate_cifs_search(const unsigned int xid, struct file *file)
303 cifsFile->invalidHandle = true; 303 cifsFile->invalidHandle = true;
304 cifsFile->srch_inf.endOfSearch = false; 304 cifsFile->srch_inf.endOfSearch = false;
305 305
306 full_path = build_path_from_dentry(file->f_path.dentry); 306 full_path = build_path_from_dentry(file_dentry(file));
307 if (full_path == NULL) { 307 if (full_path == NULL) {
308 rc = -ENOMEM; 308 rc = -ENOMEM;
309 goto error_exit; 309 goto error_exit;
@@ -762,7 +762,7 @@ static int cifs_filldir(char *find_entry, struct file *file,
762 */ 762 */
763 fattr.cf_flags |= CIFS_FATTR_NEED_REVAL; 763 fattr.cf_flags |= CIFS_FATTR_NEED_REVAL;
764 764
765 cifs_prime_dcache(file->f_path.dentry, &name, &fattr); 765 cifs_prime_dcache(file_dentry(file), &name, &fattr);
766 766
767 ino = cifs_uniqueid_to_ino_t(fattr.cf_uniqueid); 767 ino = cifs_uniqueid_to_ino_t(fattr.cf_uniqueid);
768 return !dir_emit(ctx, name.name, name.len, ino, fattr.cf_dtype); 768 return !dir_emit(ctx, name.name, name.len, ino, fattr.cf_dtype);