cifs: Fix check for regular file in couldbe_mf_symlink()
Subsystems (2)
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
@@ -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
Jeff Layton
Reviewed-byQuoted 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 setS_IFREGbit 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_ISREGmacro to test instead.Signed-off-by Sachin Prabhu <[email protected]>Reported-by Neil Brown <[email protected]>Reported-by Dan Carpenter <[email protected]>--- fs/cifs/link.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/cifs/link.c +0
-0
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
Steve French
Appliedmerged 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 setS_IFREGbit 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_ISREGmacro to test instead.Signed-off-by Sachin Prabhu <[email protected]>Reported-by Neil Brown <[email protected]>Reported-by Dan Carpenter <[email protected]>--- fs/cifs/link.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/cifs/link.c +0
-0fs/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.
Reviewed-by Jeff Layton <[email protected]>
Signature · 3 lines
Thanks, Steve