* [PATCH] cifs: When "refer file directly", make new inode cache if file type is different
@ 2014-12-24 2:14 Nakajima Akira
[not found] ` <549A2188.5030809-o7dWnD6vFTHqq2nvvmkE/A@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Nakajima Akira @ 2014-12-24 2:14 UTC (permalink / raw)
To: linux-cifs-u79uwXL29TY76Z2rM5mHXA
This problem is similar as
"Dec/19/2014 [PATCH] cifs: make new inode cache when file type is different"
but we need different patch.
Problem :
When "refer file directly" (e.g. ls <filename>),
in spite of different file type,
if file is same name, old inode cache is used.
This causes that you can not cd directory, can not cat SymbolicLink.
So this patch is that if file type is different, return error.
Reproducible sample :
1. create file 'a' at cifs client.
2. rm 'a' and mkdir 'a' at server.
3. ls 'a' at client, then returned error (ls: cannot open directory).
And you can not cd directory.
SymbolicLink has same problem.
Bug link:
https://bugzilla.kernel.org/show_bug.cgi?id=90031
# cifs_get_inode_info_unix() is for UNIX server.
# cifs_get_inode_info() is for Win server.
Signed-off-by: Nakajima Akira <nakajima.akira-o7dWnD6vFTHqq2nvvmkE/A@public.gmane.org>
diff -uprN -X linux-3.18-vanilla/Documentation/dontdiff linux-3.18-vanilla/fs/cifs/inode.c linux-3.18/fs/cifs/inode.c
--- linux-3.18-vanilla/fs/cifs/inode.c 2014-12-08 07:21:05.000000000 +0900
+++ linux-3.18/fs/cifs/inode.c 2014-12-18 14:20:35.096468862 +0900
@@ -402,9 +402,18 @@ int cifs_get_inode_info_unix(struct inod
rc = -ENOMEM;
} else {
/* we already have inode, update it */
+
+ /* if filetype is different, return error */
+ if (unlikely(((*pinode)->i_mode & S_IFMT) !=
+ (fattr.cf_mode & S_IFMT))) {
+ rc = -ENOENT;
+ goto cgiiu_exit;
+ }
+
cifs_fattr_to_inode(*pinode, &fattr);
}
+cgiiu_exit:
return rc;
}
@@ -837,6 +846,15 @@ cifs_get_inode_info(struct inode **inode
if (!*inode)
rc = -ENOMEM;
} else {
+ /* we already have inode, update it */
+
+ /* if filetype is different, return error */
+ if (unlikely(((*inode)->i_mode & S_IFMT) !=
+ (fattr.cf_mode & S_IFMT))) {
+ rc = -ENOENT;
+ goto cgii_exit;
+ }
+
cifs_fattr_to_inode(*inode, &fattr);
}
^ permalink raw reply [flat|nested] 2+ messages in thread[parent not found: <549A2188.5030809-o7dWnD6vFTHqq2nvvmkE/A@public.gmane.org>]
* Re: [PATCH] cifs: When "refer file directly", make new inode cache if file type is different [not found] ` <549A2188.5030809-o7dWnD6vFTHqq2nvvmkE/A@public.gmane.org> @ 2015-01-04 5:33 ` Shirish Pargaonkar 0 siblings, 0 replies; 2+ messages in thread From: Shirish Pargaonkar @ 2015-01-04 5:33 UTC (permalink / raw) To: Nakajima Akira; +Cc: linux-cifs Looks correct. Reviewed-by: Shirish Pargaonkar <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> On Tue, Dec 23, 2014 at 8:14 PM, Nakajima Akira <nakajima.akira-o7dWnD6vFTHqq2nvvmkE/A@public.gmane.org> wrote: > This problem is similar as > "Dec/19/2014 [PATCH] cifs: make new inode cache when file type is different" > but we need different patch. > > > Problem : > When "refer file directly" (e.g. ls <filename>), > in spite of different file type, > if file is same name, old inode cache is used. > This causes that you can not cd directory, can not cat SymbolicLink. > So this patch is that if file type is different, return error. > > > Reproducible sample : > 1. create file 'a' at cifs client. > 2. rm 'a' and mkdir 'a' at server. > 3. ls 'a' at client, then returned error (ls: cannot open directory). > And you can not cd directory. > > SymbolicLink has same problem. > > Bug link: > https://bugzilla.kernel.org/show_bug.cgi?id=90031 > > # cifs_get_inode_info_unix() is for UNIX server. > # cifs_get_inode_info() is for Win server. > > > > > Signed-off-by: Nakajima Akira <nakajima.akira-o7dWnD6vFTHqq2nvvmkE/A@public.gmane.org> > diff -uprN -X linux-3.18-vanilla/Documentation/dontdiff linux-3.18-vanilla/fs/cifs/inode.c linux-3.18/fs/cifs/inode.c > --- linux-3.18-vanilla/fs/cifs/inode.c 2014-12-08 07:21:05.000000000 +0900 > +++ linux-3.18/fs/cifs/inode.c 2014-12-18 14:20:35.096468862 +0900 > @@ -402,9 +402,18 @@ int cifs_get_inode_info_unix(struct inod > rc = -ENOMEM; > } else { > /* we already have inode, update it */ > + > + /* if filetype is different, return error */ > + if (unlikely(((*pinode)->i_mode & S_IFMT) != > + (fattr.cf_mode & S_IFMT))) { > + rc = -ENOENT; > + goto cgiiu_exit; > + } > + > cifs_fattr_to_inode(*pinode, &fattr); > } > > +cgiiu_exit: > return rc; > } > > @@ -837,6 +846,15 @@ cifs_get_inode_info(struct inode **inode > if (!*inode) > rc = -ENOMEM; > } else { > + /* we already have inode, update it */ > + > + /* if filetype is different, return error */ > + if (unlikely(((*inode)->i_mode & S_IFMT) != > + (fattr.cf_mode & S_IFMT))) { > + rc = -ENOENT; > + goto cgii_exit; > + } > + > cifs_fattr_to_inode(*inode, &fattr); > } > -- > To unsubscribe from this list: send the line "unsubscribe linux-cifs" in > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-01-04 5:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-24 2:14 [PATCH] cifs: When "refer file directly", make new inode cache if file type is different Nakajima Akira
[not found] ` <549A2188.5030809-o7dWnD6vFTHqq2nvvmkE/A@public.gmane.org>
2015-01-04 5:33 ` Shirish Pargaonkar
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.