Skip to content

Commit 8ddecf5

Browse files
aaptelSteve French
authored andcommitted
CIFS: Fix NULL ptr deref
cifs->master_tlink is NULL against Win Server 2016 (which is strange.. not sure why) and is dereferenced in cifs_sb_master_tcon(). move master_tlink getter to cifsglob.h so it can be used from smb2misc.c Signed-off-by: Aurelien Aptel <[email protected]> Reviewed-by: Ronnie Sahlberg <[email protected]> Signed-off-by: Steve French <[email protected]> Acked-by: Pavel Shilovsky <[email protected]>
1 parent 83210ba commit 8ddecf5

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

fs/cifs/cifsglob.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,12 @@ tlink_tcon(struct tcon_link *tlink)
10191019
return tlink->tl_tcon;
10201020
}
10211021

1022+
static inline struct tcon_link *
1023+
cifs_sb_master_tlink(struct cifs_sb_info *cifs_sb)
1024+
{
1025+
return cifs_sb->master_tlink;
1026+
}
1027+
10221028
extern void cifs_put_tlink(struct tcon_link *tlink);
10231029

10241030
static inline struct tcon_link *

fs/cifs/connect.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3116,12 +3116,6 @@ cifs_put_tlink(struct tcon_link *tlink)
31163116
return;
31173117
}
31183118

3119-
static inline struct tcon_link *
3120-
cifs_sb_master_tlink(struct cifs_sb_info *cifs_sb)
3121-
{
3122-
return cifs_sb->master_tlink;
3123-
}
3124-
31253119
static int
31263120
compare_mount_options(struct super_block *sb, struct cifs_mnt_data *mnt_data)
31273121
{

fs/cifs/smb2misc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,10 @@ cifs_convert_path_to_utf16(const char *from, struct cifs_sb_info *cifs_sb)
453453
start_of_path = from + 1;
454454
#ifdef CONFIG_CIFS_SMB311
455455
/* SMB311 POSIX extensions paths do not include leading slash */
456-
else if (cifs_sb_master_tcon(cifs_sb)->posix_extensions)
456+
else if (cifs_sb_master_tlink(cifs_sb) &&
457+
cifs_sb_master_tcon(cifs_sb)->posix_extensions) {
457458
start_of_path = from + 1;
459+
}
458460
#endif /* 311 */
459461
else
460462
start_of_path = from;

0 commit comments

Comments
 (0)