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>
This commit is contained in:
parent
7f427d3a60
commit
1f1735cb75
@ -271,7 +271,7 @@ struct cifsFileInfo *
|
|||||||
cifs_new_fileinfo(struct cifs_fid *fid, struct file *file,
|
cifs_new_fileinfo(struct cifs_fid *fid, struct file *file,
|
||||||
struct tcon_link *tlink, __u32 oplock)
|
struct tcon_link *tlink, __u32 oplock)
|
||||||
{
|
{
|
||||||
struct dentry *dentry = file->f_path.dentry;
|
struct dentry *dentry = file_dentry(file);
|
||||||
struct inode *inode = d_inode(dentry);
|
struct inode *inode = d_inode(dentry);
|
||||||
struct cifsInodeInfo *cinode = CIFS_I(inode);
|
struct cifsInodeInfo *cinode = CIFS_I(inode);
|
||||||
struct cifsFileInfo *cfile;
|
struct cifsFileInfo *cfile;
|
||||||
@ -461,7 +461,7 @@ int cifs_open(struct inode *inode, struct file *file)
|
|||||||
tcon = tlink_tcon(tlink);
|
tcon = tlink_tcon(tlink);
|
||||||
server = tcon->ses->server;
|
server = tcon->ses->server;
|
||||||
|
|
||||||
full_path = build_path_from_dentry(file->f_path.dentry);
|
full_path = build_path_from_dentry(file_dentry(file));
|
||||||
if (full_path == NULL) {
|
if (full_path == NULL) {
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -303,7 +303,7 @@ initiate_cifs_search(const unsigned int xid, struct file *file)
|
|||||||
cifsFile->invalidHandle = true;
|
cifsFile->invalidHandle = true;
|
||||||
cifsFile->srch_inf.endOfSearch = false;
|
cifsFile->srch_inf.endOfSearch = false;
|
||||||
|
|
||||||
full_path = build_path_from_dentry(file->f_path.dentry);
|
full_path = build_path_from_dentry(file_dentry(file));
|
||||||
if (full_path == NULL) {
|
if (full_path == NULL) {
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
@ -762,7 +762,7 @@ static int cifs_filldir(char *find_entry, struct file *file,
|
|||||||
*/
|
*/
|
||||||
fattr.cf_flags |= CIFS_FATTR_NEED_REVAL;
|
fattr.cf_flags |= CIFS_FATTR_NEED_REVAL;
|
||||||
|
|
||||||
cifs_prime_dcache(file->f_path.dentry, &name, &fattr);
|
cifs_prime_dcache(file_dentry(file), &name, &fattr);
|
||||||
|
|
||||||
ino = cifs_uniqueid_to_ino_t(fattr.cf_uniqueid);
|
ino = cifs_uniqueid_to_ino_t(fattr.cf_uniqueid);
|
||||||
return !dir_emit(ctx, name.name, name.len, ino, fattr.cf_dtype);
|
return !dir_emit(ctx, name.name, name.len, ino, fattr.cf_dtype);
|
||||||
|
Loading…
Reference in New Issue
Block a user