Skip to contentSkip to conversation

cifs: Fix check for regular file in couldbe_mf_symlink()

PATCH Applied Sachin Prabhu 3 participants 3 messages Jan 31, 2014 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: Fix check for regular file in couldbe_mf_symlink()

MF Symlinks are regular files containing content in a specified format.

The function couldbe_mf_symlink() checks the mode for a set S_IFREG bit as a test to confirm that it is a regular file. This bit is also set for other filetypes and simply checking for this bit being set may return false positives.

We ensure that we are actually checking for a regular file by using the S_ISREG macro to test instead.

---
 fs/cifs/link.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/link.c +1 -1
index 52f41f9..264ece7 100644
@@ -185,7 +185,7 @@ format_mf_symlink(u8 *buf, unsigned int buf_len, const char *link_str)
 bool
 couldbe_mf_symlink(const struct cifs_fattr *fattr)
 {
-	if (!(fattr->cf_mode & S_IFREG))
+	if (!S_ISREG(fattr->cf_mode))
 		/* it's not a symlink */
 		return false;
 
Signature · 1 line
1.8.4.2

A message that is not in the archive (sent off-list or not yet received): 1391178436-10069-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

Reviewed-by
#2 lore raw
Quoted 22 lines · On Fri, 31 Jan 2014 14:27:16 +0000 Sachin Prabhu…

MF Symlinks are regular files containing content in a specified format.

The function couldbe_mf_symlink() checks the mode for a set S_IFREG bit as a test to confirm that it is a regular file. This bit is also set for other filetypes and simply checking for this bit being set may return false positives.

We ensure that we are actually checking for a regular file by using the S_ISREG macro to test instead.

---
 fs/cifs/link.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/link.c +0 -0
index 52f41f9..264ece7 100644

fs/cifs/link.c format_mf_symlink(u8 *buf, unsigned int buf_len, const char *link_str) · line 191

Quoted 8 lines
fs/cifs/link.c +1 -1
@@ -185,7 +185,7 @@ format_mf_symlink(u8 *buf, unsigned int buf_len, const char *link_str)
 bool
 couldbe_mf_symlink(const struct cifs_fattr *fattr)
 {
-	if (!(fattr->cf_mode & S_IFREG))
+	if (!S_ISREG(fattr->cf_mode))
 		/* it's not a symlink */
 		return false;
 

Looks correct.

A message that is not in the archive (sent off-list or not yet received): 20140131093250.3f26fa59-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org

Applied
#4 lore raw

merged into cifs-2.6.git for-next

Quoted 37 lines · Jeff Layton
Quoted 22 lines · On Fri, 31 Jan 2014 14:27:16 +0000 Sachin Prabhu…

MF Symlinks are regular files containing content in a specified format.

The function couldbe_mf_symlink() checks the mode for a set S_IFREG bit as a test to confirm that it is a regular file. This bit is also set for other filetypes and simply checking for this bit being set may return false positives.

We ensure that we are actually checking for a regular file by using the S_ISREG macro to test instead.

---
 fs/cifs/link.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/link.c +0 -0
index 52f41f9..264ece7 100644

fs/cifs/link.c format_mf_symlink(u8 *buf, unsigned int buf_len, const char *link_str) · line 191

Quoted 8 lines
fs/cifs/link.c +1 -1
@@ -185,7 +185,7 @@ format_mf_symlink(u8 *buf, unsigned int buf_len, const char *link_str)
 bool
 couldbe_mf_symlink(const struct cifs_fattr *fattr)
 {
-     if (!(fattr->cf_mode & S_IFREG))
+     if (!S_ISREG(fattr->cf_mode))
              /* it's not a symlink */
              return false;
 

Looks correct.

Signature · 3 lines
Thanks,

Steve