Skip to content

Commit ef201e8

Browse files
paliSteve French
authored andcommitted
cifs: Validate EAs for WSL reparse points
Major and minor numbers for char and block devices are mandatory for stat. So check that the WSL EA $LXDEV is present for WSL CHR and BLK reparse points. WSL reparse point tag determinate type of the file. But file type is present also in the WSL EA $LXMOD. So check that both file types are same. Fixes: 78e26be ("smb: client: parse uid, gid, mode and dev from WSL reparse points") Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 438e211 commit ef201e8

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

fs/smb/client/reparse.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -747,11 +747,12 @@ int smb2_parse_reparse_point(struct cifs_sb_info *cifs_sb,
747747
return parse_reparse_point(buf, plen, cifs_sb, full_path, true, data);
748748
}
749749

750-
static void wsl_to_fattr(struct cifs_open_info_data *data,
750+
static bool wsl_to_fattr(struct cifs_open_info_data *data,
751751
struct cifs_sb_info *cifs_sb,
752752
u32 tag, struct cifs_fattr *fattr)
753753
{
754754
struct smb2_file_full_ea_info *ea;
755+
bool have_xattr_dev = false;
755756
u32 next = 0;
756757

757758
switch (tag) {
@@ -794,13 +795,24 @@ static void wsl_to_fattr(struct cifs_open_info_data *data,
794795
fattr->cf_uid = wsl_make_kuid(cifs_sb, v);
795796
else if (!strncmp(name, SMB2_WSL_XATTR_GID, nlen))
796797
fattr->cf_gid = wsl_make_kgid(cifs_sb, v);
797-
else if (!strncmp(name, SMB2_WSL_XATTR_MODE, nlen))
798+
else if (!strncmp(name, SMB2_WSL_XATTR_MODE, nlen)) {
799+
/* File type in reparse point tag and in xattr mode must match. */
800+
if (S_DT(fattr->cf_mode) != S_DT(le32_to_cpu(*(__le32 *)v)))
801+
return false;
798802
fattr->cf_mode = (umode_t)le32_to_cpu(*(__le32 *)v);
799-
else if (!strncmp(name, SMB2_WSL_XATTR_DEV, nlen))
803+
} else if (!strncmp(name, SMB2_WSL_XATTR_DEV, nlen)) {
800804
fattr->cf_rdev = reparse_mkdev(v);
805+
have_xattr_dev = true;
806+
}
801807
} while (next);
802808
out:
809+
810+
/* Major and minor numbers for char and block devices are mandatory. */
811+
if (!have_xattr_dev && (tag == IO_REPARSE_TAG_LX_CHR || tag == IO_REPARSE_TAG_LX_BLK))
812+
return false;
813+
803814
fattr->cf_dtype = S_DT(fattr->cf_mode);
815+
return true;
804816
}
805817

806818
static bool posix_reparse_to_fattr(struct cifs_sb_info *cifs_sb,
@@ -874,7 +886,9 @@ bool cifs_reparse_point_to_fattr(struct cifs_sb_info *cifs_sb,
874886
case IO_REPARSE_TAG_AF_UNIX:
875887
case IO_REPARSE_TAG_LX_CHR:
876888
case IO_REPARSE_TAG_LX_BLK:
877-
wsl_to_fattr(data, cifs_sb, tag, fattr);
889+
ok = wsl_to_fattr(data, cifs_sb, tag, fattr);
890+
if (!ok)
891+
return false;
878892
break;
879893
case IO_REPARSE_TAG_NFS:
880894
ok = posix_reparse_to_fattr(cifs_sb, fattr, data);

0 commit comments

Comments
 (0)