Skip to content

Commit

Permalink
cifsd: don't clear ATTR_DIRECTORY with ATTR_NORMAL + other bits
Browse files Browse the repository at this point in the history
Windows backup client seems to set ATTR_NORMAL + other bits about
directory using smb2_set_info_file. When it clears ATTR_DIRECTORY bit,
directory appears as a file. This patch leave ATTR_DIRECTORY in file
attribute when setting ATTR_NORMAL + other bits.

Reported-by: Marios Makassikis <[email protected]>
Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
namjaejeon committed Mar 11, 2021
1 parent 3e64c91 commit fa423ad
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -5715,13 +5715,14 @@ static int set_file_basic_info(struct ksmbd_file *fp,

if (file_info->Attributes) {
if (!S_ISDIR(inode->i_mode) &&
file_info->Attributes == ATTR_DIRECTORY_LE) {
file_info->Attributes & ATTR_DIRECTORY_LE) {
ksmbd_err("can't change a file to a directory\n");
return -EINVAL;
}

if (!(S_ISDIR(inode->i_mode) && file_info->Attributes == ATTR_NORMAL_LE))
fp->f_ci->m_fattr = file_info->Attributes;
fp->f_ci->m_fattr = file_info->Attributes |
(fp->f_ci->m_fattr & ATTR_DIRECTORY_LE);
}

if (test_share_config_flag(share, KSMBD_SHARE_FLAG_STORE_DOS_ATTRS) &&
Expand Down

0 comments on commit fa423ad

Please sign in to comment.