Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'v7.1-rc-part1-ksmbd-srv-fixes' of git://git.samba.org/ksmbd

Pull smb server updates from Steve French:

- smbdirect double free fixes

- Add some smbdirect logging

- Minor cleanup in crypto, and smbdirect and in IPC handling

- Minor cleanup to move header info to common FSCC code

- Fix crypt message use after free

- Fix memory leak in session setup

- Fix for DACL parsing

- Fix EA name length validation

- Reconnect fix

- Fix use after free in close

* tag 'v7.1-rc-part1-ksmbd-srv-fixes' of git://git.samba.org/ksmbd:
smb: smbdirect: add some logging to SMBDIRECT_CHECK_STATUS_{WARN,DISCONNECT}()
smb: smbdirect: introduce smbdirect_socket.logging infrastructure
smb: smbdirect: let smbdirect.h include #include <linux/types.h>
smb: server: avoid double-free in smb_direct_free_sendmsg after smb_direct_flush_send_list()
smb: client: avoid double-free in smbd_free_send_io() after smbd_send_batch_flush()
ksmbd: fix use-after-free from async crypto on Qualcomm crypto engine
ksmbd: fix mechToken leak when SPNEGO decode fails after token alloc
ksmbd: require 3 sub-authorities before reading sub_auth[2]
ksmbd: validate EaNameLength in smb2_get_ea()
ksmbd: Remove unnecessary selection of CRYPTO_ECB
ksmbd: validate owner of durable handle on reconnect
ksmbd: fix use-after-free in __ksmbd_close_fd() via durable scavenger
ksmbd: ipc: use kzalloc_flex and __counted_by
smb: move filesystem_vol_info into common/fscc.h
smb: move file_basic_info into common/fscc.h
smb: move some definitions from common/smb2pdu.h into common/fscc.h

+663 -403
-9
fs/smb/client/smb1pdu.h
··· 2061 2061 __le32 EASize; 2062 2062 } __packed FILE_INFO_STANDARD; /* level 1 SetPath/FileInfo */ 2063 2063 2064 - typedef struct { 2065 - __le64 CreationTime; 2066 - __le64 LastAccessTime; 2067 - __le64 LastWriteTime; 2068 - __le64 ChangeTime; 2069 - __le32 Attributes; 2070 - __u32 Pad; 2071 - } __packed FILE_BASIC_INFO; /* size info, level 0x101 */ 2072 - 2073 2064 struct file_allocation_info { 2074 2065 __le64 AllocationSize; /* Note old Samba srvr rounds this up too much */ 2075 2066 } __packed; /* size used on disk, for level 0x103 for set, 0x105 for query */
+4 -4
fs/smb/client/smb2pdu.c
··· 6147 6147 max_len = sizeof(struct smb3_fs_ss_info); 6148 6148 min_len = sizeof(struct smb3_fs_ss_info); 6149 6149 } else if (level == FS_VOLUME_INFORMATION) { 6150 - max_len = sizeof(struct smb3_fs_vol_info) + MAX_VOL_LABEL_LEN; 6151 - min_len = sizeof(struct smb3_fs_vol_info); 6150 + max_len = sizeof(struct filesystem_vol_info) + MAX_VOL_LABEL_LEN; 6151 + min_len = sizeof(struct filesystem_vol_info); 6152 6152 } else { 6153 6153 cifs_dbg(FYI, "Invalid qfsinfo level %d\n", level); 6154 6154 return -EINVAL; ··· 6203 6203 tcon->perf_sector_size = 6204 6204 le32_to_cpu(ss_info->PhysicalBytesPerSectorForPerf); 6205 6205 } else if (level == FS_VOLUME_INFORMATION) { 6206 - struct smb3_fs_vol_info *vol_info = (struct smb3_fs_vol_info *) 6206 + struct filesystem_vol_info *vol_info = (struct filesystem_vol_info *) 6207 6207 (offset + (char *)rsp); 6208 - tcon->vol_serial_number = vol_info->VolumeSerialNumber; 6208 + tcon->vol_serial_number = le32_to_cpu(vol_info->VolumeSerialNumber); 6209 6209 tcon->vol_create_time = vol_info->VolumeCreationTime; 6210 6210 } 6211 6211
+8
fs/smb/client/smbdirect.c
··· 1551 1551 1552 1552 rc = smbd_post_send(sc, batch, request); 1553 1553 if (!rc) { 1554 + /* 1555 + * From here request is moved to batch 1556 + * and we should not free it explicitly. 1557 + */ 1558 + 1554 1559 if (batch != &_batch) 1555 1560 return 0; 1556 1561 1557 1562 rc = smbd_send_batch_flush(sc, batch, true); 1558 1563 if (!rc) 1559 1564 return 0; 1565 + 1566 + goto err_flush; 1560 1567 } 1561 1568 1562 1569 err_dma: 1563 1570 smbd_free_send_io(request); 1564 1571 1572 + err_flush: 1565 1573 err_alloc: 1566 1574 atomic_inc(&sc->send_io.credits.count); 1567 1575 wake_up(&sc->send_io.credits.wait_queue);
+336
fs/smb/common/fscc.h
··· 12 12 #ifndef _COMMON_SMB_FSCC_H 13 13 #define _COMMON_SMB_FSCC_H 14 14 15 + /* Reparse structures - see MS-FSCC 2.1.2 */ 16 + 17 + /* struct fsctl_reparse_info_req is empty, only response structs (see below) */ 18 + struct reparse_data_buffer { 19 + __le32 ReparseTag; 20 + __le16 ReparseDataLength; 21 + __u16 Reserved; 22 + __u8 DataBuffer[]; /* Variable Length */ 23 + } __packed; 24 + 25 + struct reparse_guid_data_buffer { 26 + __le32 ReparseTag; 27 + __le16 ReparseDataLength; 28 + __u16 Reserved; 29 + __u8 ReparseGuid[16]; 30 + __u8 DataBuffer[]; /* Variable Length */ 31 + } __packed; 32 + 33 + struct reparse_mount_point_data_buffer { 34 + __le32 ReparseTag; 35 + __le16 ReparseDataLength; 36 + __u16 Reserved; 37 + __le16 SubstituteNameOffset; 38 + __le16 SubstituteNameLength; 39 + __le16 PrintNameOffset; 40 + __le16 PrintNameLength; 41 + __u8 PathBuffer[]; /* Variable Length */ 42 + } __packed; 43 + 44 + #define SYMLINK_FLAG_RELATIVE 0x00000001 45 + 46 + struct reparse_symlink_data_buffer { 47 + __le32 ReparseTag; 48 + __le16 ReparseDataLength; 49 + __u16 Reserved; 50 + __le16 SubstituteNameOffset; 51 + __le16 SubstituteNameLength; 52 + __le16 PrintNameOffset; 53 + __le16 PrintNameLength; 54 + __le32 Flags; 55 + __u8 PathBuffer[]; /* Variable Length */ 56 + } __packed; 57 + 58 + /* For IO_REPARSE_TAG_NFS - see MS-FSCC 2.1.2.6 */ 59 + #define NFS_SPECFILE_LNK 0x00000000014B4E4C 60 + #define NFS_SPECFILE_CHR 0x0000000000524843 61 + #define NFS_SPECFILE_BLK 0x00000000004B4C42 62 + #define NFS_SPECFILE_FIFO 0x000000004F464946 63 + #define NFS_SPECFILE_SOCK 0x000000004B434F53 64 + struct reparse_nfs_data_buffer { 65 + __le32 ReparseTag; 66 + __le16 ReparseDataLength; 67 + __u16 Reserved; 68 + __le64 InodeType; /* NFS_SPECFILE_* */ 69 + __u8 DataBuffer[]; 70 + } __packed; 71 + 72 + /* For IO_REPARSE_TAG_LX_SYMLINK - see MS-FSCC 2.1.2.7 */ 73 + struct reparse_wsl_symlink_data_buffer { 74 + __le32 ReparseTag; 75 + __le16 ReparseDataLength; 76 + __u16 Reserved; 77 + __le32 Version; /* Always 2 */ 78 + __u8 Target[]; /* Variable Length UTF-8 string without nul-term */ 79 + } __packed; 80 + 81 + /* See MS-FSCC 2.3.7 */ 82 + struct duplicate_extents_to_file { 83 + __u64 PersistentFileHandle; /* source file handle, opaque endianness */ 84 + __u64 VolatileFileHandle; 85 + __le64 SourceFileOffset; 86 + __le64 TargetFileOffset; 87 + __le64 ByteCount; /* Bytes to be copied */ 88 + } __packed; 89 + 90 + /* See MS-FSCC 2.3.9 */ 91 + #define DUPLICATE_EXTENTS_DATA_EX_SOURCE_ATOMIC 0x00000001 92 + struct duplicate_extents_to_file_ex { 93 + __le64 StructureSize; /* MUST be set to 0x30 */ 94 + __u64 PersistentFileHandle; /* source file handle, opaque endianness */ 95 + __u64 VolatileFileHandle; 96 + __le64 SourceFileOffset; 97 + __le64 TargetFileOffset; 98 + __le64 ByteCount; /* Bytes to be copied */ 99 + __le32 Flags; 100 + __le32 Reserved; 101 + } __packed; 102 + 103 + /* See MS-FSCC 2.3.20 */ 104 + struct fsctl_get_integrity_information_rsp { 105 + __le16 ChecksumAlgorithm; 106 + __le16 Reserved; 107 + __le32 Flags; 108 + __le32 ChecksumChunkSizeInBytes; 109 + __le32 ClusterSizeInBytes; 110 + } __packed; 111 + 112 + /* See MS-FSCC 2.3.52 */ 113 + struct file_allocated_range_buffer { 114 + __le64 file_offset; 115 + __le64 length; 116 + } __packed; 117 + 118 + /* See MS-FSCC 2.3.55 */ 119 + struct fsctl_query_file_regions_req { 120 + __le64 FileOffset; 121 + __le64 Length; 122 + __le32 DesiredUsage; 123 + __le32 Reserved; 124 + } __packed; 125 + 126 + /* DesiredUsage flags see MS-FSCC 2.3.56.1 */ 127 + #define FILE_USAGE_INVALID_RANGE 0x00000000 128 + #define FILE_USAGE_VALID_CACHED_DATA 0x00000001 129 + #define FILE_USAGE_NONCACHED_DATA 0x00000002 130 + struct file_region_info { 131 + __le64 FileOffset; 132 + __le64 Length; 133 + __le32 DesiredUsage; 134 + __le32 Reserved; 135 + } __packed; 136 + 137 + /* See MS-FSCC 2.3.56 */ 138 + struct fsctl_query_file_region_rsp { 139 + __le32 Flags; 140 + __le32 TotalRegionEntryCount; 141 + __le32 RegionEntryCount; 142 + __u32 Reserved; 143 + struct file_region_info Regions[]; 144 + } __packed; 145 + 146 + /* See MS-FSCC 2.3.58 */ 147 + struct fsctl_query_on_disk_vol_info_rsp { 148 + __le64 DirectoryCount; 149 + __le64 FileCount; 150 + __le16 FsFormatMajVersion; 151 + __le16 FsFormatMinVersion; 152 + __u8 FsFormatName[24]; 153 + __le64 FormatTime; 154 + __le64 LastUpdateTime; 155 + __u8 CopyrightInfo[68]; 156 + __u8 AbstractInfo[68]; 157 + __u8 FormatImplInfo[68]; 158 + __u8 LastModifyImplInfo[68]; 159 + } __packed; 160 + 161 + /* See MS-FSCC 2.3.73 */ 162 + struct fsctl_set_integrity_information_req { 163 + __le16 ChecksumAlgorithm; 164 + __le16 Reserved; 165 + __le32 Flags; 166 + } __packed; 167 + 168 + /* See MS-FSCC 2.3.75 */ 169 + struct fsctl_set_integrity_info_ex_req { 170 + __u8 EnableIntegrity; 171 + __u8 KeepState; 172 + __u16 Reserved; 173 + __le32 Flags; 174 + __u8 Version; 175 + __u8 Reserved2[7]; 176 + } __packed; 177 + 178 + /* 179 + * this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA 180 + * See MS-FSCC 2.3.85 181 + */ 182 + struct file_zero_data_information { 183 + __le64 FileOffset; 184 + __le64 BeyondFinalZero; 185 + } __packed; 186 + 187 + /* 188 + * This level 18, although with struct with same name is different from cifs 189 + * level 0x107. Level 0x107 has an extra u64 between AccessFlags and 190 + * CurrentByteOffset. 191 + * See MS-FSCC 2.4.2 192 + */ 193 + struct smb2_file_all_info { /* data block encoding of response to level 18 */ 194 + __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */ 195 + __le64 LastAccessTime; 196 + __le64 LastWriteTime; 197 + __le64 ChangeTime; 198 + __le32 Attributes; 199 + __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */ 200 + __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ 201 + __le64 EndOfFile; /* size ie offset to first free byte in file */ 202 + __le32 NumberOfLinks; /* hard links */ 203 + __u8 DeletePending; 204 + __u8 Directory; 205 + __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */ 206 + __le64 IndexNumber; 207 + __le32 EASize; 208 + __le32 AccessFlags; 209 + __le64 CurrentByteOffset; 210 + __le32 Mode; 211 + __le32 AlignmentRequirement; 212 + __le32 FileNameLength; 213 + union { 214 + char __pad; /* Legacy structure padding */ 215 + DECLARE_FLEX_ARRAY(char, FileName); 216 + }; 217 + } __packed; /* level 18 Query */ 218 + 219 + /* See MS-FSCC 2.4.7 */ 220 + typedef struct file_basic_info { /* data block encoding of response to level 18 */ 221 + __le64 CreationTime; 222 + __le64 LastAccessTime; 223 + __le64 LastWriteTime; 224 + __le64 ChangeTime; 225 + __le32 Attributes; 226 + __u32 Pad; 227 + } __packed FILE_BASIC_INFO; /* size info, level 0x101 */ 228 + 15 229 /* See MS-FSCC 2.4.8 */ 16 230 typedef struct { 17 231 __le32 NextEntryOffset; ··· 259 45 __le32 FileNameLength; 260 46 char FileName[]; 261 47 } __packed FILE_DIRECTORY_INFO; /* level 0x101 FF resp data */ 48 + 49 + /* See MS-FSCC 2.4.13 */ 50 + struct smb2_file_eof_info { /* encoding of request for level 10 */ 51 + __le64 EndOfFile; /* new end of file value */ 52 + } __packed; /* level 20 Set */ 262 53 263 54 /* See MS-FSCC 2.4.14 */ 264 55 typedef struct { ··· 299 80 char FileName[]; 300 81 } __packed FILE_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */ 301 82 83 + /* See MS-FSCC 2.4.27 */ 84 + struct smb2_file_internal_info { 85 + __le64 IndexNumber; 86 + } __packed; /* level 6 Query */ 87 + 88 + /* See MS-FSCC 2.4.28.2 */ 89 + struct smb2_file_link_info { /* encoding of request for level 11 */ 90 + /* New members MUST be added within the struct_group() macro below. */ 91 + __struct_group(smb2_file_link_info_hdr, __hdr, __packed, 92 + __u8 ReplaceIfExists; /* 1 = replace existing link with new */ 93 + /* 0 = fail if link already exists */ 94 + __u8 Reserved[7]; 95 + __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ 96 + __le32 FileNameLength; 97 + ); 98 + char FileName[]; /* Name to be assigned to new link */ 99 + } __packed; /* level 11 Set */ 100 + static_assert(offsetof(struct smb2_file_link_info, FileName) == sizeof(struct smb2_file_link_info_hdr), 101 + "struct member likely outside of __struct_group()"); 102 + 302 103 /* See MS-FSCC 2.4.34 */ 303 104 struct smb2_file_network_open_info { 304 105 struct_group_attr(network_open_info, __packed, ··· 332 93 ); 333 94 __le32 Reserved; 334 95 } __packed; /* level 34 Query also similar returned in close rsp and open rsp */ 96 + 97 + /* See MS-FSCC 2.4.42.2 */ 98 + struct smb2_file_rename_info { /* encoding of request for level 10 */ 99 + /* New members MUST be added within the struct_group() macro below. */ 100 + __struct_group(smb2_file_rename_info_hdr, __hdr, __packed, 101 + __u8 ReplaceIfExists; /* 1 = replace existing target with new */ 102 + /* 0 = fail if target already exists */ 103 + __u8 Reserved[7]; 104 + __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ 105 + __le32 FileNameLength; 106 + ); 107 + char FileName[]; /* New name to be assigned */ 108 + /* padding - overall struct size must be >= 24 so filename + pad >= 6 */ 109 + } __packed; /* level 10 Set */ 110 + static_assert(offsetof(struct smb2_file_rename_info, FileName) == sizeof(struct smb2_file_rename_info_hdr), 111 + "struct member likely outside of __struct_group()"); 112 + 113 + /* File System Information Classes */ 114 + /* See MS-FSCC 2.5 */ 115 + #define FS_VOLUME_INFORMATION 1 /* Query */ 116 + #define FS_LABEL_INFORMATION 2 /* Set */ 117 + #define FS_SIZE_INFORMATION 3 /* Query */ 118 + #define FS_DEVICE_INFORMATION 4 /* Query */ 119 + #define FS_ATTRIBUTE_INFORMATION 5 /* Query */ 120 + #define FS_CONTROL_INFORMATION 6 /* Query, Set */ 121 + #define FS_FULL_SIZE_INFORMATION 7 /* Query */ 122 + #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */ 123 + #define FS_DRIVER_PATH_INFORMATION 9 /* Query */ 124 + #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */ 125 + /* See POSIX Extensions to MS-FSCC 2.3.1.1 */ 126 + #define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */ 335 127 336 128 /* See MS-FSCC 2.5.1 */ 337 129 #define MAX_FS_NAME_LEN 52 ··· 400 130 #define FILE_CASE_PRESERVED_NAMES 0x00000002 401 131 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001 402 132 133 + /* 134 + * File System Control Information 135 + * See MS-FSCC 2.5.2 136 + */ 137 + struct smb2_fs_control_info { 138 + __le64 FreeSpaceStartFiltering; 139 + __le64 FreeSpaceThreshold; 140 + __le64 FreeSpaceStopFiltering; 141 + __le64 DefaultQuotaThreshold; 142 + __le64 DefaultQuotaLimit; 143 + __le32 FileSystemControlFlags; 144 + __le32 Padding; 145 + } __packed; 146 + 147 + /* See MS-FSCC 2.5.4 */ 148 + struct smb2_fs_full_size_info { 149 + __le64 TotalAllocationUnits; 150 + __le64 CallerAvailableAllocationUnits; 151 + __le64 ActualAvailableAllocationUnits; 152 + __le32 SectorsPerAllocationUnit; 153 + __le32 BytesPerSector; 154 + } __packed; 155 + 156 + /* See MS-FSCC 2.5.7 */ 157 + #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001 158 + #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002 159 + #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004 160 + #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008 161 + /* sector size info struct */ 162 + struct smb3_fs_ss_info { 163 + __le32 LogicalBytesPerSector; 164 + __le32 PhysicalBytesPerSectorForAtomicity; 165 + __le32 PhysicalBytesPerSectorForPerf; 166 + __le32 FSEffPhysicalBytesPerSectorForAtomicity; 167 + __le32 Flags; 168 + __le32 ByteOffsetForSectorAlignment; 169 + __le32 ByteOffsetForPartitionAlignment; 170 + } __packed; 171 + 403 172 /* See MS-FSCC 2.5.8 */ 404 173 typedef struct { 405 174 __le64 TotalAllocationUnits; ··· 446 137 __le32 SectorsPerAllocationUnit; 447 138 __le32 BytesPerSector; 448 139 } __packed FILE_SYSTEM_SIZE_INFO; /* size info, level 0x103 */ 140 + 141 + /* volume info struct - see MS-FSCC 2.5.9 */ 142 + #define MAX_VOL_LABEL_LEN 32 143 + struct filesystem_vol_info { 144 + __le64 VolumeCreationTime; 145 + __le32 VolumeSerialNumber; 146 + __le32 VolumeLabelLength; /* includes trailing null */ 147 + __u8 SupportsObjects; /* True if eg like NTFS, supports objects */ 148 + __u8 Reserved; 149 + __u8 VolumeLabel[]; /* variable len */ 150 + } __packed; 449 151 450 152 /* See MS-FSCC 2.5.10 */ 451 153 typedef struct { ··· 508 188 #define FILE_ATTRIBUTE_INTEGRITY_STREAM_LE cpu_to_le32(FILE_ATTRIBUTE_INTEGRITY_STREAM) 509 189 #define FILE_ATTRIBUTE_NO_SCRUB_DATA_LE cpu_to_le32(FILE_ATTRIBUTE_NO_SCRUB_DATA) 510 190 #define FILE_ATTRIBUTE_MASK_LE cpu_to_le32(FILE_ATTRIBUTE_MASK) 191 + 192 + /* 193 + * SMB2 Notify Action Flags 194 + * See MS-FSCC 2.7.1 195 + */ 196 + #define FILE_ACTION_ADDED 0x00000001 197 + #define FILE_ACTION_REMOVED 0x00000002 198 + #define FILE_ACTION_MODIFIED 0x00000003 199 + #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004 200 + #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005 201 + #define FILE_ACTION_ADDED_STREAM 0x00000006 202 + #define FILE_ACTION_REMOVED_STREAM 0x00000007 203 + #define FILE_ACTION_MODIFIED_STREAM 0x00000008 204 + #define FILE_ACTION_REMOVED_BY_DELETE 0x00000009 205 + #define FILE_ACTION_ID_NOT_TUNNELLED 0x0000000A 206 + #define FILE_ACTION_TUNNELLED_ID_COLLISION 0x0000000B 511 207 512 208 /* 513 209 * Response contains array of the following structures
-318
fs/smb/common/smb2pdu.h
··· 1006 1006 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400 1007 1007 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800 1008 1008 1009 - /* 1010 - * SMB2 Notify Action Flags 1011 - * See MS-FSCC 2.7.1 1012 - */ 1013 - #define FILE_ACTION_ADDED 0x00000001 1014 - #define FILE_ACTION_REMOVED 0x00000002 1015 - #define FILE_ACTION_MODIFIED 0x00000003 1016 - #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004 1017 - #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005 1018 - #define FILE_ACTION_ADDED_STREAM 0x00000006 1019 - #define FILE_ACTION_REMOVED_STREAM 0x00000007 1020 - #define FILE_ACTION_MODIFIED_STREAM 0x00000008 1021 - #define FILE_ACTION_REMOVED_BY_DELETE 0x00000009 1022 - #define FILE_ACTION_ID_NOT_TUNNELLED 0x0000000A 1023 - #define FILE_ACTION_TUNNELLED_ID_COLLISION 0x0000000B 1024 - 1025 1009 /* See MS-SMB2 2.2.35 */ 1026 1010 struct smb2_change_notify_req { 1027 1011 struct smb2_hdr hdr; ··· 1483 1499 }; 1484 1500 } __packed; 1485 1501 1486 - /* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */ 1487 - struct file_zero_data_information { 1488 - __le64 FileOffset; 1489 - __le64 BeyondFinalZero; 1490 - } __packed; 1491 - 1492 - /* See MS-FSCC 2.3.7 */ 1493 - struct duplicate_extents_to_file { 1494 - __u64 PersistentFileHandle; /* source file handle, opaque endianness */ 1495 - __u64 VolatileFileHandle; 1496 - __le64 SourceFileOffset; 1497 - __le64 TargetFileOffset; 1498 - __le64 ByteCount; /* Bytes to be copied */ 1499 - } __packed; 1500 - 1501 - /* See MS-FSCC 2.3.9 */ 1502 - #define DUPLICATE_EXTENTS_DATA_EX_SOURCE_ATOMIC 0x00000001 1503 - struct duplicate_extents_to_file_ex { 1504 - __le64 StructureSize; /* MUST be set to 0x30 */ 1505 - __u64 PersistentFileHandle; /* source file handle, opaque endianness */ 1506 - __u64 VolatileFileHandle; 1507 - __le64 SourceFileOffset; 1508 - __le64 TargetFileOffset; 1509 - __le64 ByteCount; /* Bytes to be copied */ 1510 - __le32 Flags; 1511 - __le32 Reserved; 1512 - } __packed; 1513 - 1514 - 1515 - /* See MS-FSCC 2.3.20 */ 1516 - struct fsctl_get_integrity_information_rsp { 1517 - __le16 ChecksumAlgorithm; 1518 - __le16 Reserved; 1519 - __le32 Flags; 1520 - __le32 ChecksumChunkSizeInBytes; 1521 - __le32 ClusterSizeInBytes; 1522 - } __packed; 1523 - 1524 - /* See MS-FSCC 2.3.55 */ 1525 - struct fsctl_query_file_regions_req { 1526 - __le64 FileOffset; 1527 - __le64 Length; 1528 - __le32 DesiredUsage; 1529 - __le32 Reserved; 1530 - } __packed; 1531 - 1532 - /* DesiredUsage flags see MS-FSCC 2.3.56.1 */ 1533 - #define FILE_USAGE_INVALID_RANGE 0x00000000 1534 - #define FILE_USAGE_VALID_CACHED_DATA 0x00000001 1535 - #define FILE_USAGE_NONCACHED_DATA 0x00000002 1536 - 1537 - struct file_region_info { 1538 - __le64 FileOffset; 1539 - __le64 Length; 1540 - __le32 DesiredUsage; 1541 - __le32 Reserved; 1542 - } __packed; 1543 - 1544 - /* See MS-FSCC 2.3.56 */ 1545 - struct fsctl_query_file_region_rsp { 1546 - __le32 Flags; 1547 - __le32 TotalRegionEntryCount; 1548 - __le32 RegionEntryCount; 1549 - __u32 Reserved; 1550 - struct file_region_info Regions[]; 1551 - } __packed; 1552 - 1553 - /* See MS-FSCC 2.3.58 */ 1554 - struct fsctl_query_on_disk_vol_info_rsp { 1555 - __le64 DirectoryCount; 1556 - __le64 FileCount; 1557 - __le16 FsFormatMajVersion; 1558 - __le16 FsFormatMinVersion; 1559 - __u8 FsFormatName[24]; 1560 - __le64 FormatTime; 1561 - __le64 LastUpdateTime; 1562 - __u8 CopyrightInfo[68]; 1563 - __u8 AbstractInfo[68]; 1564 - __u8 FormatImplInfo[68]; 1565 - __u8 LastModifyImplInfo[68]; 1566 - } __packed; 1567 - 1568 - /* See MS-FSCC 2.3.73 */ 1569 - struct fsctl_set_integrity_information_req { 1570 - __le16 ChecksumAlgorithm; 1571 - __le16 Reserved; 1572 - __le32 Flags; 1573 - } __packed; 1574 - 1575 - /* See MS-FSCC 2.3.75 */ 1576 - struct fsctl_set_integrity_info_ex_req { 1577 - __u8 EnableIntegrity; 1578 - __u8 KeepState; 1579 - __u16 Reserved; 1580 - __le32 Flags; 1581 - __u8 Version; 1582 - __u8 Reserved2[7]; 1583 - } __packed; 1584 - 1585 1502 /* Integrity ChecksumAlgorithm choices for above */ 1586 1503 #define CHECKSUM_TYPE_NONE 0x0000 1587 1504 #define CHECKSUM_TYPE_CRC64 0x0002 ··· 1490 1605 1491 1606 /* Integrity flags for above */ 1492 1607 #define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001 1493 - 1494 - /* Reparse structures - see MS-FSCC 2.1.2 */ 1495 - 1496 - /* struct fsctl_reparse_info_req is empty, only response structs (see below) */ 1497 - struct reparse_data_buffer { 1498 - __le32 ReparseTag; 1499 - __le16 ReparseDataLength; 1500 - __u16 Reserved; 1501 - __u8 DataBuffer[]; /* Variable Length */ 1502 - } __packed; 1503 - 1504 - struct reparse_guid_data_buffer { 1505 - __le32 ReparseTag; 1506 - __le16 ReparseDataLength; 1507 - __u16 Reserved; 1508 - __u8 ReparseGuid[16]; 1509 - __u8 DataBuffer[]; /* Variable Length */ 1510 - } __packed; 1511 - 1512 - struct reparse_mount_point_data_buffer { 1513 - __le32 ReparseTag; 1514 - __le16 ReparseDataLength; 1515 - __u16 Reserved; 1516 - __le16 SubstituteNameOffset; 1517 - __le16 SubstituteNameLength; 1518 - __le16 PrintNameOffset; 1519 - __le16 PrintNameLength; 1520 - __u8 PathBuffer[]; /* Variable Length */ 1521 - } __packed; 1522 - 1523 - #define SYMLINK_FLAG_RELATIVE 0x00000001 1524 - 1525 - struct reparse_symlink_data_buffer { 1526 - __le32 ReparseTag; 1527 - __le16 ReparseDataLength; 1528 - __u16 Reserved; 1529 - __le16 SubstituteNameOffset; 1530 - __le16 SubstituteNameLength; 1531 - __le16 PrintNameOffset; 1532 - __le16 PrintNameLength; 1533 - __le32 Flags; 1534 - __u8 PathBuffer[]; /* Variable Length */ 1535 - } __packed; 1536 - 1537 - /* For IO_REPARSE_TAG_NFS - see MS-FSCC 2.1.2.6 */ 1538 - #define NFS_SPECFILE_LNK 0x00000000014B4E4C 1539 - #define NFS_SPECFILE_CHR 0x0000000000524843 1540 - #define NFS_SPECFILE_BLK 0x00000000004B4C42 1541 - #define NFS_SPECFILE_FIFO 0x000000004F464946 1542 - #define NFS_SPECFILE_SOCK 0x000000004B434F53 1543 - struct reparse_nfs_data_buffer { 1544 - __le32 ReparseTag; 1545 - __le16 ReparseDataLength; 1546 - __u16 Reserved; 1547 - __le64 InodeType; /* NFS_SPECFILE_* */ 1548 - __u8 DataBuffer[]; 1549 - } __packed; 1550 - 1551 - /* For IO_REPARSE_TAG_LX_SYMLINK - see MS-FSCC 2.1.2.7 */ 1552 - struct reparse_wsl_symlink_data_buffer { 1553 - __le32 ReparseTag; 1554 - __le16 ReparseDataLength; 1555 - __u16 Reserved; 1556 - __le32 Version; /* Always 2 */ 1557 - __u8 Target[]; /* Variable Length UTF-8 string without nul-term */ 1558 - } __packed; 1559 1608 1560 1609 struct validate_negotiate_info_req { 1561 1610 __le32 Capabilities; ··· 1610 1791 __u8 Buffer[]; 1611 1792 } __packed; 1612 1793 1613 - /* 1614 - * PDU query infolevel structure definitions 1615 - */ 1616 - 1617 - /* See MS-FSCC 2.3.52 */ 1618 - struct file_allocated_range_buffer { 1619 - __le64 file_offset; 1620 - __le64 length; 1621 - } __packed; 1622 - 1623 - struct smb2_file_internal_info { 1624 - __le64 IndexNumber; 1625 - } __packed; /* level 6 Query */ 1626 - 1627 - struct smb2_file_rename_info { /* encoding of request for level 10 */ 1628 - /* New members MUST be added within the struct_group() macro below. */ 1629 - __struct_group(smb2_file_rename_info_hdr, __hdr, __packed, 1630 - __u8 ReplaceIfExists; /* 1 = replace existing target with new */ 1631 - /* 0 = fail if target already exists */ 1632 - __u8 Reserved[7]; 1633 - __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ 1634 - __le32 FileNameLength; 1635 - ); 1636 - char FileName[]; /* New name to be assigned */ 1637 - /* padding - overall struct size must be >= 24 so filename + pad >= 6 */ 1638 - } __packed; /* level 10 Set */ 1639 - static_assert(offsetof(struct smb2_file_rename_info, FileName) == sizeof(struct smb2_file_rename_info_hdr), 1640 - "struct member likely outside of __struct_group()"); 1641 - 1642 - struct smb2_file_link_info { /* encoding of request for level 11 */ 1643 - /* New members MUST be added within the struct_group() macro below. */ 1644 - __struct_group(smb2_file_link_info_hdr, __hdr, __packed, 1645 - __u8 ReplaceIfExists; /* 1 = replace existing link with new */ 1646 - /* 0 = fail if link already exists */ 1647 - __u8 Reserved[7]; 1648 - __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ 1649 - __le32 FileNameLength; 1650 - ); 1651 - char FileName[]; /* Name to be assigned to new link */ 1652 - } __packed; /* level 11 Set */ 1653 - static_assert(offsetof(struct smb2_file_link_info, FileName) == sizeof(struct smb2_file_link_info_hdr), 1654 - "struct member likely outside of __struct_group()"); 1655 - 1656 - /* 1657 - * This level 18, although with struct with same name is different from cifs 1658 - * level 0x107. Level 0x107 has an extra u64 between AccessFlags and 1659 - * CurrentByteOffset. 1660 - */ 1661 - struct smb2_file_all_info { /* data block encoding of response to level 18 */ 1662 - __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */ 1663 - __le64 LastAccessTime; 1664 - __le64 LastWriteTime; 1665 - __le64 ChangeTime; 1666 - __le32 Attributes; 1667 - __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */ 1668 - __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ 1669 - __le64 EndOfFile; /* size ie offset to first free byte in file */ 1670 - __le32 NumberOfLinks; /* hard links */ 1671 - __u8 DeletePending; 1672 - __u8 Directory; 1673 - __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */ 1674 - __le64 IndexNumber; 1675 - __le32 EASize; 1676 - __le32 AccessFlags; 1677 - __le64 CurrentByteOffset; 1678 - __le32 Mode; 1679 - __le32 AlignmentRequirement; 1680 - __le32 FileNameLength; 1681 - union { 1682 - char __pad; /* Legacy structure padding */ 1683 - DECLARE_FLEX_ARRAY(char, FileName); 1684 - }; 1685 - } __packed; /* level 18 Query */ 1686 - 1687 - struct smb2_file_eof_info { /* encoding of request for level 10 */ 1688 - __le64 EndOfFile; /* new end of file value */ 1689 - } __packed; /* level 20 Set */ 1690 - 1691 1794 /* Level 100 query info */ 1692 1795 struct smb311_posix_qinfo { 1693 1796 __le64 CreationTime; ··· 1633 1892 * le32 filenamelength 1634 1893 * u8 filename[] 1635 1894 */ 1636 - } __packed; 1637 - 1638 - /* File System Information Classes */ 1639 - #define FS_VOLUME_INFORMATION 1 /* Query */ 1640 - #define FS_LABEL_INFORMATION 2 /* Set */ 1641 - #define FS_SIZE_INFORMATION 3 /* Query */ 1642 - #define FS_DEVICE_INFORMATION 4 /* Query */ 1643 - #define FS_ATTRIBUTE_INFORMATION 5 /* Query */ 1644 - #define FS_CONTROL_INFORMATION 6 /* Query, Set */ 1645 - #define FS_FULL_SIZE_INFORMATION 7 /* Query */ 1646 - #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */ 1647 - #define FS_DRIVER_PATH_INFORMATION 9 /* Query */ 1648 - #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */ 1649 - #define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */ 1650 - 1651 - struct smb2_fs_full_size_info { 1652 - __le64 TotalAllocationUnits; 1653 - __le64 CallerAvailableAllocationUnits; 1654 - __le64 ActualAvailableAllocationUnits; 1655 - __le32 SectorsPerAllocationUnit; 1656 - __le32 BytesPerSector; 1657 - } __packed; 1658 - 1659 - #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001 1660 - #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002 1661 - #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004 1662 - #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008 1663 - 1664 - /* sector size info struct */ 1665 - struct smb3_fs_ss_info { 1666 - __le32 LogicalBytesPerSector; 1667 - __le32 PhysicalBytesPerSectorForAtomicity; 1668 - __le32 PhysicalBytesPerSectorForPerf; 1669 - __le32 FSEffPhysicalBytesPerSectorForAtomicity; 1670 - __le32 Flags; 1671 - __le32 ByteOffsetForSectorAlignment; 1672 - __le32 ByteOffsetForPartitionAlignment; 1673 - } __packed; 1674 - 1675 - /* File System Control Information */ 1676 - struct smb2_fs_control_info { 1677 - __le64 FreeSpaceStartFiltering; 1678 - __le64 FreeSpaceThreshold; 1679 - __le64 FreeSpaceStopFiltering; 1680 - __le64 DefaultQuotaThreshold; 1681 - __le64 DefaultQuotaLimit; 1682 - __le32 FileSystemControlFlags; 1683 - __le32 Padding; 1684 - } __packed; 1685 - 1686 - /* volume info struct - see MS-FSCC 2.5.9 */ 1687 - #define MAX_VOL_LABEL_LEN 32 1688 - struct smb3_fs_vol_info { 1689 - __le64 VolumeCreationTime; 1690 - __u32 VolumeSerialNumber; 1691 - __le32 VolumeLabelLength; /* includes trailing null */ 1692 - __u8 SupportsObjects; /* True if eg like NTFS, supports objects */ 1693 - __u8 Reserved; 1694 - __u8 VolumeLabel[]; /* variable len */ 1695 1895 } __packed; 1696 1896 1697 1897 /* See MS-SMB2 2.2.23 through 2.2.25 */
+2
fs/smb/common/smbdirect/smbdirect.h
··· 7 7 #ifndef __FS_SMB_COMMON_SMBDIRECT_SMBDIRECT_H__ 8 8 #define __FS_SMB_COMMON_SMBDIRECT_SMBDIRECT_H__ 9 9 10 + #include <linux/types.h> 11 + 10 12 /* SMB-DIRECT buffer descriptor V1 structure [MS-SMBD] 2.2.3.1 */ 11 13 struct smbdirect_buffer_descriptor_v1 { 12 14 __le64 offset;
+147 -1
fs/smb/common/smbdirect/smbdirect_socket.h
··· 350 350 u64 dequeue_reassembly_queue; 351 351 u64 send_empty; 352 352 } statistics; 353 + 354 + struct { 355 + #define SMBDIRECT_LOG_ERR 0x0 356 + #define SMBDIRECT_LOG_INFO 0x1 357 + 358 + #define SMBDIRECT_LOG_OUTGOING 0x1 359 + #define SMBDIRECT_LOG_INCOMING 0x2 360 + #define SMBDIRECT_LOG_READ 0x4 361 + #define SMBDIRECT_LOG_WRITE 0x8 362 + #define SMBDIRECT_LOG_RDMA_SEND 0x10 363 + #define SMBDIRECT_LOG_RDMA_RECV 0x20 364 + #define SMBDIRECT_LOG_KEEP_ALIVE 0x40 365 + #define SMBDIRECT_LOG_RDMA_EVENT 0x80 366 + #define SMBDIRECT_LOG_RDMA_MR 0x100 367 + #define SMBDIRECT_LOG_RDMA_RW 0x200 368 + #define SMBDIRECT_LOG_NEGOTIATE 0x400 369 + void *private_ptr; 370 + bool (*needed)(struct smbdirect_socket *sc, 371 + void *private_ptr, 372 + unsigned int lvl, 373 + unsigned int cls); 374 + void (*vaprintf)(struct smbdirect_socket *sc, 375 + const char *func, 376 + unsigned int line, 377 + void *private_ptr, 378 + unsigned int lvl, 379 + unsigned int cls, 380 + struct va_format *vaf); 381 + } logging; 353 382 }; 354 383 355 384 static void __smbdirect_socket_disabled_work(struct work_struct *work) ··· 388 359 */ 389 360 WARN_ON_ONCE(1); 390 361 } 362 + 363 + static bool __smbdirect_log_needed(struct smbdirect_socket *sc, 364 + void *private_ptr, 365 + unsigned int lvl, 366 + unsigned int cls) 367 + { 368 + /* 369 + * Should never be called, the caller should 370 + * set it's own functions. 371 + */ 372 + WARN_ON_ONCE(1); 373 + return false; 374 + } 375 + 376 + static void __smbdirect_log_vaprintf(struct smbdirect_socket *sc, 377 + const char *func, 378 + unsigned int line, 379 + void *private_ptr, 380 + unsigned int lvl, 381 + unsigned int cls, 382 + struct va_format *vaf) 383 + { 384 + /* 385 + * Should never be called, the caller should 386 + * set it's own functions. 387 + */ 388 + WARN_ON_ONCE(1); 389 + } 390 + 391 + __printf(6, 7) 392 + static void __smbdirect_log_printf(struct smbdirect_socket *sc, 393 + const char *func, 394 + unsigned int line, 395 + unsigned int lvl, 396 + unsigned int cls, 397 + const char *fmt, 398 + ...); 399 + __maybe_unused 400 + static void __smbdirect_log_printf(struct smbdirect_socket *sc, 401 + const char *func, 402 + unsigned int line, 403 + unsigned int lvl, 404 + unsigned int cls, 405 + const char *fmt, 406 + ...) 407 + { 408 + struct va_format vaf; 409 + va_list args; 410 + 411 + va_start(args, fmt); 412 + 413 + vaf.fmt = fmt; 414 + vaf.va = &args; 415 + 416 + sc->logging.vaprintf(sc, 417 + func, 418 + line, 419 + sc->logging.private_ptr, 420 + lvl, 421 + cls, 422 + &vaf); 423 + va_end(args); 424 + } 425 + 426 + #define ___smbdirect_log_generic(sc, func, line, lvl, cls, fmt, args...) do { \ 427 + if (sc->logging.needed(sc, sc->logging.private_ptr, lvl, cls)) { \ 428 + __smbdirect_log_printf(sc, func, line, lvl, cls, fmt, ##args); \ 429 + } \ 430 + } while (0) 431 + #define __smbdirect_log_generic(sc, lvl, cls, fmt, args...) \ 432 + ___smbdirect_log_generic(sc, __func__, __LINE__, lvl, cls, fmt, ##args) 433 + 434 + #define smbdirect_log_outgoing(sc, lvl, fmt, args...) \ 435 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_OUTGOING, fmt, ##args) 436 + #define smbdirect_log_incoming(sc, lvl, fmt, args...) \ 437 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_INCOMING, fmt, ##args) 438 + #define smbdirect_log_read(sc, lvl, fmt, args...) \ 439 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_READ, fmt, ##args) 440 + #define smbdirect_log_write(sc, lvl, fmt, args...) \ 441 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_WRITE, fmt, ##args) 442 + #define smbdirect_log_rdma_send(sc, lvl, fmt, args...) \ 443 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_RDMA_SEND, fmt, ##args) 444 + #define smbdirect_log_rdma_recv(sc, lvl, fmt, args...) \ 445 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_RDMA_RECV, fmt, ##args) 446 + #define smbdirect_log_keep_alive(sc, lvl, fmt, args...) \ 447 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_KEEP_ALIVE, fmt, ##args) 448 + #define smbdirect_log_rdma_event(sc, lvl, fmt, args...) \ 449 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_RDMA_EVENT, fmt, ##args) 450 + #define smbdirect_log_rdma_mr(sc, lvl, fmt, args...) \ 451 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_RDMA_MR, fmt, ##args) 452 + #define smbdirect_log_rdma_rw(sc, lvl, fmt, args...) \ 453 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_RDMA_RW, fmt, ##args) 454 + #define smbdirect_log_negotiate(sc, lvl, fmt, args...) \ 455 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_NEGOTIATE, fmt, ##args) 391 456 392 457 static __always_inline void smbdirect_socket_init(struct smbdirect_socket *sc) 393 458 { ··· 543 420 INIT_WORK(&sc->mr_io.recovery_work, __smbdirect_socket_disabled_work); 544 421 disable_work_sync(&sc->mr_io.recovery_work); 545 422 init_waitqueue_head(&sc->mr_io.cleanup.wait_queue); 423 + 424 + sc->logging.private_ptr = NULL; 425 + sc->logging.needed = __smbdirect_log_needed; 426 + sc->logging.vaprintf = __smbdirect_log_vaprintf; 546 427 } 547 428 548 429 #define __SMBDIRECT_CHECK_STATUS_FAILED(__sc, __expected_status, __error_cmd, __unexpected_cmd) ({ \ ··· 563 436 564 437 #define __SMBDIRECT_CHECK_STATUS_WARN(__sc, __expected_status, __unexpected_cmd) \ 565 438 __SMBDIRECT_CHECK_STATUS_FAILED(__sc, __expected_status, \ 566 - , \ 567 439 { \ 568 440 const struct sockaddr_storage *__src = NULL; \ 569 441 const struct sockaddr_storage *__dst = NULL; \ ··· 570 444 __src = &(__sc)->rdma.cm_id->route.addr.src_addr; \ 571 445 __dst = &(__sc)->rdma.cm_id->route.addr.dst_addr; \ 572 446 } \ 447 + smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_INFO, \ 448 + "expected[%s] != %s first_error=%1pe local=%pISpsfc remote=%pISpsfc\n", \ 449 + smbdirect_socket_status_string(__expected_status), \ 450 + smbdirect_socket_status_string((__sc)->status), \ 451 + SMBDIRECT_DEBUG_ERR_PTR((__sc)->first_error), \ 452 + __src, __dst); \ 453 + }, \ 454 + { \ 455 + const struct sockaddr_storage *__src = NULL; \ 456 + const struct sockaddr_storage *__dst = NULL; \ 457 + if ((__sc)->rdma.cm_id) { \ 458 + __src = &(__sc)->rdma.cm_id->route.addr.src_addr; \ 459 + __dst = &(__sc)->rdma.cm_id->route.addr.dst_addr; \ 460 + } \ 461 + smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR, \ 462 + "expected[%s] != %s first_error=%1pe local=%pISpsfc remote=%pISpsfc\n", \ 463 + smbdirect_socket_status_string(__expected_status), \ 464 + smbdirect_socket_status_string((__sc)->status), \ 465 + SMBDIRECT_DEBUG_ERR_PTR((__sc)->first_error), \ 466 + __src, __dst); \ 573 467 WARN_ONCE(1, \ 574 468 "expected[%s] != %s first_error=%1pe local=%pISpsfc remote=%pISpsfc\n", \ 575 469 smbdirect_socket_status_string(__expected_status), \
-1
fs/smb/server/Kconfig
··· 7 7 select NLS_UTF8 8 8 select NLS_UCS2_UTILS 9 9 select CRYPTO 10 - select CRYPTO_ECB 11 10 select CRYPTO_LIB_ARC4 12 11 select CRYPTO_LIB_DES 13 12 select CRYPTO_LIB_MD5
+6 -5
fs/smb/server/auth.c
··· 827 827 struct smb2_transform_hdr *tr_hdr = smb_get_msg(iov[0].iov_base); 828 828 unsigned int assoc_data_len = sizeof(struct smb2_transform_hdr) - 20; 829 829 int rc; 830 + DECLARE_CRYPTO_WAIT(wait); 830 831 struct scatterlist *sg; 831 832 u8 sign[SMB2_SIGNATURE_SIZE] = {}; 832 833 u8 key[SMB3_ENC_DEC_KEY_SIZE]; ··· 914 913 915 914 aead_request_set_crypt(req, sg, sg, crypt_len, iv); 916 915 aead_request_set_ad(req, assoc_data_len); 917 - aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL); 916 + aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG | 917 + CRYPTO_TFM_REQ_MAY_SLEEP, 918 + crypto_req_done, &wait); 918 919 919 - if (enc) 920 - rc = crypto_aead_encrypt(req); 921 - else 922 - rc = crypto_aead_decrypt(req); 920 + rc = crypto_wait_req(enc ? crypto_aead_encrypt(req) : 921 + crypto_aead_decrypt(req), &wait); 923 922 if (rc) 924 923 goto free_iv; 925 924
+1
fs/smb/server/connection.c
··· 96 96 xa_destroy(&conn->sessions); 97 97 kvfree(conn->request_buf); 98 98 kfree(conn->preauth_info); 99 + kfree(conn->mechToken); 99 100 if (atomic_dec_and_test(&conn->refcnt)) { 100 101 conn->transport->ops->free_transport(conn->transport); 101 102 kfree(conn);
-5
fs/smb/server/crypto_ctx.h
··· 20 20 CRYPTO_AEAD_MAX, 21 21 }; 22 22 23 - enum { 24 - CRYPTO_BLK_ECBDES = 32, 25 - CRYPTO_BLK_MAX, 26 - }; 27 - 28 23 struct ksmbd_crypto_ctx { 29 24 struct list_head list; 30 25
+3 -5
fs/smb/server/mgmt/user_session.c
··· 382 382 return; 383 383 384 384 delete_proc_session(sess); 385 - 385 + ksmbd_tree_conn_session_logoff(sess); 386 + ksmbd_destroy_file_table(sess); 386 387 if (sess->user) 387 388 ksmbd_free_user(sess->user); 388 - 389 - ksmbd_tree_conn_session_logoff(sess); 390 - ksmbd_destroy_file_table(&sess->file_table); 391 389 ksmbd_launch_ksmbd_durable_scavenger(); 392 390 ksmbd_session_rpc_clear_list(sess); 393 391 free_channel_list(sess); ··· 616 618 goto out; 617 619 } 618 620 619 - ksmbd_destroy_file_table(&prev_sess->file_table); 621 + ksmbd_destroy_file_table(prev_sess); 620 622 prev_sess->state = SMB2_SESSION_EXPIRED; 621 623 ksmbd_all_conn_set_status(id, KSMBD_SESS_NEED_SETUP); 622 624 ksmbd_launch_ksmbd_durable_scavenger();
+7
fs/smb/server/oplock.c
··· 1841 1841 struct ksmbd_share_config *share, 1842 1842 struct ksmbd_file *fp, 1843 1843 struct lease_ctx_info *lctx, 1844 + struct ksmbd_user *user, 1844 1845 char *name) 1845 1846 { 1846 1847 struct oplock_info *opinfo = opinfo_get(fp); ··· 1849 1848 1850 1849 if (!opinfo) 1851 1850 return 0; 1851 + 1852 + if (ksmbd_vfs_compare_durable_owner(fp, user) == false) { 1853 + ksmbd_debug(SMB, "Durable handle reconnect failed: owner mismatch\n"); 1854 + ret = -EBADF; 1855 + goto out; 1856 + } 1852 1857 1853 1858 if (opinfo->is_lease == false) { 1854 1859 if (lctx) {
+1
fs/smb/server/oplock.h
··· 126 126 struct ksmbd_share_config *share, 127 127 struct ksmbd_file *fp, 128 128 struct lease_ctx_info *lctx, 129 + struct ksmbd_user *user, 129 130 char *name); 130 131 #endif /* __KSMBD_OPLOCK_H */
-1
fs/smb/server/server.c
··· 629 629 MODULE_AUTHOR("Namjae Jeon <linkinjeon@kernel.org>"); 630 630 MODULE_DESCRIPTION("Linux kernel CIFS/SMB SERVER"); 631 631 MODULE_LICENSE("GPL"); 632 - MODULE_SOFTDEP("pre: ecb"); 633 632 MODULE_SOFTDEP("pre: nls"); 634 633 MODULE_SOFTDEP("pre: aes"); 635 634 MODULE_SOFTDEP("pre: cmac");
+18 -11
fs/smb/server/smb2pdu.c
··· 1915 1915 else if (rc) 1916 1916 rsp->hdr.Status = STATUS_LOGON_FAILURE; 1917 1917 1918 - if (conn->use_spnego && conn->mechToken) { 1918 + if (conn->mechToken) { 1919 1919 kfree(conn->mechToken); 1920 1920 conn->mechToken = NULL; 1921 1921 } ··· 3013 3013 } 3014 3014 3015 3015 if (dh_info.reconnected == true) { 3016 - rc = smb2_check_durable_oplock(conn, share, dh_info.fp, lc, name); 3016 + rc = smb2_check_durable_oplock(conn, share, dh_info.fp, 3017 + lc, sess->user, name); 3017 3018 if (rc) { 3018 3019 ksmbd_put_durable_fd(dh_info.fp); 3019 3020 goto err_out2; ··· 4717 4716 4718 4717 ea_req = (struct smb2_ea_info_req *)((char *)req + 4719 4718 le16_to_cpu(req->InputBufferOffset)); 4719 + 4720 + if (le32_to_cpu(req->InputBufferLength) < 4721 + offsetof(struct smb2_ea_info_req, name) + 4722 + ea_req->EaNameLength) 4723 + return -EINVAL; 4720 4724 } else { 4721 4725 /* need to send all EAs, if no specific EA is requested*/ 4722 4726 if (le32_to_cpu(req->Flags) & SL_RETURN_SINGLE_ENTRY) ··· 4864 4858 static int get_file_basic_info(struct smb2_query_info_rsp *rsp, 4865 4859 struct ksmbd_file *fp, void *rsp_org) 4866 4860 { 4867 - struct smb2_file_basic_info *basic_info; 4861 + struct file_basic_info *basic_info; 4868 4862 struct kstat stat; 4869 4863 u64 time; 4870 4864 int ret; ··· 4880 4874 if (ret) 4881 4875 return ret; 4882 4876 4883 - basic_info = (struct smb2_file_basic_info *)rsp->Buffer; 4877 + basic_info = (struct file_basic_info *)rsp->Buffer; 4884 4878 basic_info->CreationTime = cpu_to_le64(fp->create_time); 4885 4879 time = ksmbd_UnixTimeToNT(stat.atime); 4886 4880 basic_info->LastAccessTime = cpu_to_le64(time); ··· 4889 4883 time = ksmbd_UnixTimeToNT(stat.ctime); 4890 4884 basic_info->ChangeTime = cpu_to_le64(time); 4891 4885 basic_info->Attributes = fp->f_ci->m_fattr; 4892 - basic_info->Pad1 = 0; 4886 + basic_info->Pad = 0; 4893 4887 rsp->OutputBufferLength = 4894 - cpu_to_le32(sizeof(struct smb2_file_basic_info)); 4888 + cpu_to_le32(sizeof(struct file_basic_info)); 4895 4889 return 0; 4896 4890 } 4897 4891 ··· 5589 5583 serial_crc = crc32_le(serial_crc, ksmbd_netbios_name(), 5590 5584 strlen(ksmbd_netbios_name())); 5591 5585 /* Taking dummy value of serial number*/ 5592 - info->SerialNumber = cpu_to_le32(serial_crc); 5586 + info->VolumeSerialNumber = cpu_to_le32(serial_crc); 5593 5587 len = smbConvertToUTF16((__le16 *)info->VolumeLabel, 5594 5588 share->name, PATH_MAX, 5595 5589 conn->local_nls, 0); 5596 5590 len = len * 2; 5597 - info->VolumeLabelSize = cpu_to_le32(len); 5591 + info->VolumeLabelLength = cpu_to_le32(len); 5598 5592 info->Reserved = 0; 5593 + info->SupportsObjects = 0; 5599 5594 sz = sizeof(struct filesystem_vol_info) + len; 5600 5595 rsp->OutputBufferLength = cpu_to_le32(sz); 5601 5596 break; ··· 6229 6222 } 6230 6223 6231 6224 static int set_file_basic_info(struct ksmbd_file *fp, 6232 - struct smb2_file_basic_info *file_info, 6225 + struct file_basic_info *file_info, 6233 6226 struct ksmbd_share_config *share) 6234 6227 { 6235 6228 struct iattr attrs; ··· 6511 6504 switch (req->FileInfoClass) { 6512 6505 case FILE_BASIC_INFORMATION: 6513 6506 { 6514 - if (buf_len < sizeof(struct smb2_file_basic_info)) 6507 + if (buf_len < sizeof(struct file_basic_info)) 6515 6508 return -EMSGSIZE; 6516 6509 6517 - return set_file_basic_info(fp, (struct smb2_file_basic_info *)buffer, share); 6510 + return set_file_basic_info(fp, (struct file_basic_info *)buffer, share); 6518 6511 } 6519 6512 case FILE_ALLOCATION_INFORMATION: 6520 6513 {
-9
fs/smb/server/smb2pdu.h
··· 186 186 __le32 AlignmentRequirement; 187 187 } __packed; 188 188 189 - struct smb2_file_basic_info { /* data block encoding of response to level 18 */ 190 - __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */ 191 - __le64 LastAccessTime; 192 - __le64 LastWriteTime; 193 - __le64 ChangeTime; 194 - __le32 Attributes; 195 - __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */ 196 - } __packed; 197 - 198 189 struct smb2_file_alt_name_info { 199 190 __le32 FileNameLength; 200 191 char FileName[];
-8
fs/smb/server/smb_common.h
··· 90 90 __le16 ByteCount; 91 91 } __packed; 92 92 93 - struct filesystem_vol_info { 94 - __le64 VolumeCreationTime; 95 - __le32 SerialNumber; 96 - __le32 VolumeLabelSize; 97 - __le16 Reserved; 98 - __le16 VolumeLabel[]; 99 - } __packed; 100 - 101 93 #define EXTENDED_INFO_MAGIC 0x43667364 /* Cfsd */ 102 94 #define STRING_LENGTH 28 103 95
+2 -1
fs/smb/server/smbacl.c
··· 451 451 ppace[i]->access_req = 452 452 smb_map_generic_desired_access(ppace[i]->access_req); 453 453 454 - if (!(compare_sids(&ppace[i]->sid, &sid_unix_NFS_mode))) { 454 + if (ppace[i]->sid.num_subauth >= 3 && 455 + !(compare_sids(&ppace[i]->sid, &sid_unix_NFS_mode))) { 455 456 fattr->cf_mode = 456 457 le32_to_cpu(ppace[i]->sid.sub_auth[2]); 457 458 break;
+2 -3
fs/smb/server/transport_ipc.c
··· 55 55 struct ksmbd_ipc_msg { 56 56 unsigned int type; 57 57 unsigned int sz; 58 - unsigned char payload[]; 58 + unsigned char payload[] __counted_by(sz); 59 59 }; 60 60 61 61 struct ipc_msg_table_entry { ··· 242 242 static struct ksmbd_ipc_msg *ipc_msg_alloc(size_t sz) 243 243 { 244 244 struct ksmbd_ipc_msg *msg; 245 - size_t msg_sz = sz + sizeof(struct ksmbd_ipc_msg); 246 245 247 - msg = kvzalloc(msg_sz, KSMBD_DEFAULT_GFP); 246 + msg = kvzalloc_flex(*msg, payload, sz, KSMBD_DEFAULT_GFP); 248 247 if (msg) 249 248 msg->sz = sz; 250 249 return msg;
+7 -1
fs/smb/server/transport_rdma.c
··· 1588 1588 if (ret) 1589 1589 goto err; 1590 1590 1591 + /* 1592 + * From here msg is moved to send_ctx 1593 + * and we should not free it explicitly. 1594 + */ 1595 + 1591 1596 if (send_ctx == &_send_ctx) { 1592 1597 ret = smb_direct_flush_send_list(sc, send_ctx, true); 1593 1598 if (ret) 1594 - goto err; 1599 + goto flush_failed; 1595 1600 } 1596 1601 1597 1602 return 0; 1598 1603 err: 1599 1604 smb_direct_free_sendmsg(sc, msg); 1605 + flush_failed: 1600 1606 header_failed: 1601 1607 atomic_inc(&sc->send_io.credits.count); 1602 1608 credit_failed:
+108 -20
fs/smb/server/vfs_cache.c
··· 19 19 #include "misc.h" 20 20 #include "mgmt/tree_connect.h" 21 21 #include "mgmt/user_session.h" 22 + #include "mgmt/user_config.h" 22 23 #include "smb_common.h" 23 24 #include "server.h" 24 25 #include "smb2pdu.h" ··· 464 463 * there are not accesses to fp->lock_list. 465 464 */ 466 465 list_for_each_entry_safe(smb_lock, tmp_lock, &fp->lock_list, flist) { 467 - spin_lock(&fp->conn->llist_lock); 468 - list_del(&smb_lock->clist); 469 - spin_unlock(&fp->conn->llist_lock); 466 + if (!list_empty(&smb_lock->clist) && fp->conn) { 467 + spin_lock(&fp->conn->llist_lock); 468 + list_del(&smb_lock->clist); 469 + spin_unlock(&fp->conn->llist_lock); 470 + } 470 471 471 472 list_del(&smb_lock->flist); 472 473 locks_free_lock(smb_lock->fl); ··· 477 474 478 475 if (ksmbd_stream_fd(fp)) 479 476 kfree(fp->stream.name); 477 + kfree(fp->owner.name); 478 + 480 479 kmem_cache_free(filp_cache, fp); 481 480 } 482 481 ··· 790 785 } 791 786 792 787 static int 793 - __close_file_table_ids(struct ksmbd_file_table *ft, 788 + __close_file_table_ids(struct ksmbd_session *sess, 794 789 struct ksmbd_tree_connect *tcon, 795 790 bool (*skip)(struct ksmbd_tree_connect *tcon, 796 - struct ksmbd_file *fp)) 791 + struct ksmbd_file *fp, 792 + struct ksmbd_user *user)) 797 793 { 794 + struct ksmbd_file_table *ft = &sess->file_table; 798 795 struct ksmbd_file *fp; 799 796 unsigned int id = 0; 800 797 int num = 0; ··· 809 802 break; 810 803 } 811 804 812 - if (skip(tcon, fp) || 805 + if (skip(tcon, fp, sess->user) || 813 806 !atomic_dec_and_test(&fp->refcount)) { 814 807 id++; 815 808 write_unlock(&ft->lock); ··· 861 854 } 862 855 863 856 static bool tree_conn_fd_check(struct ksmbd_tree_connect *tcon, 864 - struct ksmbd_file *fp) 857 + struct ksmbd_file *fp, 858 + struct ksmbd_user *user) 865 859 { 866 860 return fp->tcon != tcon; 867 861 } ··· 997 989 kthread_stop(server_conf.dh_task); 998 990 } 999 991 992 + /* 993 + * ksmbd_vfs_copy_durable_owner - Copy owner info for durable reconnect 994 + * @fp: ksmbd file pointer to store owner info 995 + * @user: user pointer to copy from 996 + * 997 + * This function binds the current user's identity to the file handle 998 + * to satisfy MS-SMB2 Step 8 (SecurityContext matching) during reconnect. 999 + * 1000 + * Return: 0 on success, or negative error code on failure 1001 + */ 1002 + static int ksmbd_vfs_copy_durable_owner(struct ksmbd_file *fp, 1003 + struct ksmbd_user *user) 1004 + { 1005 + if (!user) 1006 + return -EINVAL; 1007 + 1008 + /* Duplicate the user name to ensure identity persistence */ 1009 + fp->owner.name = kstrdup(user->name, GFP_KERNEL); 1010 + if (!fp->owner.name) 1011 + return -ENOMEM; 1012 + 1013 + fp->owner.uid = user->uid; 1014 + fp->owner.gid = user->gid; 1015 + 1016 + return 0; 1017 + } 1018 + 1019 + /** 1020 + * ksmbd_vfs_compare_durable_owner - Verify if the requester is original owner 1021 + * @fp: existing ksmbd file pointer 1022 + * @user: user pointer of the reconnect requester 1023 + * 1024 + * Compares the UID, GID, and name of the current requester against the 1025 + * original owner stored in the file handle. 1026 + * 1027 + * Return: true if the user matches, false otherwise 1028 + */ 1029 + bool ksmbd_vfs_compare_durable_owner(struct ksmbd_file *fp, 1030 + struct ksmbd_user *user) 1031 + { 1032 + if (!user || !fp->owner.name) 1033 + return false; 1034 + 1035 + /* Check if the UID and GID match first (fast path) */ 1036 + if (fp->owner.uid != user->uid || fp->owner.gid != user->gid) 1037 + return false; 1038 + 1039 + /* Validate the account name to ensure the same SecurityContext */ 1040 + if (strcmp(fp->owner.name, user->name)) 1041 + return false; 1042 + 1043 + return true; 1044 + } 1045 + 1000 1046 static bool session_fd_check(struct ksmbd_tree_connect *tcon, 1001 - struct ksmbd_file *fp) 1047 + struct ksmbd_file *fp, struct ksmbd_user *user) 1002 1048 { 1003 1049 struct ksmbd_inode *ci; 1004 1050 struct oplock_info *op; 1005 1051 struct ksmbd_conn *conn; 1052 + struct ksmbd_lock *smb_lock, *tmp_lock; 1006 1053 1007 1054 if (!is_reconnectable(fp)) 1055 + return false; 1056 + 1057 + if (ksmbd_vfs_copy_durable_owner(fp, user)) 1008 1058 return false; 1009 1059 1010 1060 conn = fp->conn; ··· 1077 1011 } 1078 1012 up_write(&ci->m_lock); 1079 1013 1014 + list_for_each_entry_safe(smb_lock, tmp_lock, &fp->lock_list, flist) { 1015 + spin_lock(&fp->conn->llist_lock); 1016 + list_del_init(&smb_lock->clist); 1017 + spin_unlock(&fp->conn->llist_lock); 1018 + } 1019 + 1080 1020 fp->conn = NULL; 1081 1021 fp->tcon = NULL; 1082 1022 fp->volatile_id = KSMBD_NO_FID; ··· 1096 1024 1097 1025 void ksmbd_close_tree_conn_fds(struct ksmbd_work *work) 1098 1026 { 1099 - int num = __close_file_table_ids(&work->sess->file_table, 1027 + int num = __close_file_table_ids(work->sess, 1100 1028 work->tcon, 1101 1029 tree_conn_fd_check); 1102 1030 ··· 1105 1033 1106 1034 void ksmbd_close_session_fds(struct ksmbd_work *work) 1107 1035 { 1108 - int num = __close_file_table_ids(&work->sess->file_table, 1036 + int num = __close_file_table_ids(work->sess, 1109 1037 work->tcon, 1110 1038 session_fd_check); 1111 1039 ··· 1162 1090 { 1163 1091 struct ksmbd_inode *ci; 1164 1092 struct oplock_info *op; 1093 + struct ksmbd_conn *conn = work->conn; 1094 + struct ksmbd_lock *smb_lock; 1095 + unsigned int old_f_state; 1165 1096 1166 1097 if (!fp->is_durable || fp->conn || fp->tcon) { 1167 1098 pr_err("Invalid durable fd [%p:%p]\n", fp->conn, fp->tcon); ··· 1176 1101 return -EBADF; 1177 1102 } 1178 1103 1179 - fp->conn = work->conn; 1104 + old_f_state = fp->f_state; 1105 + fp->f_state = FP_NEW; 1106 + __open_id(&work->sess->file_table, fp, OPEN_ID_TYPE_VOLATILE_ID); 1107 + if (!has_file_id(fp->volatile_id)) { 1108 + fp->f_state = old_f_state; 1109 + return -EBADF; 1110 + } 1111 + 1112 + fp->conn = conn; 1180 1113 fp->tcon = work->tcon; 1114 + 1115 + list_for_each_entry(smb_lock, &fp->lock_list, flist) { 1116 + spin_lock(&conn->llist_lock); 1117 + list_add_tail(&smb_lock->clist, &conn->lock_list); 1118 + spin_unlock(&conn->llist_lock); 1119 + } 1181 1120 1182 1121 ci = fp->f_ci; 1183 1122 down_write(&ci->m_lock); ··· 1203 1114 } 1204 1115 up_write(&ci->m_lock); 1205 1116 1206 - fp->f_state = FP_NEW; 1207 - __open_id(&work->sess->file_table, fp, OPEN_ID_TYPE_VOLATILE_ID); 1208 - if (!has_file_id(fp->volatile_id)) { 1209 - fp->conn = NULL; 1210 - fp->tcon = NULL; 1211 - return -EBADF; 1212 - } 1117 + fp->owner.uid = fp->owner.gid = 0; 1118 + kfree(fp->owner.name); 1119 + fp->owner.name = NULL; 1120 + 1213 1121 return 0; 1214 1122 } 1215 1123 ··· 1221 1135 return 0; 1222 1136 } 1223 1137 1224 - void ksmbd_destroy_file_table(struct ksmbd_file_table *ft) 1138 + void ksmbd_destroy_file_table(struct ksmbd_session *sess) 1225 1139 { 1140 + struct ksmbd_file_table *ft = &sess->file_table; 1141 + 1226 1142 if (!ft->idr) 1227 1143 return; 1228 1144 1229 - __close_file_table_ids(ft, NULL, session_fd_check); 1145 + __close_file_table_ids(sess, NULL, session_fd_check); 1230 1146 idr_destroy(ft->idr); 1231 1147 kfree(ft->idr); 1232 1148 ft->idr = NULL;
+11 -1
fs/smb/server/vfs_cache.h
··· 68 68 FP_CLOSED 69 69 }; 70 70 71 + /* Owner information for durable handle reconnect */ 72 + struct durable_owner { 73 + unsigned int uid; 74 + unsigned int gid; 75 + char *name; 76 + }; 77 + 71 78 struct ksmbd_file { 72 79 struct file *filp; 73 80 u64 persistent_id; ··· 121 114 bool is_resilient; 122 115 123 116 bool is_posix_ctxt; 117 + struct durable_owner owner; 124 118 }; 125 119 126 120 static inline void set_ctx_actor(struct dir_context *ctx, ··· 148 140 } 149 141 150 142 int ksmbd_init_file_table(struct ksmbd_file_table *ft); 151 - void ksmbd_destroy_file_table(struct ksmbd_file_table *ft); 143 + void ksmbd_destroy_file_table(struct ksmbd_session *sess); 152 144 int ksmbd_close_fd(struct ksmbd_work *work, u64 id); 153 145 struct ksmbd_file *ksmbd_lookup_fd_fast(struct ksmbd_work *work, u64 id); 154 146 struct ksmbd_file *ksmbd_lookup_foreign_fd(struct ksmbd_work *work, u64 id); ··· 174 166 void ksmbd_set_fd_limit(unsigned long limit); 175 167 void ksmbd_update_fstate(struct ksmbd_file_table *ft, struct ksmbd_file *fp, 176 168 unsigned int state); 169 + bool ksmbd_vfs_compare_durable_owner(struct ksmbd_file *fp, 170 + struct ksmbd_user *user); 177 171 178 172 /* 179 173 * INODE hash