All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nakajima Akira <nakajima.akira-o7dWnD6vFTHqq2nvvmkE/A@public.gmane.org>
To: <linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: [PATCH] cifs: When "refer file directly", make new inode cache if file type is different
Date: Wed, 24 Dec 2014 11:14:32 +0900	[thread overview]
Message-ID: <549A2188.5030809@nttcom.co.jp> (raw)

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);
 	}

             reply	other threads:[~2014-12-24  2:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-24  2:14 Nakajima Akira [this message]
     [not found] ` <549A2188.5030809-o7dWnD6vFTHqq2nvvmkE/A@public.gmane.org>
2015-01-04  5:33   ` [PATCH] cifs: When "refer file directly", make new inode cache if file type is different Shirish Pargaonkar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=549A2188.5030809@nttcom.co.jp \
    --to=nakajima.akira-o7dwnd6vfthqq2nvvmke/a@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.