Skip to contentSkip to conversation

cifs: fix NULL dereference in match_prepath

PATCH Applied Ronnie Sahlberg 2 participants 2 messages Jan 22, 2020

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

PATCH 1/1 cifs: fix NULL dereference in match_prepath

RHBZ: 1760879

Fix an oops in match_prepath() by making sure that the prepath string is not NULL before we pass it into strcmp().

This is similar to other checks we make for example in cifs_root_iget()

---
 fs/cifs/connect.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
fs/cifs/connect.c +4 -2
index 05ea0e2b7e0e..0aa3623ae0e1 100644
@@ -3709,8 +3709,10 @@ match_prepath(struct super_block *sb, struct cifs_mnt_data *mnt_data)
 {
 	struct cifs_sb_info *old = CIFS_SB(sb);
 	struct cifs_sb_info *new = mnt_data->cifs_sb;
-	bool old_set = old->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH;
-	bool new_set = new->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH;
+	bool old_set = (old->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) &&
+		old->prepath;
+	bool new_set = (new->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) &&
+		new->prepath;
 
 	if (old_set && new_set && !strcmp(new->prepath, old->prepath))
 		return 1;
Signature · 1 line
2.13.6
Applied
#1 lore raw

merged into cifs-2.6.git for-next

Quoted 33 lines · Ronnie Sahlberg

RHBZ: 1760879

Fix an oops in match_prepath() by making sure that the prepath string is not NULL before we pass it into strcmp().

This is similar to other checks we make for example in cifs_root_iget()

---
 fs/cifs/connect.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
fs/cifs/connect.c +4 -3
index 05ea0e2b7e0e..0aa3623ae0e1 100644
@@ -3709,8 +3709,10 @@ match_prepath(struct super_block *sb, struct cifs_mnt_data *mnt_data)
 {
        struct cifs_sb_info *old = CIFS_SB(sb);
        struct cifs_sb_info *new = mnt_data->cifs_sb;
-       bool old_set = old->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH;
-       bool new_set = new->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH;
+       bool old_set = (old->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) &&
+               old->prepath;
+       bool new_set = (new->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) &&
+               new->prepath;
 
        if (old_set && new_set && !strcmp(new->prepath, old->prepath))
                return 1;
--

2.13.6

Signature · 3 lines
Thanks,

Steve