From 36d5d64dcecbec1dfcdcf7b4b57d1917c18a7e6f Mon Sep 17 00:00:00 2001 From: Gordon Ross Date: Sun, 16 Jan 2022 20:36:44 -0500 Subject: 15156 WPTS FSA FileInfo_Query_FileModeInformation Reviewed by: Garrett D'Amore Reviewed by: Andy Stormont Reviewed by: Matt Barden Approved by: Patrick Mooney --- usr/src/uts/common/fs/smbsrv/smb2_qinfo_file.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/usr/src/uts/common/fs/smbsrv/smb2_qinfo_file.c b/usr/src/uts/common/fs/smbsrv/smb2_qinfo_file.c index dcfd771baa..6f70a8d74b 100644 --- a/usr/src/uts/common/fs/smbsrv/smb2_qinfo_file.c +++ b/usr/src/uts/common/fs/smbsrv/smb2_qinfo_file.c @@ -482,17 +482,35 @@ smb2_qif_position(smb_request_t *sr, smb_queryinfo_t *qi) /* * FileModeInformation [MS-FSA 2.4.24] - * XXX: These mode flags are supposed to be on the open handle, - * XXX: or I think so. Not yet... (just put zero for now) */ static uint32_t smb2_qif_mode(smb_request_t *sr, smb_queryinfo_t *qi) { _NOTE(ARGUNUSED(qi)) + smb_ofile_t *of = sr->fid_ofile; + uint32_t mode; int rc; + /* + * See MS-FSA description of Open.Mode + * For now, we have these in... + */ + mode = of->f_create_options & + (FILE_WRITE_THROUGH | FILE_SEQUENTIAL_ONLY | + FILE_NO_INTERMEDIATE_BUFFERING | FILE_DELETE_ON_CLOSE); + + /* + * The ofile level DoC flag is currently in of->f_flags + * (SMB_OFLAGS_SET_DELETE_ON_CLOSE) though probably it + * should be in f_create_options (and perhaps rename + * that field to f_mode or something closer to the + * Open.Mode terminology used in MS-FSA). + */ + if (of->f_flags & SMB_OFLAGS_SET_DELETE_ON_CLOSE) + mode |= FILE_DELETE_ON_CLOSE; + rc = smb_mbc_encodef( - &sr->raw_data, "l", 0); + &sr->raw_data, "l", mode); if (rc != 0) return (NT_STATUS_BUFFER_OVERFLOW); -- cgit v1.2.3 From 6e7e68d69a0c906a89a14afbb5663a30d0f202f0 Mon Sep 17 00:00:00 2001 From: Gordon Ross Date: Sun, 16 Jan 2022 20:48:40 -0500 Subject: 15157 WPTS FSA FileInfo_Query_FilePositionInformation Reviewed by: Joyce McIntosh Reviewed by: Andy Stormont Reviewed by: Matt Barden Approved by: Patrick Mooney --- usr/src/uts/common/fs/smbsrv/smb2_setinfo_file.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr/src/uts/common/fs/smbsrv/smb2_setinfo_file.c b/usr/src/uts/common/fs/smbsrv/smb2_setinfo_file.c index bbb9f2877b..28b1177158 100644 --- a/usr/src/uts/common/fs/smbsrv/smb2_setinfo_file.c +++ b/usr/src/uts/common/fs/smbsrv/smb2_setinfo_file.c @@ -11,6 +11,7 @@ /* * Copyright 2019 Nexenta by DDN, Inc. All rights reserved. + * Copyright 2022 RackTop Systems, Inc. */ /* @@ -179,7 +180,7 @@ smb2_setf_seek(smb_request_t *sr, smb_setinfo_t *si) uint64_t newoff; if (smb_mbc_decodef(&si->si_data, "q", &newoff) != 0) - return (NT_STATUS_INVALID_PARAMETER); + return (NT_STATUS_INFO_LENGTH_MISMATCH); ASSERT(of->f_magic == SMB_OFILE_MAGIC); mutex_enter(&of->f_mutex); @@ -214,7 +215,7 @@ smb2_setf_mode(smb_request_t *sr, smb_setinfo_t *si) uint32_t Mode; if (smb_mbc_decodef(&si->si_data, "l", &Mode) != 0) - return (NT_STATUS_INVALID_PARAMETER); + return (NT_STATUS_INFO_LENGTH_MISMATCH); #if 0 /* XXX - todo */ if (Mode & FILE_WRITE_THROUGH) { -- cgit v1.2.3 From 0cab3dcd1eb7944361370218fd81d56d85907ed1 Mon Sep 17 00:00:00 2001 From: Gordon Ross Date: Sun, 16 Jan 2022 21:09:18 -0500 Subject: 15158 WPTS FSA FileInfo_Set_FileBasicInformation_Dir_Negative Reviewed by: Joyce McIntosh Reviewed by: Andy Stormont Reviewed by: Matt Barden Approved by: Patrick Mooney --- usr/src/uts/common/fs/smbsrv/smb_cmn_setfile.c | 17 ++++++++++++++--- usr/src/uts/common/fs/smbsrv/smb_common_open.c | 7 +++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/usr/src/uts/common/fs/smbsrv/smb_cmn_setfile.c b/usr/src/uts/common/fs/smbsrv/smb_cmn_setfile.c index 304eb93a39..1b9ed07060 100644 --- a/usr/src/uts/common/fs/smbsrv/smb_cmn_setfile.c +++ b/usr/src/uts/common/fs/smbsrv/smb_cmn_setfile.c @@ -21,6 +21,7 @@ /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2020 Tintri by DDN, Inc. All rights reserved. + * Copyright 2022 RackTop Systems, Inc. */ /* @@ -62,9 +63,19 @@ smb_set_basic_info(smb_request_t *sr, smb_setinfo_t *si) &crtime, &atime, &mtime, &ctime, &attributes) != 0) return (NT_STATUS_INFO_LENGTH_MISMATCH); - if ((attributes & FILE_ATTRIBUTE_DIRECTORY) && - (!smb_node_is_dir(node))) - return (NT_STATUS_INVALID_PARAMETER); + /* + * MS-FSA 2.1.5.14.2 FileBasicInformation + * Return STATUS_INVALID_PARAMETER if: + * FILE_ATTRIBUTE_TEMPORARY on a directory, + * FILE_ATTRIBUTE_DIRECTORY on a non-directory. + */ + if (smb_node_is_dir(node)) { + if ((attributes & FILE_ATTRIBUTE_TEMPORARY) != 0) + return (NT_STATUS_INVALID_PARAMETER); + } else { + if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) + return (NT_STATUS_INVALID_PARAMETER); + } bzero(attr, sizeof (*attr)); if (atime != 0 && atime != (uint64_t)-1) { diff --git a/usr/src/uts/common/fs/smbsrv/smb_common_open.c b/usr/src/uts/common/fs/smbsrv/smb_common_open.c index 2fe367e4c3..cf8ed57a8d 100644 --- a/usr/src/uts/common/fs/smbsrv/smb_common_open.c +++ b/usr/src/uts/common/fs/smbsrv/smb_common_open.c @@ -22,6 +22,7 @@ /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2020 Tintri by DDN, Inc. All rights reserved. + * Copyright 2022 RackTop Systems, Inc. */ /* @@ -938,6 +939,12 @@ create: goto errout; } + if (is_dir != 0 && + (op->dattr & FILE_ATTRIBUTE_TEMPORARY) != 0) { + status = NT_STATUS_INVALID_PARAMETER; + goto errout; + } + if ((op->desired_access & ACCESS_SYSTEM_SECURITY) != 0 && !smb_user_has_security_priv(sr->uid_user, sr->user_cr)) { status = NT_STATUS_ACCESS_DENIED; -- cgit v1.2.3