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

Merge tag 'v6.19-rc-smb-fixes' of git://git.samba.org/ksmbd

Pull smb client and server updates from Steve French:

- server fixes:
- IPC use after free locking fix
- fix locking bug in delete paths
- fix use after free in disconnect
- fix underflow in locking check
- error mapping improvement
- socket listening improvement
- return code mapping fixes
- crypto improvements (use default libraries)

- cleanup patches:
- netfs
- client checkpatch cleanup
- server cleanup
- move server/client duplicate code to common code
- fix some defines to better match protocol specification

- smbdirect (RDMA) fixes

- client debugging improvements for leases

* tag 'v6.19-rc-smb-fixes' of git://git.samba.org/ksmbd: (44 commits)
cifs: Use netfs_alloc/free_folioq_buffer()
smb: client: show smb lease key in open_dirs output
smb: client: show smb lease key in open_files output
ksmbd: ipc: fix use-after-free in ipc_msg_send_request
smb: client: relax WARN_ON_ONCE(SMBDIRECT_SOCKET_*) checks in recv_done() and smbd_conn_upcall()
smb: server: relax WARN_ON_ONCE(SMBDIRECT_SOCKET_*) checks in recv_done() and smb_direct_cm_handler()
smb: smbdirect: introduce SMBDIRECT_CHECK_STATUS_{WARN,DISCONNECT}()
smb: smbdirect: introduce SMBDIRECT_DEBUG_ERR_PTR() helper
ksmbd: vfs: fix race on m_flags in vfs_cache
ksmbd: Replace strcpy + strcat to improve convert_to_nt_pathname
smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/fscc.h
ksmbd: implement error handling for STATUS_INFO_LENGTH_MISMATCH in smb server
ksmbd: fix use-after-free in ksmbd_tree_connect_put under concurrency
ksmbd: server: avoid busy polling in accept loop
smb: move create_durable_reconn to common/smb2pdu.h
smb: fix some warnings reported by scripts/checkpatch.pl
smb: do some cleanups
smb: move FILE_SYSTEM_SIZE_INFO to common/fscc.h
smb: move some duplicate struct definitions to common/fscc.h
smb: move list of FileSystemAttributes to common/fscc.h
...

+1194 -1743
+17 -6
fs/smb/client/cifs_debug.c
··· 249 249 seq_puts(m, "# Format:\n"); 250 250 seq_puts(m, "# <tree id> <ses id> <persistent fid> <flags> <count> <pid> <uid>"); 251 251 #ifdef CONFIG_CIFS_DEBUG2 252 - seq_puts(m, " <filename> <lease> <mid>\n"); 252 + seq_puts(m, " <filename> <lease> <lease-key> <mid>\n"); 253 253 #else 254 - seq_puts(m, " <filename> <lease>\n"); 254 + seq_puts(m, " <filename> <lease> <lease-key>\n"); 255 255 #endif /* CIFS_DEBUG2 */ 256 256 spin_lock(&cifs_tcp_ses_lock); 257 257 list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) { ··· 274 274 275 275 /* Append lease/oplock caching state as RHW letters */ 276 276 inode = d_inode(cfile->dentry); 277 + cinode = NULL; 277 278 n = 0; 278 279 if (inode) { 279 280 cinode = CIFS_I(inode); ··· 291 290 seq_printf(m, "%s", lease); 292 291 else 293 292 seq_puts(m, "NONE"); 293 + 294 + seq_puts(m, " "); 295 + if (cinode && cinode->lease_granted) 296 + seq_printf(m, "%pUl", cinode->lease_key); 297 + else 298 + seq_puts(m, "-"); 294 299 295 300 #ifdef CONFIG_CIFS_DEBUG2 296 301 seq_printf(m, " %llu", cfile->fid.mid); ··· 324 317 325 318 seq_puts(m, "# Version:1\n"); 326 319 seq_puts(m, "# Format:\n"); 327 - seq_puts(m, "# <tree id> <sess id> <persistent fid> <path>\n"); 320 + seq_puts(m, "# <tree id> <sess id> <persistent fid> <lease-key> <path>\n"); 328 321 329 322 spin_lock(&cifs_tcp_ses_lock); 330 323 list_for_each(stmp, &cifs_tcp_ses_list) { ··· 343 336 (unsigned long)atomic_long_read(&cfids->total_dirents_entries), 344 337 (unsigned long long)atomic64_read(&cfids->total_dirents_bytes)); 345 338 list_for_each_entry(cfid, &cfids->entries, entry) { 346 - seq_printf(m, "0x%x 0x%llx 0x%llx %s", 339 + seq_printf(m, "0x%x 0x%llx 0x%llx ", 347 340 tcon->tid, 348 341 ses->Suid, 349 - cfid->fid.persistent_fid, 350 - cfid->path); 342 + cfid->fid.persistent_fid); 343 + if (cfid->has_lease) 344 + seq_printf(m, "%pUl ", cfid->fid.lease_key); 345 + else 346 + seq_puts(m, "- "); 347 + seq_printf(m, "%s", cfid->path); 351 348 if (cfid->file_all_info_is_valid) 352 349 seq_printf(m, "\tvalid file info"); 353 350 if (cfid->dirents.is_valid)
+2 -29
fs/smb/client/cifsglob.h
··· 24 24 #include "cifsacl.h" 25 25 #include <crypto/internal/hash.h> 26 26 #include <uapi/linux/cifs/cifs_mount.h> 27 - #include "../common/cifsglob.h" 27 + #include "../common/smbglob.h" 28 28 #include "../common/smb2pdu.h" 29 + #include "../common/fscc.h" 29 30 #include "smb2pdu.h" 30 31 #include <linux/filelock.h> 31 32 ··· 634 633 struct kvec *xattr_iov); 635 634 }; 636 635 637 - struct smb_version_values { 638 - char *version_string; 639 - __u16 protocol_id; 640 - __u32 req_capabilities; 641 - __u32 large_lock_type; 642 - __u32 exclusive_lock_type; 643 - __u32 shared_lock_type; 644 - __u32 unlock_lock_type; 645 - size_t header_preamble_size; 646 - size_t header_size; 647 - size_t max_header_size; 648 - size_t read_rsp_size; 649 - __le16 lock_cmd; 650 - unsigned int cap_unix; 651 - unsigned int cap_nt_find; 652 - unsigned int cap_large_files; 653 - unsigned int cap_unicode; 654 - __u16 signing_enabled; 655 - __u16 signing_required; 656 - size_t create_lease_size; 657 - }; 658 - 659 636 #define HEADER_SIZE(server) (server->vals->header_size) 660 637 #define MAX_HEADER_SIZE(server) (server->vals->max_header_size) 661 638 #define HEADER_PREAMBLE_SIZE(server) (server->vals->header_preamble_size) ··· 670 691 struct smb3_fs_context *ctx; 671 692 int flags; 672 693 }; 673 - 674 - static inline unsigned int 675 - get_rfc1002_length(void *buf) 676 - { 677 - return be32_to_cpu(*((__be32 *)buf)) & 0xffffff; 678 - } 679 694 680 695 struct TCP_Server_Info { 681 696 struct list_head tcp_ses_list;
+166 -435
fs/smb/client/cifspdu.h
··· 12 12 #include <net/sock.h> 13 13 #include <linux/unaligned.h> 14 14 #include "../common/smbfsctl.h" 15 + #include "../common/smb2pdu.h" 15 16 16 17 #define CIFS_PROT 0 17 18 #define POSIX_PROT (CIFS_PROT+1) 18 19 #define BAD_PROT 0xFFFF 19 20 20 21 /* SMB command codes: 22 + * See MS-CIFS 2.2.2.1 21 23 * Note some commands have minimal (wct=0,bcc=0), or uninteresting, responses 22 24 * (ie which include no useful data other than the SMB error code itself). 23 25 * This can allow us to avoid response buffer allocations and copy in some cases ··· 88 86 #define NT_TRANSACT_GET_USER_QUOTA 0x07 89 87 #define NT_TRANSACT_SET_USER_QUOTA 0x08 90 88 91 - #define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */ 92 89 /* future chained NTCreateXReadX bigger, but for time being NTCreateX biggest */ 93 90 /* among the requests (NTCreateX response is bigger with wct of 34) */ 94 91 #define MAX_CIFS_HDR_SIZE 0x58 /* 4 len + 32 hdr + (2*24 wct) + 2 bct + 2 pad */ ··· 153 152 154 153 /* 155 154 * SMB flag definitions 155 + * See MS-CIFS 2.2.3.1 156 156 */ 157 157 #define SMBFLG_EXTD_LOCK 0x01 /* server supports lock-read write-unlock smb */ 158 158 #define SMBFLG_RCV_POSTED 0x02 /* obsolete */ ··· 167 165 168 166 /* 169 167 * SMB flag2 definitions 168 + * See MS-CIFS 2.2.3.1 169 + * MS-SMB 2.2.3.1 170 170 */ 171 171 #define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1) /* can send long (non-8.3) 172 172 path names in response */ ··· 184 180 #define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000) 185 181 #define SMBFLG2_UNICODE cpu_to_le16(0x8000) 186 182 187 - /* 188 - * These are the file access permission bits defined in CIFS for the 189 - * NTCreateAndX as well as the level 0x107 190 - * TRANS2_QUERY_PATH_INFORMATION API. The level 0x107, SMB_QUERY_FILE_ALL_INFO 191 - * responds with the AccessFlags. 192 - * The AccessFlags specifies the access permissions a caller has to the 193 - * file and can have any suitable combination of the following values: 194 - */ 195 - 196 - #define FILE_READ_DATA 0x00000001 /* Data can be read from the file */ 197 - /* or directory child entries can */ 198 - /* be listed together with the */ 199 - /* associated child attributes */ 200 - /* (so the FILE_READ_ATTRIBUTES on */ 201 - /* the child entry is not needed) */ 202 - #define FILE_WRITE_DATA 0x00000002 /* Data can be written to the file */ 203 - /* or new file can be created in */ 204 - /* the directory */ 205 - #define FILE_APPEND_DATA 0x00000004 /* Data can be appended to the file */ 206 - /* (for non-local files over SMB it */ 207 - /* is same as FILE_WRITE_DATA) */ 208 - /* or new subdirectory can be */ 209 - /* created in the directory */ 210 - #define FILE_READ_EA 0x00000008 /* Extended attributes associated */ 211 - /* with the file can be read */ 212 - #define FILE_WRITE_EA 0x00000010 /* Extended attributes associated */ 213 - /* with the file can be written */ 214 - #define FILE_EXECUTE 0x00000020 /*Data can be read into memory from */ 215 - /* the file using system paging I/O */ 216 - /* for executing the file / script */ 217 - /* or right to traverse directory */ 218 - /* (but by default all users have */ 219 - /* directory bypass traverse */ 220 - /* privilege and do not need this */ 221 - /* permission on directories at all)*/ 222 - #define FILE_DELETE_CHILD 0x00000040 /* Child entry can be deleted from */ 223 - /* the directory (so the DELETE on */ 224 - /* the child entry is not needed) */ 225 - #define FILE_READ_ATTRIBUTES 0x00000080 /* Attributes associated with the */ 226 - /* file or directory can be read */ 227 - #define FILE_WRITE_ATTRIBUTES 0x00000100 /* Attributes associated with the */ 228 - /* file or directory can be written */ 229 - #define DELETE 0x00010000 /* The file or dir can be deleted */ 230 - #define READ_CONTROL 0x00020000 /* The discretionary access control */ 231 - /* list and ownership associated */ 232 - /* with the file or dir can be read */ 233 - #define WRITE_DAC 0x00040000 /* The discretionary access control */ 234 - /* list associated with the file or */ 235 - /* directory can be written */ 236 - #define WRITE_OWNER 0x00080000 /* Ownership information associated */ 237 - /* with the file/dir can be written */ 238 - #define SYNCHRONIZE 0x00100000 /* The file handle can waited on to */ 239 - /* synchronize with the completion */ 240 - /* of an input/output request */ 241 - #define SYSTEM_SECURITY 0x01000000 /* The system access control list */ 242 - /* associated with the file or */ 243 - /* directory can be read or written */ 244 - /* (cannot be in DACL, can in SACL) */ 245 - #define MAXIMUM_ALLOWED 0x02000000 /* Maximal subset of GENERIC_ALL */ 246 - /* permissions which can be granted */ 247 - /* (cannot be in DACL nor SACL) */ 248 - #define GENERIC_ALL 0x10000000 /* Same as: GENERIC_EXECUTE | */ 249 - /* GENERIC_WRITE | */ 250 - /* GENERIC_READ | */ 251 - /* FILE_DELETE_CHILD | */ 252 - /* DELETE | */ 253 - /* WRITE_DAC | */ 254 - /* WRITE_OWNER */ 255 - /* So GENERIC_ALL contains all bits */ 256 - /* mentioned above except these two */ 257 - /* SYSTEM_SECURITY MAXIMUM_ALLOWED */ 258 - #define GENERIC_EXECUTE 0x20000000 /* Same as: FILE_EXECUTE | */ 259 - /* FILE_READ_ATTRIBUTES | */ 260 - /* READ_CONTROL | */ 261 - /* SYNCHRONIZE */ 262 - #define GENERIC_WRITE 0x40000000 /* Same as: FILE_WRITE_DATA | */ 263 - /* FILE_APPEND_DATA | */ 264 - /* FILE_WRITE_EA | */ 265 - /* FILE_WRITE_ATTRIBUTES | */ 266 - /* READ_CONTROL | */ 267 - /* SYNCHRONIZE */ 268 - #define GENERIC_READ 0x80000000 /* Same as: FILE_READ_DATA | */ 269 - /* FILE_READ_EA | */ 270 - /* FILE_READ_ATTRIBUTES | */ 271 - /* READ_CONTROL | */ 272 - /* SYNCHRONIZE */ 273 - 274 - #define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES) 275 - #define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \ 276 - | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES) 277 - #define FILE_EXEC_RIGHTS (FILE_EXECUTE) 278 - 183 + /* Combinations of file access permission bits */ 279 184 #define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_WRITE_EA \ 280 185 | FILE_READ_ATTRIBUTES \ 281 186 | FILE_WRITE_ATTRIBUTES \ ··· 196 283 | FILE_WRITE_ATTRIBUTES \ 197 284 | DELETE | READ_CONTROL | WRITE_DAC \ 198 285 | WRITE_OWNER | SYNCHRONIZE) 199 - #define SET_FILE_EXEC_RIGHTS (FILE_READ_EA | FILE_WRITE_EA | FILE_EXECUTE \ 200 - | FILE_READ_ATTRIBUTES \ 201 - | FILE_WRITE_ATTRIBUTES \ 202 - | DELETE | READ_CONTROL | WRITE_DAC \ 203 - | WRITE_OWNER | SYNCHRONIZE) 204 - 205 - #define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \ 206 - | READ_CONTROL | SYNCHRONIZE) 207 - 208 286 209 287 /* 210 288 * Invalid readdir handle ··· 229 325 /* 230 326 * File Attribute flags 231 327 */ 232 - #define ATTR_READONLY 0x0001 233 - #define ATTR_HIDDEN 0x0002 234 - #define ATTR_SYSTEM 0x0004 235 - #define ATTR_VOLUME 0x0008 236 - #define ATTR_DIRECTORY 0x0010 237 - #define ATTR_ARCHIVE 0x0020 238 - #define ATTR_DEVICE 0x0040 239 - #define ATTR_NORMAL 0x0080 240 - #define ATTR_TEMPORARY 0x0100 241 - #define ATTR_SPARSE 0x0200 242 - #define ATTR_REPARSE 0x0400 243 - #define ATTR_COMPRESSED 0x0800 244 - #define ATTR_OFFLINE 0x1000 /* ie file not immediately available - 245 - on offline storage */ 246 - #define ATTR_NOT_CONTENT_INDEXED 0x2000 247 - #define ATTR_ENCRYPTED 0x4000 248 - #define ATTR_POSIX_SEMANTICS 0x01000000 249 - #define ATTR_BACKUP_SEMANTICS 0x02000000 250 - #define ATTR_DELETE_ON_CLOSE 0x04000000 251 - #define ATTR_SEQUENTIAL_SCAN 0x08000000 252 - #define ATTR_RANDOM_ACCESS 0x10000000 253 - #define ATTR_NO_BUFFERING 0x20000000 254 - #define ATTR_WRITE_THROUGH 0x80000000 328 + #define ATTR_READONLY 0x0001 /* See MS-CIFS 2.2.1.2.3 */ 329 + #define ATTR_HIDDEN 0x0002 /* See MS-CIFS 2.2.1.2.3 */ 330 + #define ATTR_SYSTEM 0x0004 /* See MS-CIFS 2.2.1.2.3 */ 331 + #define ATTR_VOLUME 0x0008 332 + #define ATTR_DIRECTORY 0x0010 /* See MS-CIFS 2.2.1.2.3 */ 333 + #define ATTR_ARCHIVE 0x0020 /* See MS-CIFS 2.2.1.2.3 */ 334 + #define ATTR_DEVICE 0x0040 335 + #define ATTR_NORMAL 0x0080 /* See MS-CIFS 2.2.1.2.3 */ 336 + #define ATTR_TEMPORARY 0x0100 /* See MS-CIFS 2.2.1.2.3 */ 337 + #define ATTR_SPARSE 0x0200 /* See MS-SMB 2.2.1.2.1 */ 338 + #define ATTR_REPARSE_POINT 0x0400 /* See MS-SMB 2.2.1.2.1 */ 339 + #define ATTR_COMPRESSED 0x0800 /* See MS-CIFS 2.2.1.2.3 */ 340 + #define ATTR_OFFLINE 0x1000 /* See MS-SMB 2.2.1.2.1 341 + ie file not immediately available - 342 + on offline storage */ 343 + #define ATTR_NOT_CONTENT_INDEXED 0x2000 /* See MS-SMB 2.2.1.2.1 */ 344 + #define ATTR_ENCRYPTED 0x4000 /* See MS-SMB 2.2.1.2.1 */ 345 + #define ATTR_POSIX_SEMANTICS 0x0100000 /* See MS-CIFS 2.2.1.2.3 */ 346 + #define ATTR_BACKUP_SEMANTICS 0x0200000 /* See MS-CIFS 2.2.1.2.3 */ 347 + #define ATTR_DELETE_ON_CLOSE 0x0400000 /* See MS-CIFS 2.2.1.2.3 */ 348 + #define ATTR_SEQUENTIAL_SCAN 0x0800000 /* See MS-CIFS 2.2.1.2.3 */ 349 + #define ATTR_RANDOM_ACCESS 0x1000000 /* See MS-CIFS 2.2.1.2.3 */ 350 + #define ATTR_NO_BUFFERING 0x2000000 /* See MS-CIFS 2.2.1.2.3 */ 351 + #define ATTR_WRITE_THROUGH 0x8000000 /* See MS-CIFS 2.2.1.2.3 */ 255 352 256 353 /* ShareAccess flags */ 257 354 #define FILE_NO_SHARE 0x00000000 ··· 321 416 322 417 #define GETU16(var) (*((__u16 *)var)) /* BB check for endian issues */ 323 418 #define GETU32(var) (*((__u32 *)var)) /* BB check for endian issues */ 324 - 325 - struct smb_hdr { 326 - __be32 smb_buf_length; /* BB length is only two (rarely three) bytes, 327 - with one or two byte "type" preceding it that will be 328 - zero - we could mask the type byte off */ 329 - __u8 Protocol[4]; 330 - __u8 Command; 331 - union { 332 - struct { 333 - __u8 ErrorClass; 334 - __u8 Reserved; 335 - __le16 Error; 336 - } __attribute__((packed)) DosError; 337 - __le32 CifsError; 338 - } __attribute__((packed)) Status; 339 - __u8 Flags; 340 - __le16 Flags2; /* note: le */ 341 - __le16 PidHigh; 342 - union { 343 - struct { 344 - __le32 SequenceNumber; /* le */ 345 - __u32 Reserved; /* zero */ 346 - } __attribute__((packed)) Sequence; 347 - __u8 SecuritySignature[8]; /* le */ 348 - } __attribute__((packed)) Signature; 349 - __u8 pad[2]; 350 - __u16 Tid; 351 - __le16 Pid; 352 - __u16 Uid; 353 - __le16 Mid; 354 - __u8 WordCount; 355 - } __attribute__((packed)); 356 419 357 420 /* given a pointer to an smb_hdr, retrieve a void pointer to the ByteCount */ 358 421 static inline void * ··· 393 520 * 394 521 */ 395 522 396 - typedef struct negotiate_req { 397 - struct smb_hdr hdr; /* wct = 0 */ 398 - __le16 ByteCount; 399 - unsigned char DialectsArray[]; 400 - } __attribute__((packed)) NEGOTIATE_REQ; 401 - 402 523 #define MIN_TZ_ADJ (15 * 60) /* minimum grid for timezones in seconds */ 403 524 404 525 #define READ_RAW_ENABLE 1 405 526 #define WRITE_RAW_ENABLE 2 406 527 #define RAW_ENABLE (READ_RAW_ENABLE | WRITE_RAW_ENABLE) 407 528 #define SMB1_CLIENT_GUID_SIZE (16) 408 - typedef struct negotiate_rsp { 529 + 530 + /* See MS-CIFS 2.2.4.52.2 */ 531 + typedef struct smb_negotiate_rsp { 409 532 struct smb_hdr hdr; /* wct = 17 */ 410 533 __le16 DialectIndex; /* 0xFFFF = no dialect acceptable */ 411 534 __u8 SecurityMode; ··· 425 556 struct { 426 557 unsigned char GUID[SMB1_CLIENT_GUID_SIZE]; 427 558 unsigned char SecurityBlob[]; 428 - } __attribute__((packed)) extended_response; 429 - } __attribute__((packed)) u; 430 - } __attribute__((packed)) NEGOTIATE_RSP; 559 + } __packed extended_response; 560 + } __packed u; 561 + } __packed SMB_NEGOTIATE_RSP; 431 562 432 563 /* SecurityMode bits */ 433 564 #define SECMODE_USER 0x01 /* off indicates share level security */ ··· 474 605 unsigned char SecurityBlob[]; /* followed by */ 475 606 /* STRING NativeOS */ 476 607 /* STRING NativeLanMan */ 477 - } __attribute__((packed)) req; /* NTLM request format (with 608 + } __packed req; /* NTLM request format (with 478 609 extended security */ 479 610 480 611 struct { /* request format */ ··· 497 628 /* STRING PrimaryDomain */ 498 629 /* STRING NativeOS */ 499 630 /* STRING NativeLanMan */ 500 - } __attribute__((packed)) req_no_secext; /* NTLM request format (without 631 + } __packed req_no_secext; /* NTLM request format (without 501 632 extended security */ 502 633 503 634 struct { /* default (NTLM) response format */ ··· 512 643 /* unsigned char * NativeOS; */ 513 644 /* unsigned char * NativeLanMan; */ 514 645 /* unsigned char * PrimaryDomain; */ 515 - } __attribute__((packed)) resp; /* NTLM response 646 + } __packed resp; /* NTLM response 516 647 (with or without extended sec) */ 517 648 518 649 struct { /* request format */ ··· 532 663 /* STRING PrimaryDomain */ 533 664 /* STRING NativeOS */ 534 665 /* STRING NativeLanMan */ 535 - } __attribute__((packed)) old_req; /* pre-NTLM (LANMAN2.1) req format */ 666 + } __packed old_req; /* pre-NTLM (LANMAN2.1) req format */ 536 667 537 668 struct { /* default (NTLM) response format */ 538 669 struct smb_hdr hdr; /* wct = 3 */ ··· 544 675 unsigned char NativeOS[]; /* followed by */ 545 676 /* unsigned char * NativeLanMan; */ 546 677 /* unsigned char * PrimaryDomain; */ 547 - } __attribute__((packed)) old_resp; /* pre-NTLM (LANMAN2.1) response */ 548 - } __attribute__((packed)) SESSION_SETUP_ANDX; 678 + } __packed old_resp; /* pre-NTLM (LANMAN2.1) response */ 679 + } __packed SESSION_SETUP_ANDX; 549 680 550 681 /* format of NLTMv2 Response ie "case sensitive password" hash when NTLMv2 */ 551 682 ··· 559 690 __le16 type; 560 691 __le16 length; 561 692 __u8 data[]; 562 - } __attribute__((packed)); 693 + } __packed; 563 694 564 695 struct ntlmv2_resp { 565 696 union { ··· 567 698 struct { 568 699 __u8 reserved[8]; 569 700 __u8 key[CIFS_SERVER_CHALLENGE_SIZE]; 570 - } __attribute__((packed)) challenge; 571 - } __attribute__((packed)); 701 + } __packed challenge; 702 + } __packed; 572 703 __le32 blob_signature; 573 704 __u32 reserved; 574 705 __le64 time; 575 706 __u64 client_chal; /* random */ 576 707 __u32 reserved2; 577 708 /* array of name entries could follow ending in minimum 4 byte struct */ 578 - } __attribute__((packed)); 709 + } __packed; 579 710 580 711 581 712 #define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux" 582 713 583 - /* Capabilities bits (for NTLM SessSetup request) */ 714 + 715 + /* 716 + * Capabilities bits (for NTLM SessSetup request) 717 + * See MS-CIFS 2.2.4.52.2 718 + * MS-SMB 2.2.4.5.2.1 719 + */ 584 720 #define CAP_UNICODE 0x00000004 585 721 #define CAP_LARGE_FILES 0x00000008 586 722 #define CAP_NT_SMBS 0x00000010 ··· 593 719 #define CAP_LEVEL_II_OPLOCKS 0x00000080 594 720 #define CAP_NT_FIND 0x00000200 /* reserved should be zero 595 721 (because NT_SMBs implies the same thing?) */ 596 - #define CAP_BULK_TRANSFER 0x20000000 722 + #define CAP_BULK_TRANSFER 0x00000400 597 723 #define CAP_EXTENDED_SECURITY 0x80000000 598 724 599 725 /* Action bits */ ··· 610 736 unsigned char Password[]; /* followed by */ 611 737 /* STRING Path *//* \\server\share name */ 612 738 /* STRING Service */ 613 - } __attribute__((packed)) TCONX_REQ; 739 + } __packed TCONX_REQ; 614 740 615 741 typedef struct smb_com_tconx_rsp { 616 742 struct smb_hdr hdr; /* wct = 3 , not extended response */ ··· 621 747 __u16 ByteCount; 622 748 unsigned char Service[]; /* always ASCII, not Unicode */ 623 749 /* STRING NativeFileSystem */ 624 - } __attribute__((packed)) TCONX_RSP; 750 + } __packed TCONX_RSP; 625 751 626 752 typedef struct smb_com_tconx_rsp_ext { 627 753 struct smb_hdr hdr; /* wct = 7, extended response */ ··· 634 760 __u16 ByteCount; 635 761 unsigned char Service[]; /* always ASCII, not Unicode */ 636 762 /* STRING NativeFileSystem */ 637 - } __attribute__((packed)) TCONX_RSP_EXT; 763 + } __packed TCONX_RSP_EXT; 638 764 639 765 640 766 /* tree connect Flags */ ··· 670 796 __le16 EchoCount; 671 797 __le16 ByteCount; 672 798 char Data[]; 673 - } __attribute__((packed)) ECHO_REQ; 799 + } __packed ECHO_REQ; 674 800 675 801 typedef struct smb_com_echo_rsp { 676 802 struct smb_hdr hdr; 677 803 __le16 SequenceNumber; 678 804 __le16 ByteCount; 679 805 char Data[]; 680 - } __attribute__((packed)) ECHO_RSP; 806 + } __packed ECHO_RSP; 681 807 682 808 typedef struct smb_com_logoff_andx_req { 683 809 struct smb_hdr hdr; /* wct = 2 */ ··· 685 811 __u8 AndXReserved; 686 812 __u16 AndXOffset; 687 813 __u16 ByteCount; 688 - } __attribute__((packed)) LOGOFF_ANDX_REQ; 814 + } __packed LOGOFF_ANDX_REQ; 689 815 690 816 typedef struct smb_com_logoff_andx_rsp { 691 817 struct smb_hdr hdr; /* wct = 2 */ ··· 693 819 __u8 AndXReserved; 694 820 __u16 AndXOffset; 695 821 __u16 ByteCount; 696 - } __attribute__((packed)) LOGOFF_ANDX_RSP; 822 + } __packed LOGOFF_ANDX_RSP; 697 823 698 824 typedef union smb_com_tree_disconnect { /* as an alternative can use flag on 699 825 tree_connect PDU to effect disconnect */ ··· 701 827 struct { 702 828 struct smb_hdr hdr; /* wct = 0 */ 703 829 __u16 ByteCount; /* bcc = 0 */ 704 - } __attribute__((packed)) req; 830 + } __packed req; 705 831 struct { 706 832 struct smb_hdr hdr; /* wct = 0 */ 707 833 __u16 ByteCount; /* bcc = 0 */ 708 - } __attribute__((packed)) resp; 709 - } __attribute__((packed)) TREE_DISCONNECT; 834 + } __packed resp; 835 + } __packed TREE_DISCONNECT; 710 836 711 837 typedef struct smb_com_close_req { 712 838 struct smb_hdr hdr; /* wct = 3 */ 713 839 __u16 FileID; 714 840 __u32 LastWriteTime; /* should be zero or -1 */ 715 841 __u16 ByteCount; /* 0 */ 716 - } __attribute__((packed)) CLOSE_REQ; 842 + } __packed CLOSE_REQ; 717 843 718 844 typedef struct smb_com_close_rsp { 719 845 struct smb_hdr hdr; /* wct = 0 */ 720 846 __u16 ByteCount; /* bct = 0 */ 721 - } __attribute__((packed)) CLOSE_RSP; 847 + } __packed CLOSE_RSP; 722 848 723 849 typedef struct smb_com_flush_req { 724 850 struct smb_hdr hdr; /* wct = 1 */ 725 851 __u16 FileID; 726 852 __u16 ByteCount; /* 0 */ 727 - } __attribute__((packed)) FLUSH_REQ; 853 + } __packed FLUSH_REQ; 728 854 729 855 typedef struct smb_com_findclose_req { 730 856 struct smb_hdr hdr; /* wct = 1 */ 731 857 __u16 FileID; 732 858 __u16 ByteCount; /* 0 */ 733 - } __attribute__((packed)) FINDCLOSE_REQ; 859 + } __packed FINDCLOSE_REQ; 734 860 735 861 /* OpenFlags */ 736 862 #define REQ_MORE_INFO 0x00000001 /* legacy (OPEN_AND_X) only */ ··· 777 903 __u8 SecurityFlags; 778 904 __le16 ByteCount; 779 905 char fileName[]; 780 - } __attribute__((packed)) OPEN_REQ; 906 + } __packed OPEN_REQ; 781 907 782 908 /* open response: oplock levels */ 783 909 #define OPLOCK_NONE 0 ··· 809 935 __le16 DeviceState; 810 936 __u8 DirectoryFlag; 811 937 __u16 ByteCount; /* bct = 0 */ 812 - } __attribute__((packed)) OPEN_RSP; 938 + } __packed OPEN_RSP; 813 939 814 940 typedef struct smb_com_open_rsp_ext { 815 941 struct smb_hdr hdr; /* wct = 42 but meaningless due to MS bug? */ ··· 834 960 __le32 MaximalAccessRights; 835 961 __le32 GuestMaximalAccessRights; 836 962 __u16 ByteCount; /* bct = 0 */ 837 - } __attribute__((packed)) OPEN_RSP_EXT; 963 + } __packed OPEN_RSP_EXT; 838 964 839 965 840 966 /* format of legacy open request */ ··· 854 980 __le32 Reserved; 855 981 __le16 ByteCount; /* file name follows */ 856 982 char fileName[]; 857 - } __attribute__((packed)) OPENX_REQ; 983 + } __packed OPENX_REQ; 858 984 859 985 typedef struct smb_com_openx_rsp { 860 986 struct smb_hdr hdr; /* wct = 15 */ ··· 872 998 __u32 FileId; 873 999 __u16 Reserved; 874 1000 __u16 ByteCount; 875 - } __attribute__((packed)) OPENX_RSP; 1001 + } __packed OPENX_RSP; 876 1002 877 1003 /* For encoding of POSIX Open Request - see trans2 function 0x209 data struct */ 878 1004 ··· 894 1020 __u8 Pad; /* BB check for whether padded to DWORD 895 1021 boundary and optimum performance here */ 896 1022 char Data[]; 897 - } __attribute__((packed)) WRITEX_REQ; 1023 + } __packed WRITEX_REQ; 898 1024 899 1025 typedef struct smb_com_write_req { 900 1026 struct smb_hdr hdr; /* wct = 14 */ ··· 914 1040 __u8 Pad; /* BB check for whether padded to DWORD 915 1041 boundary and optimum performance here */ 916 1042 char Data[]; 917 - } __attribute__((packed)) WRITE_REQ; 1043 + } __packed WRITE_REQ; 918 1044 919 1045 typedef struct smb_com_write_rsp { 920 1046 struct smb_hdr hdr; /* wct = 6 */ ··· 926 1052 __le16 CountHigh; 927 1053 __u16 Reserved; 928 1054 __u16 ByteCount; 929 - } __attribute__((packed)) WRITE_RSP; 1055 + } __packed WRITE_RSP; 930 1056 931 1057 /* legacy read request for older servers */ 932 1058 typedef struct smb_com_readx_req { ··· 941 1067 __le32 Reserved; 942 1068 __le16 Remaining; 943 1069 __le16 ByteCount; 944 - } __attribute__((packed)) READX_REQ; 1070 + } __packed READX_REQ; 945 1071 946 1072 typedef struct smb_com_read_req { 947 1073 struct smb_hdr hdr; /* wct = 12 */ ··· 956 1082 __le16 Remaining; 957 1083 __le32 OffsetHigh; 958 1084 __le16 ByteCount; 959 - } __attribute__((packed)) READ_REQ; 1085 + } __packed READ_REQ; 960 1086 961 1087 typedef struct smb_com_read_rsp { 962 1088 struct smb_hdr hdr; /* wct = 12 */ ··· 972 1098 __u64 Reserved2; 973 1099 __u16 ByteCount; 974 1100 /* read response data immediately follows */ 975 - } __attribute__((packed)) READ_RSP; 1101 + } __packed READ_RSP; 976 1102 977 1103 typedef struct locking_andx_range { 978 1104 __le16 Pid; ··· 981 1107 __le32 OffsetLow; 982 1108 __le32 LengthHigh; 983 1109 __le32 LengthLow; 984 - } __attribute__((packed)) LOCKING_ANDX_RANGE; 1110 + } __packed LOCKING_ANDX_RANGE; 985 1111 986 1112 #define LOCKING_ANDX_SHARED_LOCK 0x01 987 1113 #define LOCKING_ANDX_OPLOCK_RELEASE 0x02 ··· 1002 1128 __le16 NumberOfLocks; 1003 1129 __le16 ByteCount; 1004 1130 LOCKING_ANDX_RANGE Locks[]; 1005 - } __attribute__((packed)) LOCK_REQ; 1131 + } __packed LOCK_REQ; 1006 1132 1007 1133 /* lock type */ 1008 1134 #define CIFS_RDLCK 0 ··· 1015 1141 __le64 start; 1016 1142 __le64 length; 1017 1143 /* BB what about additional owner info to identify network client */ 1018 - } __attribute__((packed)) CIFS_POSIX_LOCK; 1144 + } __packed CIFS_POSIX_LOCK; 1019 1145 1020 1146 typedef struct smb_com_lock_rsp { 1021 1147 struct smb_hdr hdr; /* wct = 2 */ ··· 1023 1149 __u8 AndXReserved; 1024 1150 __le16 AndXOffset; 1025 1151 __u16 ByteCount; 1026 - } __attribute__((packed)) LOCK_RSP; 1152 + } __packed LOCK_RSP; 1027 1153 1028 1154 typedef struct smb_com_rename_req { 1029 1155 struct smb_hdr hdr; /* wct = 1 */ ··· 1033 1159 unsigned char OldFileName[]; 1034 1160 /* followed by __u8 BufferFormat2 */ 1035 1161 /* followed by NewFileName */ 1036 - } __attribute__((packed)) RENAME_REQ; 1162 + } __packed RENAME_REQ; 1037 1163 1038 1164 /* copy request flags */ 1039 1165 #define COPY_MUST_BE_FILE 0x0001 ··· 1053 1179 unsigned char OldFileName[]; 1054 1180 /* followed by __u8 BufferFormat2 */ 1055 1181 /* followed by NewFileName string */ 1056 - } __attribute__((packed)) COPY_REQ; 1182 + } __packed COPY_REQ; 1057 1183 1058 1184 typedef struct smb_com_copy_rsp { 1059 1185 struct smb_hdr hdr; /* wct = 1 */ ··· 1061 1187 __u16 ByteCount; /* may be zero */ 1062 1188 __u8 BufferFormat; /* 0x04 - only present if errored file follows */ 1063 1189 unsigned char ErrorFileName[]; /* only present if error in copy */ 1064 - } __attribute__((packed)) COPY_RSP; 1190 + } __packed COPY_RSP; 1065 1191 1066 1192 #define CREATE_HARD_LINK 0x103 1067 1193 #define MOVEFILE_COPY_ALLOWED 0x0002 ··· 1077 1203 unsigned char OldFileName[]; 1078 1204 /* followed by __u8 BufferFormat2 */ 1079 1205 /* followed by NewFileName */ 1080 - } __attribute__((packed)) NT_RENAME_REQ; 1206 + } __packed NT_RENAME_REQ; 1081 1207 1082 1208 typedef struct smb_com_rename_rsp { 1083 1209 struct smb_hdr hdr; /* wct = 0 */ 1084 1210 __u16 ByteCount; /* bct = 0 */ 1085 - } __attribute__((packed)) RENAME_RSP; 1211 + } __packed RENAME_RSP; 1086 1212 1087 1213 typedef struct smb_com_delete_file_req { 1088 1214 struct smb_hdr hdr; /* wct = 1 */ ··· 1090 1216 __le16 ByteCount; 1091 1217 __u8 BufferFormat; /* 4 = ASCII */ 1092 1218 unsigned char fileName[]; 1093 - } __attribute__((packed)) DELETE_FILE_REQ; 1219 + } __packed DELETE_FILE_REQ; 1094 1220 1095 1221 typedef struct smb_com_delete_file_rsp { 1096 1222 struct smb_hdr hdr; /* wct = 0 */ 1097 1223 __u16 ByteCount; /* bct = 0 */ 1098 - } __attribute__((packed)) DELETE_FILE_RSP; 1224 + } __packed DELETE_FILE_RSP; 1099 1225 1100 1226 typedef struct smb_com_delete_directory_req { 1101 1227 struct smb_hdr hdr; /* wct = 0 */ 1102 1228 __le16 ByteCount; 1103 1229 __u8 BufferFormat; /* 4 = ASCII */ 1104 1230 unsigned char DirName[]; 1105 - } __attribute__((packed)) DELETE_DIRECTORY_REQ; 1231 + } __packed DELETE_DIRECTORY_REQ; 1106 1232 1107 1233 typedef struct smb_com_delete_directory_rsp { 1108 1234 struct smb_hdr hdr; /* wct = 0 */ 1109 1235 __u16 ByteCount; /* bct = 0 */ 1110 - } __attribute__((packed)) DELETE_DIRECTORY_RSP; 1236 + } __packed DELETE_DIRECTORY_RSP; 1111 1237 1112 1238 typedef struct smb_com_create_directory_req { 1113 1239 struct smb_hdr hdr; /* wct = 0 */ 1114 1240 __le16 ByteCount; 1115 1241 __u8 BufferFormat; /* 4 = ASCII */ 1116 1242 unsigned char DirName[]; 1117 - } __attribute__((packed)) CREATE_DIRECTORY_REQ; 1243 + } __packed CREATE_DIRECTORY_REQ; 1118 1244 1119 1245 typedef struct smb_com_create_directory_rsp { 1120 1246 struct smb_hdr hdr; /* wct = 0 */ 1121 1247 __u16 ByteCount; /* bct = 0 */ 1122 - } __attribute__((packed)) CREATE_DIRECTORY_RSP; 1248 + } __packed CREATE_DIRECTORY_RSP; 1123 1249 1124 1250 typedef struct smb_com_query_information_req { 1125 1251 struct smb_hdr hdr; /* wct = 0 */ 1126 1252 __le16 ByteCount; /* 1 + namelen + 1 */ 1127 1253 __u8 BufferFormat; /* 4 = ASCII */ 1128 1254 unsigned char FileName[]; 1129 - } __attribute__((packed)) QUERY_INFORMATION_REQ; 1255 + } __packed QUERY_INFORMATION_REQ; 1130 1256 1131 1257 typedef struct smb_com_query_information_rsp { 1132 1258 struct smb_hdr hdr; /* wct = 10 */ ··· 1135 1261 __le32 size; 1136 1262 __u16 reserved[5]; 1137 1263 __le16 ByteCount; /* bcc = 0 */ 1138 - } __attribute__((packed)) QUERY_INFORMATION_RSP; 1264 + } __packed QUERY_INFORMATION_RSP; 1139 1265 1140 1266 typedef struct smb_com_setattr_req { 1141 1267 struct smb_hdr hdr; /* wct = 8 */ ··· 1145 1271 __le16 ByteCount; 1146 1272 __u8 BufferFormat; /* 4 = ASCII */ 1147 1273 unsigned char fileName[]; 1148 - } __attribute__((packed)) SETATTR_REQ; 1274 + } __packed SETATTR_REQ; 1149 1275 1150 1276 typedef struct smb_com_setattr_rsp { 1151 1277 struct smb_hdr hdr; /* wct = 0 */ 1152 1278 __u16 ByteCount; /* bct = 0 */ 1153 - } __attribute__((packed)) SETATTR_RSP; 1279 + } __packed SETATTR_RSP; 1154 1280 1155 1281 /* empty wct response to setattr */ 1156 1282 ··· 1178 1304 __le16 ByteCount; 1179 1305 __u8 Pad[3]; 1180 1306 __u8 Parms[]; 1181 - } __attribute__((packed)) NTRANSACT_REQ; 1307 + } __packed NTRANSACT_REQ; 1182 1308 1183 1309 typedef struct smb_com_ntransact_rsp { 1184 1310 struct smb_hdr hdr; /* wct = 18 */ ··· 1195 1321 __u16 ByteCount; 1196 1322 /* __u8 Pad[3]; */ 1197 1323 /* parms and data follow */ 1198 - } __attribute__((packed)) NTRANSACT_RSP; 1199 - 1200 - /* See MS-SMB 2.2.7.2.1.1 */ 1201 - struct srv_copychunk { 1202 - __le64 SourceOffset; 1203 - __le64 DestinationOffset; 1204 - __le32 CopyLength; 1205 - __u32 Reserved; 1206 - } __packed; 1324 + } __packed NTRANSACT_RSP; 1207 1325 1208 1326 typedef struct smb_com_transaction_ioctl_req { 1209 1327 struct smb_hdr hdr; /* wct = 23 */ ··· 1219 1353 __le16 ByteCount; 1220 1354 __u8 Pad[3]; 1221 1355 __u8 Data[]; 1222 - } __attribute__((packed)) TRANSACT_IOCTL_REQ; 1356 + } __packed TRANSACT_IOCTL_REQ; 1223 1357 1224 1358 typedef struct smb_com_transaction_compr_ioctl_req { 1225 1359 struct smb_hdr hdr; /* wct = 23 */ ··· 1243 1377 __le16 ByteCount; 1244 1378 __u8 Pad[3]; 1245 1379 __le16 compression_state; /* See below for valid flags */ 1246 - } __attribute__((packed)) TRANSACT_COMPR_IOCTL_REQ; 1380 + } __packed TRANSACT_COMPR_IOCTL_REQ; 1247 1381 1248 1382 /* compression state flags */ 1249 1383 #define COMPRESSION_FORMAT_NONE 0x0000 ··· 1264 1398 __u8 SetupCount; /* 1 */ 1265 1399 __le16 ReturnedDataLen; 1266 1400 __le16 ByteCount; 1267 - } __attribute__((packed)) TRANSACT_IOCTL_RSP; 1401 + } __packed TRANSACT_IOCTL_RSP; 1268 1402 1269 1403 #define CIFS_ACL_OWNER 1 1270 1404 #define CIFS_ACL_GROUP 2 ··· 1291 1425 __u16 Fid; 1292 1426 __u16 Reserved2; 1293 1427 __le32 AclFlags; 1294 - } __attribute__((packed)) QUERY_SEC_DESC_REQ; 1428 + } __packed QUERY_SEC_DESC_REQ; 1295 1429 1296 1430 1297 1431 typedef struct smb_com_transaction_ssec_req { ··· 1314 1448 __u16 Fid; 1315 1449 __u16 Reserved2; 1316 1450 __le32 AclFlags; 1317 - } __attribute__((packed)) SET_SEC_DESC_REQ; 1451 + } __packed SET_SEC_DESC_REQ; 1318 1452 1319 1453 typedef struct smb_com_transaction_change_notify_req { 1320 1454 struct smb_hdr hdr; /* wct = 23 */ ··· 1338 1472 __le16 ByteCount; 1339 1473 /* __u8 Pad[3];*/ 1340 1474 /* __u8 Data[];*/ 1341 - } __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_REQ; 1475 + } __packed TRANSACT_CHANGE_NOTIFY_REQ; 1342 1476 1343 1477 /* BB eventually change to use generic ntransact rsp struct 1344 1478 and validation routine */ ··· 1356 1490 __u8 SetupCount; /* 0 */ 1357 1491 __u16 ByteCount; 1358 1492 /* __u8 Pad[3]; */ 1359 - } __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_RSP; 1493 + } __packed TRANSACT_CHANGE_NOTIFY_RSP; 1360 1494 /* Completion Filter flags for Notify */ 1361 1495 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001 1362 1496 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002 ··· 1387 1521 __le32 Action; 1388 1522 __le32 FileNameLength; 1389 1523 __u8 FileName[]; 1390 - } __attribute__((packed)); 1524 + } __packed; 1391 1525 1392 1526 struct cifs_quota_data { 1393 1527 __u32 rsrvd1; /* 0 */ ··· 1397 1531 __u64 soft_limit; 1398 1532 __u64 hard_limit; 1399 1533 char sid[]; /* variable size? */ 1400 - } __attribute__((packed)); 1534 + } __packed; 1401 1535 1402 1536 /* quota sub commands */ 1403 1537 #define QUOTA_LIST_CONTINUE 0 ··· 1423 1557 __u8 Reserved3; 1424 1558 __le16 SubCommand; /* 1st setup word - SetupCount words follow */ 1425 1559 __le16 ByteCount; 1426 - } __attribute__((packed)); 1560 + } __packed; 1427 1561 1428 1562 struct smb_t2_req { 1429 1563 struct smb_hdr hdr; 1430 1564 struct trans2_req t2_req; 1431 - } __attribute__((packed)); 1565 + } __packed; 1432 1566 1433 1567 struct trans2_resp { 1434 1568 /* struct smb_hdr hdr precedes. Note wct = 10 + setup count */ ··· 1447 1581 __u16 ByteCount; 1448 1582 __u16 Reserved2;*/ 1449 1583 /* data area follows */ 1450 - } __attribute__((packed)); 1584 + } __packed; 1451 1585 1452 1586 struct smb_t2_rsp { 1453 1587 struct smb_hdr hdr; 1454 1588 struct trans2_resp t2_rsp; 1455 - } __attribute__((packed)); 1589 + } __packed; 1456 1590 1457 1591 /* PathInfo/FileInfo infolevels */ 1458 1592 #define SMB_INFO_STANDARD 1 ··· 1549 1683 __le16 InformationLevel; 1550 1684 __u32 Reserved4; 1551 1685 char FileName[]; 1552 - } __attribute__((packed)) TRANSACTION2_QPI_REQ; 1686 + } __packed TRANSACTION2_QPI_REQ; 1553 1687 1554 1688 typedef struct smb_com_transaction2_qpi_rsp { 1555 1689 struct smb_hdr hdr; /* wct = 10 + SetupCount */ 1556 1690 struct trans2_resp t2; 1557 1691 __u16 ByteCount; 1558 1692 __u16 Reserved2; /* parameter word is present for infolevels > 100 */ 1559 - } __attribute__((packed)) TRANSACTION2_QPI_RSP; 1693 + } __packed TRANSACTION2_QPI_RSP; 1560 1694 1561 1695 typedef struct smb_com_transaction2_spi_req { 1562 1696 struct smb_hdr hdr; /* wct = 15 */ ··· 1582 1716 __le16 InformationLevel; 1583 1717 __u32 Reserved4; 1584 1718 char FileName[]; 1585 - } __attribute__((packed)) TRANSACTION2_SPI_REQ; 1719 + } __packed TRANSACTION2_SPI_REQ; 1586 1720 1587 1721 typedef struct smb_com_transaction2_spi_rsp { 1588 1722 struct smb_hdr hdr; /* wct = 10 + SetupCount */ 1589 1723 struct trans2_resp t2; 1590 1724 __u16 ByteCount; 1591 1725 __u16 Reserved2; /* parameter word is present for infolevels > 100 */ 1592 - } __attribute__((packed)) TRANSACTION2_SPI_RSP; 1726 + } __packed TRANSACTION2_SPI_RSP; 1593 1727 1594 1728 struct set_file_rename { 1595 1729 __le32 overwrite; /* 1 = overwrite dest */ 1596 1730 __u32 root_fid; /* zero */ 1597 1731 __le32 target_name_len; 1598 1732 char target_name[]; /* Must be unicode */ 1599 - } __attribute__((packed)); 1733 + } __packed; 1600 1734 1601 1735 struct smb_com_transaction2_sfi_req { 1602 1736 struct smb_hdr hdr; /* wct = 15 */ ··· 1623 1757 __le16 InformationLevel; 1624 1758 __u16 Reserved4; 1625 1759 __u8 payload[]; 1626 - } __attribute__((packed)); 1760 + } __packed; 1627 1761 1628 1762 struct smb_com_transaction2_sfi_rsp { 1629 1763 struct smb_hdr hdr; /* wct = 10 + SetupCount */ 1630 1764 struct trans2_resp t2; 1631 1765 __u16 ByteCount; 1632 1766 __u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */ 1633 - } __attribute__((packed)); 1767 + } __packed; 1634 1768 1635 1769 struct smb_t2_qfi_req { 1636 1770 struct smb_hdr hdr; ··· 1638 1772 __u8 Pad; 1639 1773 __u16 Fid; 1640 1774 __le16 InformationLevel; 1641 - } __attribute__((packed)); 1775 + } __packed; 1642 1776 1643 1777 struct smb_t2_qfi_rsp { 1644 1778 struct smb_hdr hdr; /* wct = 10 + SetupCount */ 1645 1779 struct trans2_resp t2; 1646 1780 __u16 ByteCount; 1647 1781 __u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */ 1648 - } __attribute__((packed)); 1782 + } __packed; 1649 1783 1650 1784 /* 1651 1785 * Flags on T2 FINDFIRST and FINDNEXT ··· 1687 1821 __le16 InformationLevel; 1688 1822 __le32 SearchStorageType; 1689 1823 char FileName[]; 1690 - } __attribute__((packed)) TRANSACTION2_FFIRST_REQ; 1824 + } __packed TRANSACTION2_FFIRST_REQ; 1691 1825 1692 1826 typedef struct smb_com_transaction2_ffirst_rsp { 1693 1827 struct smb_hdr hdr; /* wct = 10 */ 1694 1828 struct trans2_resp t2; 1695 1829 __u16 ByteCount; 1696 - } __attribute__((packed)) TRANSACTION2_FFIRST_RSP; 1830 + } __packed TRANSACTION2_FFIRST_RSP; 1697 1831 1698 1832 typedef struct smb_com_transaction2_ffirst_rsp_parms { 1699 1833 __u16 SearchHandle; ··· 1701 1835 __le16 EndofSearch; 1702 1836 __le16 EAErrorOffset; 1703 1837 __le16 LastNameOffset; 1704 - } __attribute__((packed)) T2_FFIRST_RSP_PARMS; 1838 + } __packed T2_FFIRST_RSP_PARMS; 1705 1839 1706 1840 typedef struct smb_com_transaction2_fnext_req { 1707 1841 struct smb_hdr hdr; /* wct = 15 */ ··· 1729 1863 __u32 ResumeKey; 1730 1864 __le16 SearchFlags; 1731 1865 char ResumeFileName[]; 1732 - } __attribute__((packed)) TRANSACTION2_FNEXT_REQ; 1866 + } __packed TRANSACTION2_FNEXT_REQ; 1733 1867 1734 1868 typedef struct smb_com_transaction2_fnext_rsp { 1735 1869 struct smb_hdr hdr; /* wct = 10 */ 1736 1870 struct trans2_resp t2; 1737 1871 __u16 ByteCount; 1738 - } __attribute__((packed)) TRANSACTION2_FNEXT_RSP; 1872 + } __packed TRANSACTION2_FNEXT_RSP; 1739 1873 1740 1874 typedef struct smb_com_transaction2_fnext_rsp_parms { 1741 1875 __le16 SearchCount; 1742 1876 __le16 EndofSearch; 1743 1877 __le16 EAErrorOffset; 1744 1878 __le16 LastNameOffset; 1745 - } __attribute__((packed)) T2_FNEXT_RSP_PARMS; 1879 + } __packed T2_FNEXT_RSP_PARMS; 1746 1880 1747 1881 /* QFSInfo Levels */ 1748 1882 #define SMB_INFO_ALLOCATION 1 ··· 1786 1920 __le16 ByteCount; 1787 1921 __u8 Pad; 1788 1922 __le16 InformationLevel; 1789 - } __attribute__((packed)) TRANSACTION2_QFSI_REQ; 1923 + } __packed TRANSACTION2_QFSI_REQ; 1790 1924 1791 1925 typedef struct smb_com_transaction_qfsi_rsp { 1792 1926 struct smb_hdr hdr; /* wct = 10 + SetupCount */ 1793 1927 struct trans2_resp t2; 1794 1928 __u16 ByteCount; 1795 1929 __u8 Pad; /* may be three bytes? *//* followed by data area */ 1796 - } __attribute__((packed)) TRANSACTION2_QFSI_RSP; 1930 + } __packed TRANSACTION2_QFSI_RSP; 1797 1931 1798 1932 typedef struct whoami_rsp_data { /* Query level 0x202 */ 1799 1933 __u32 flags; /* 0 = Authenticated user 1 = GUEST */ ··· 1806 1940 __u32 pad; /* reserved - MBZ */ 1807 1941 /* __u64 gid_array[0]; */ /* may be empty */ 1808 1942 /* __u8 * psid_list */ /* may be empty */ 1809 - } __attribute__((packed)) WHOAMI_RSP_DATA; 1943 + } __packed WHOAMI_RSP_DATA; 1810 1944 1811 1945 /* SETFSInfo Levels */ 1812 1946 #define SMB_SET_CIFS_UNIX_INFO 0x200 ··· 1839 1973 __le16 ClientUnixMajor; /* Data start. */ 1840 1974 __le16 ClientUnixMinor; 1841 1975 __le64 ClientUnixCap; /* Data end */ 1842 - } __attribute__((packed)) TRANSACTION2_SETFSI_REQ; 1976 + } __packed TRANSACTION2_SETFSI_REQ; 1843 1977 1844 1978 /* level 0x203 request structure follows */ 1845 1979 typedef struct smb_com_transaction2_setfs_enc_req { ··· 1865 1999 __u16 Reserved4; /* Parameters start. */ 1866 2000 __le16 InformationLevel;/* Parameters end. */ 1867 2001 /* NTLMSSP Blob, Data start. */ 1868 - } __attribute__((packed)) TRANSACTION2_SETFSI_ENC_REQ; 2002 + } __packed TRANSACTION2_SETFSI_ENC_REQ; 1869 2003 1870 2004 /* response for setfsinfo levels 0x200 and 0x203 */ 1871 2005 typedef struct smb_com_transaction2_setfsi_rsp { 1872 2006 struct smb_hdr hdr; /* wct = 10 */ 1873 2007 struct trans2_resp t2; 1874 2008 __u16 ByteCount; 1875 - } __attribute__((packed)) TRANSACTION2_SETFSI_RSP; 2009 + } __packed TRANSACTION2_SETFSI_RSP; 1876 2010 1877 2011 typedef struct smb_com_transaction2_get_dfs_refer_req { 1878 2012 struct smb_hdr hdr; /* wct = 15 */ ··· 1898 2032 seem to matter though */ 1899 2033 __le16 MaxReferralLevel; 1900 2034 char RequestFileName[]; 1901 - } __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_REQ; 2035 + } __packed TRANSACTION2_GET_DFS_REFER_REQ; 1902 2036 1903 2037 #define DFS_VERSION cpu_to_le16(0x0003) 1904 2038 ··· 1920 2054 __le16 DfsAlternatePathOffset; 1921 2055 __le16 NetworkAddressOffset; /* offset of the link target */ 1922 2056 __u8 ServiceSiteGuid[16]; /* MBZ, ignored */ 1923 - } __attribute__((packed)) REFERRAL3; 2057 + } __packed REFERRAL3; 1924 2058 1925 2059 struct get_dfs_referral_rsp { 1926 2060 __le16 PathConsumed; ··· 1960 2094 unsigned char versionMinor; 1961 2095 unsigned long type; 1962 2096 unsigned int commentOffset; 1963 - } __attribute__((packed)); 2097 + } __packed; 1964 2098 1965 2099 /* 1966 2100 * The following structure is the format of the data returned on a NetShareEnum ··· 1972 2106 char pad; 1973 2107 unsigned short type; 1974 2108 unsigned int commentOffset; 1975 - } __attribute__((packed)); 2109 + } __packed; 1976 2110 1977 2111 struct aliasInfo { 1978 2112 char aliasName[9]; 1979 2113 char pad; 1980 2114 unsigned int commentOffset; 1981 2115 unsigned char type[2]; 1982 - } __attribute__((packed)); 2116 + } __packed; 1983 2117 1984 2118 struct aliasInfo92 { 1985 2119 int aliasNameOffset; 1986 2120 int serverNameOffset; 1987 2121 int shareNameOffset; 1988 - } __attribute__((packed)); 1989 - 1990 - typedef struct { 1991 - __le64 TotalAllocationUnits; 1992 - __le64 FreeAllocationUnits; 1993 - __le32 SectorsPerAllocationUnit; 1994 - __le32 BytesPerSector; 1995 - } __attribute__((packed)) FILE_SYSTEM_INFO; /* size info, level 0x103 */ 2122 + } __packed; 1996 2123 1997 2124 typedef struct { 1998 2125 __le32 fsid; ··· 1993 2134 __le32 TotalAllocationUnits; 1994 2135 __le32 FreeAllocationUnits; 1995 2136 __le16 BytesPerSector; 1996 - } __attribute__((packed)) FILE_SYSTEM_ALLOC_INFO; 2137 + } __packed FILE_SYSTEM_ALLOC_INFO; 1997 2138 1998 2139 typedef struct { 1999 2140 __le16 MajorVersionNumber; 2000 2141 __le16 MinorVersionNumber; 2001 2142 __le64 Capability; 2002 - } __attribute__((packed)) FILE_SYSTEM_UNIX_INFO; /* Unix extension level 0x200*/ 2143 + } __packed FILE_SYSTEM_UNIX_INFO; /* Unix extension level 0x200*/ 2003 2144 2004 2145 /* Version numbers for CIFS UNIX major and minor. */ 2005 2146 #define CIFS_UNIX_MAJOR_VERSION 1 ··· 2033 2174 2034 2175 2035 2176 #define CIFS_POSIX_EXTENSIONS 0x00000010 /* support for new QFSInfo */ 2036 - 2037 - typedef struct { 2038 - /* For undefined recommended transfer size return -1 in that field */ 2039 - __le32 OptimalTransferSize; /* bsize on some os, iosize on other os */ 2040 - __le32 BlockSize; 2041 - /* The next three fields are in terms of the block size. 2042 - (above). If block size is unknown, 4096 would be a 2043 - reasonable block size for a server to report. 2044 - Note that returning the blocks/blocksavail removes need 2045 - to make a second call (to QFSInfo level 0x103 to get this info. 2046 - UserBlockAvail is typically less than or equal to BlocksAvail, 2047 - if no distinction is made return the same value in each */ 2048 - __le64 TotalBlocks; 2049 - __le64 BlocksAvail; /* bfree */ 2050 - __le64 UserBlocksAvail; /* bavail */ 2051 - /* For undefined Node fields or FSID return -1 */ 2052 - __le64 TotalFileNodes; 2053 - __le64 FreeFileNodes; 2054 - __le64 FileSysIdentifier; /* fsid */ 2055 - /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */ 2056 - /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */ 2057 - } __attribute__((packed)) FILE_SYSTEM_POSIX_INFO; 2058 2177 2059 2178 /* DeviceType Flags */ 2060 2179 #define FILE_DEVICE_CD_ROM 0x00000002 ··· 2068 2231 #define FILE_PORTABLE_DEVICE 0x00004000 2069 2232 #define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL 0x00020000 2070 2233 2071 - typedef struct { 2072 - __le32 DeviceType; 2073 - __le32 DeviceCharacteristics; 2074 - } __attribute__((packed)) FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */ 2075 - 2076 - /* minimum includes first three fields, and empty FS Name */ 2077 - #define MIN_FS_ATTR_INFO_SIZE 12 2078 - 2079 - 2080 - /* List of FileSystemAttributes - see 2.5.1 of MS-FSCC */ 2081 - #define FILE_SUPPORTS_SPARSE_VDL 0x10000000 /* faster nonsparse extend */ 2082 - #define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000 /* allow ioctl dup extents */ 2083 - #define FILE_SUPPORT_INTEGRITY_STREAMS 0x04000000 2084 - #define FILE_SUPPORTS_USN_JOURNAL 0x02000000 2085 - #define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000 2086 - #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000 2087 - #define FILE_SUPPORTS_HARD_LINKS 0x00400000 2088 - #define FILE_SUPPORTS_TRANSACTIONS 0x00200000 2089 - #define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000 2090 - #define FILE_READ_ONLY_VOLUME 0x00080000 2091 - #define FILE_NAMED_STREAMS 0x00040000 2092 - #define FILE_SUPPORTS_ENCRYPTION 0x00020000 2093 - #define FILE_SUPPORTS_OBJECT_IDS 0x00010000 2094 - #define FILE_VOLUME_IS_COMPRESSED 0x00008000 2095 - #define FILE_SUPPORTS_POSIX_UNLINK_RENAME 0x00000400 2096 - #define FILE_RETURNS_CLEANUP_RESULT_INFO 0x00000200 2097 - #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100 2098 - #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080 2099 - #define FILE_SUPPORTS_SPARSE_FILES 0x00000040 2100 - #define FILE_VOLUME_QUOTAS 0x00000020 2101 - #define FILE_FILE_COMPRESSION 0x00000010 2102 - #define FILE_PERSISTENT_ACLS 0x00000008 2103 - #define FILE_UNICODE_ON_DISK 0x00000004 2104 - #define FILE_CASE_PRESERVED_NAMES 0x00000002 2105 - #define FILE_CASE_SENSITIVE_SEARCH 0x00000001 2106 - typedef struct { 2107 - __le32 Attributes; 2108 - __le32 MaxPathNameComponentLength; 2109 - __le32 FileSystemNameLen; 2110 - char FileSystemName[52]; /* do not have to save this - get subset? */ 2111 - } __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO; 2112 - 2113 2234 /******************************************************************************/ 2114 2235 /* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */ 2115 2236 /******************************************************************************/ ··· 2092 2297 char __pad; 2093 2298 DECLARE_FLEX_ARRAY(char, FileName); 2094 2299 }; 2095 - } __attribute__((packed)) FILE_ALL_INFO; /* level 0x107 QPathInfo */ 2300 + } __packed FILE_ALL_INFO; /* level 0x107 QPathInfo */ 2096 2301 2097 2302 typedef struct { 2098 2303 __le64 AllocationSize; ··· 2101 2306 __u8 DeletePending; 2102 2307 __u8 Directory; 2103 2308 __u16 Pad; 2104 - } __attribute__((packed)) FILE_STANDARD_INFO; /* level 0x102 QPathInfo */ 2309 + } __packed FILE_STANDARD_INFO; /* level 0x102 QPathInfo */ 2105 2310 2106 2311 2107 2312 /* defines for enumerating possible values of the Unix type field below */ ··· 2126 2331 __le64 UniqueId; 2127 2332 __le64 Permissions; 2128 2333 __le64 Nlinks; 2129 - } __attribute__((packed)) FILE_UNIX_BASIC_INFO; /* level 0x200 QPathInfo */ 2334 + } __packed FILE_UNIX_BASIC_INFO; /* level 0x200 QPathInfo */ 2130 2335 2131 2336 typedef struct { 2132 2337 DECLARE_FLEX_ARRAY(char, LinkDest); 2133 - } __attribute__((packed)) FILE_UNIX_LINK_INFO; /* level 0x201 QPathInfo */ 2338 + } __packed FILE_UNIX_LINK_INFO; /* level 0x201 QPathInfo */ 2134 2339 2135 2340 /* The following three structures are needed only for 2136 2341 setting time to NT4 and some older servers via ··· 2139 2344 __u16 Day:5; 2140 2345 __u16 Month:4; 2141 2346 __u16 Year:7; 2142 - } __attribute__((packed)) SMB_DATE; 2347 + } __packed SMB_DATE; 2143 2348 2144 2349 typedef struct { 2145 2350 __u16 TwoSeconds:5; 2146 2351 __u16 Minutes:6; 2147 2352 __u16 Hours:5; 2148 - } __attribute__((packed)) SMB_TIME; 2353 + } __packed SMB_TIME; 2149 2354 2150 2355 typedef struct { 2151 2356 __le16 CreationDate; /* SMB Date see above */ ··· 2158 2363 __le32 AllocationSize; 2159 2364 __le16 Attributes; /* verify not u32 */ 2160 2365 __le32 EASize; 2161 - } __attribute__((packed)) FILE_INFO_STANDARD; /* level 1 SetPath/FileInfo */ 2366 + } __packed FILE_INFO_STANDARD; /* level 1 SetPath/FileInfo */ 2162 2367 2163 2368 typedef struct { 2164 2369 __le64 CreationTime; ··· 2167 2372 __le64 ChangeTime; 2168 2373 __le32 Attributes; 2169 2374 __u32 Pad; 2170 - } __attribute__((packed)) FILE_BASIC_INFO; /* size info, level 0x101 */ 2375 + } __packed FILE_BASIC_INFO; /* size info, level 0x101 */ 2171 2376 2172 2377 struct file_allocation_info { 2173 2378 __le64 AllocationSize; /* Note old Samba srvr rounds this up too much */ ··· 2175 2380 2176 2381 struct file_end_of_file_info { 2177 2382 __le64 FileSize; /* offset to end of file */ 2178 - } __attribute__((packed)); /* size info, level 0x104 for set, 0x106 for query */ 2383 + } __packed; /* size info, level 0x104 for set, 0x106 for query */ 2179 2384 2180 2385 struct file_alt_name_info { 2181 2386 DECLARE_FLEX_ARRAY(__u8, alt_name); 2182 - } __attribute__((packed)); /* level 0x0108 */ 2387 + } __packed; /* level 0x0108 */ 2183 2388 2184 2389 struct file_stream_info { 2185 2390 __le32 number_of_streams; /* BB check sizes and verify location */ ··· 2196 2401 __u8 ch_shift; 2197 2402 __u8 cl_shift; 2198 2403 __u8 pad[3]; 2199 - } __attribute__((packed)); /* level 0x10b */ 2404 + } __packed; /* level 0x10b */ 2200 2405 2201 2406 /* POSIX ACL set/query path info structures */ 2202 2407 #define CIFS_ACL_VERSION 1 ··· 2204 2409 __u8 cifs_e_tag; 2205 2410 __u8 cifs_e_perm; 2206 2411 __le64 cifs_uid; /* or gid */ 2207 - } __attribute__((packed)); 2412 + } __packed; 2208 2413 2209 2414 struct cifs_posix_acl { /* access control list (ACL) */ 2210 2415 __le16 version; ··· 2212 2417 __le16 default_entry_count; /* default ACL - count of entries */ 2213 2418 struct cifs_posix_ace ace_array[]; 2214 2419 /* followed by struct cifs_posix_ace default_ace_array[] */ 2215 - } __attribute__((packed)); /* level 0x204 */ 2420 + } __packed; /* level 0x204 */ 2216 2421 2217 2422 /* types of access control entries already defined in posix_acl.h */ 2218 2423 /* #define CIFS_POSIX_ACL_USER_OBJ 0x01 ··· 2247 2452 __le32 PosixOpenFlags; 2248 2453 __le64 Permissions; 2249 2454 __le16 Level; /* reply level requested (see QPathInfo levels) */ 2250 - } __attribute__((packed)) OPEN_PSX_REQ; /* level 0x209 SetPathInfo data */ 2455 + } __packed OPEN_PSX_REQ; /* level 0x209 SetPathInfo data */ 2251 2456 2252 2457 typedef struct { 2253 2458 __le16 OplockFlags; ··· 2256 2461 __le16 ReturnedLevel; 2257 2462 __le16 Pad; 2258 2463 /* struct following varies based on requested level */ 2259 - } __attribute__((packed)) OPEN_PSX_RSP; /* level 0x209 SetPathInfo data */ 2464 + } __packed OPEN_PSX_RSP; /* level 0x209 SetPathInfo data */ 2260 2465 2261 2466 #define SMB_POSIX_UNLINK_FILE_TARGET 0 2262 2467 #define SMB_POSIX_UNLINK_DIRECTORY_TARGET 1 2263 2468 2264 2469 struct unlink_psx_rq { /* level 0x20a SetPathInfo */ 2265 2470 __le16 type; 2266 - } __attribute__((packed)); 2471 + } __packed; 2267 2472 2268 2473 struct file_internal_info { 2269 2474 __le64 UniqueId; /* inode number */ 2270 - } __attribute__((packed)); /* level 0x3ee */ 2475 + } __packed; /* level 0x3ee */ 2271 2476 2272 2477 struct file_mode_info { 2273 2478 __le32 Mode; 2274 - } __attribute__((packed)); /* level 0x3f8 */ 2479 + } __packed; /* level 0x3f8 */ 2275 2480 2276 2481 struct file_attrib_tag { 2277 2482 __le32 Attribute; 2278 2483 __le32 ReparseTag; 2279 - } __attribute__((packed)); /* level 0x40b */ 2484 + } __packed; /* level 0x40b */ 2280 2485 2281 2486 2282 2487 /********************************************************/ ··· 2291 2496 char __pad; 2292 2497 DECLARE_FLEX_ARRAY(char, FileName); 2293 2498 }; 2294 - } __attribute__((packed)) FILE_UNIX_INFO; /* level 0x202 */ 2295 - 2296 - typedef struct { 2297 - __le32 NextEntryOffset; 2298 - __u32 FileIndex; 2299 - __le64 CreationTime; 2300 - __le64 LastAccessTime; 2301 - __le64 LastWriteTime; 2302 - __le64 ChangeTime; 2303 - __le64 EndOfFile; 2304 - __le64 AllocationSize; 2305 - __le32 ExtFileAttributes; 2306 - __le32 FileNameLength; 2307 - char FileName[]; 2308 - } __attribute__((packed)) FILE_DIRECTORY_INFO; /* level 0x101 FF resp data */ 2309 - 2310 - typedef struct { 2311 - __le32 NextEntryOffset; 2312 - __u32 FileIndex; 2313 - __le64 CreationTime; 2314 - __le64 LastAccessTime; 2315 - __le64 LastWriteTime; 2316 - __le64 ChangeTime; 2317 - __le64 EndOfFile; 2318 - __le64 AllocationSize; 2319 - __le32 ExtFileAttributes; 2320 - __le32 FileNameLength; 2321 - __le32 EaSize; /* length of the xattrs */ 2322 - char FileName[]; 2323 - } __attribute__((packed)) FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */ 2324 - 2325 - typedef struct { 2326 - __le32 NextEntryOffset; 2327 - __u32 FileIndex; 2328 - __le64 CreationTime; 2329 - __le64 LastAccessTime; 2330 - __le64 LastWriteTime; 2331 - __le64 ChangeTime; 2332 - __le64 EndOfFile; 2333 - __le64 AllocationSize; 2334 - __le32 ExtFileAttributes; 2335 - __le32 FileNameLength; 2336 - __le32 EaSize; /* EA size */ 2337 - __le32 Reserved; 2338 - __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/ 2339 - char FileName[]; 2340 - } __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */ 2341 - 2342 - typedef struct { 2343 - __le32 NextEntryOffset; 2344 - __u32 FileIndex; 2345 - __le64 CreationTime; 2346 - __le64 LastAccessTime; 2347 - __le64 LastWriteTime; 2348 - __le64 ChangeTime; 2349 - __le64 EndOfFile; 2350 - __le64 AllocationSize; 2351 - __le32 ExtFileAttributes; 2352 - __le32 FileNameLength; 2353 - __le32 EaSize; /* length of the xattrs */ 2354 - __u8 ShortNameLength; 2355 - __u8 Reserved; 2356 - __u8 ShortName[24]; 2357 - char FileName[]; 2358 - } __attribute__((packed)) FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FFrsp data */ 2499 + } __packed FILE_UNIX_INFO; /* level 0x202 */ 2359 2500 2360 2501 typedef struct { 2361 2502 __u32 ResumeKey; ··· 2306 2575 __le16 Attributes; /* verify not u32 */ 2307 2576 __u8 FileNameLength; 2308 2577 char FileName[]; 2309 - } __attribute__((packed)) FIND_FILE_STANDARD_INFO; /* level 0x1 FF resp data */ 2578 + } __packed FIND_FILE_STANDARD_INFO; /* level 0x1 FF resp data */ 2310 2579 2311 2580 2312 2581 struct fea { ··· 2315 2584 __le16 value_len; 2316 2585 char name[]; 2317 2586 /* optionally followed by value */ 2318 - } __attribute__((packed)); 2587 + } __packed; 2319 2588 /* flags for _FEA.fEA */ 2320 2589 #define FEA_NEEDEA 0x80 /* need EA bit */ 2321 2590 2322 2591 struct fealist { 2323 2592 __le32 list_len; 2324 2593 struct fea list; 2325 - } __attribute__((packed)); 2594 + } __packed; 2326 2595 2327 2596 /* used to hold an arbitrary blob of data */ 2328 2597 struct data_blob { 2329 2598 __u8 *data; 2330 2599 size_t length; 2331 2600 void (*free) (struct data_blob *data_blob); 2332 - } __attribute__((packed)); 2601 + } __packed; 2333 2602 2334 2603 2335 2604 #ifdef CONFIG_CIFS_POSIX ··· 2432 2701 char cr2; /* \n */ 2433 2702 /* if room left, then end with \n then 0x20s by convention but not required */ 2434 2703 char path[1024]; 2435 - } __attribute__((packed)); 2704 + } __packed; 2436 2705 2437 2706 typedef struct file_xattr_info { 2438 2707 /* BB do we need another field for flags? BB */
+9 -9
fs/smb/client/cifssmb.c
··· 361 361 } 362 362 363 363 static int 364 - decode_ext_sec_blob(struct cifs_ses *ses, NEGOTIATE_RSP *pSMBr) 364 + decode_ext_sec_blob(struct cifs_ses *ses, SMB_NEGOTIATE_RSP *pSMBr) 365 365 { 366 366 int rc = 0; 367 367 u16 count; ··· 419 419 struct cifs_ses *ses, 420 420 struct TCP_Server_Info *server) 421 421 { 422 - NEGOTIATE_REQ *pSMB; 423 - NEGOTIATE_RSP *pSMBr; 422 + SMB_NEGOTIATE_REQ *pSMB; 423 + SMB_NEGOTIATE_RSP *pSMBr; 424 424 int rc = 0; 425 425 int bytes_returned; 426 426 int i; ··· 614 614 615 615 iov[0].iov_len = 4; 616 616 iov[0].iov_base = smb; 617 - iov[1].iov_len = get_rfc1002_length(smb); 617 + iov[1].iov_len = get_rfc1002_len(smb); 618 618 iov[1].iov_base = (char *)smb + 4; 619 619 620 620 rc = cifs_call_async(server, &rqst, NULL, cifs_echo_callback, NULL, ··· 1458 1458 rdata->iov[0].iov_base = smb; 1459 1459 rdata->iov[0].iov_len = 4; 1460 1460 rdata->iov[1].iov_base = (char *)smb + 4; 1461 - rdata->iov[1].iov_len = get_rfc1002_length(smb); 1461 + rdata->iov[1].iov_len = get_rfc1002_len(smb); 1462 1462 1463 1463 trace_smb3_read_enter(rdata->rreq->debug_id, 1464 1464 rdata->subreq.debug_index, ··· 1830 1830 /* 4 for RFC1001 length + 1 for BCC */ 1831 1831 iov[0].iov_len = 4; 1832 1832 iov[0].iov_base = smb; 1833 - iov[1].iov_len = get_rfc1002_length(smb) + 1; 1833 + iov[1].iov_len = get_rfc1002_len(smb) + 1; 1834 1834 iov[1].iov_base = (char *)smb + 4; 1835 1835 1836 1836 rqst.rq_iov = iov; ··· 4746 4746 /* level 0x103 SMB_QUERY_FILE_SYSTEM_INFO */ 4747 4747 TRANSACTION2_QFSI_REQ *pSMB = NULL; 4748 4748 TRANSACTION2_QFSI_RSP *pSMBr = NULL; 4749 - FILE_SYSTEM_INFO *response_data; 4749 + FILE_SYSTEM_SIZE_INFO *response_data; 4750 4750 int rc = 0; 4751 4751 int bytes_returned = 0; 4752 4752 __u16 params, byte_count; ··· 4794 4794 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 4795 4795 4796 4796 response_data = 4797 - (FILE_SYSTEM_INFO 4797 + (FILE_SYSTEM_SIZE_INFO 4798 4798 *) (((char *) &pSMBr->hdr.Protocol) + 4799 4799 data_offset); 4800 4800 FSData->f_bsize = ··· 4811 4811 FSData->f_blocks = 4812 4812 le64_to_cpu(response_data->TotalAllocationUnits); 4813 4813 FSData->f_bfree = FSData->f_bavail = 4814 - le64_to_cpu(response_data->FreeAllocationUnits); 4814 + le64_to_cpu(response_data->AvailableAllocationUnits); 4815 4815 cifs_dbg(FYI, "Blocks: %lld Free: %lld Block size %ld\n", 4816 4816 (unsigned long long)FSData->f_blocks, 4817 4817 (unsigned long long)FSData->f_bfree,
+4 -4
fs/smb/client/cifstransport.c
··· 165 165 int resp_buf_type; 166 166 167 167 iov[0].iov_base = in_buf; 168 - iov[0].iov_len = get_rfc1002_length(in_buf) + 4; 168 + iov[0].iov_len = get_rfc1002_len(in_buf) + 4; 169 169 flags |= CIFS_NO_RSP_BUF; 170 170 rc = SendReceive2(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov); 171 171 cifs_dbg(NOISY, "SendRcvNoRsp flags %d rc %d\n", flags, rc); ··· 177 177 cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, 178 178 bool log_error) 179 179 { 180 - unsigned int len = get_rfc1002_length(mid->resp_buf) + 4; 180 + unsigned int len = get_rfc1002_len(mid->resp_buf) + 4; 181 181 182 182 dump_smb(mid->resp_buf, min_t(u32, 92, len)); 183 183 ··· 370 370 goto out; 371 371 } 372 372 373 - *pbytes_returned = get_rfc1002_length(midQ->resp_buf); 373 + *pbytes_returned = get_rfc1002_len(midQ->resp_buf); 374 374 memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4); 375 375 rc = cifs_check_receive(midQ, server, 0); 376 376 out: ··· 554 554 goto out; 555 555 } 556 556 557 - *pbytes_returned = get_rfc1002_length(midQ->resp_buf); 557 + *pbytes_returned = get_rfc1002_len(midQ->resp_buf); 558 558 memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4); 559 559 rc = cifs_check_receive(midQ, server, 0); 560 560 out:
+3 -3
fs/smb/client/connect.c
··· 1295 1295 * The right amount was read from socket - 4 bytes, 1296 1296 * so we can now interpret the length field. 1297 1297 */ 1298 - pdu_length = get_rfc1002_length(buf); 1298 + pdu_length = get_rfc1002_len(buf); 1299 1299 1300 1300 cifs_dbg(FYI, "RFC1002 header 0x%x\n", pdu_length); 1301 1301 if (!is_smb_response(server, buf[0])) ··· 2312 2312 } 2313 2313 #else /* ! CONFIG_KEYS */ 2314 2314 static inline int 2315 - cifs_set_cifscreds(struct smb3_fs_context *ctx __attribute__((unused)), 2316 - struct cifs_ses *ses __attribute__((unused))) 2315 + cifs_set_cifscreds(struct smb3_fs_context *ctx __maybe_unused, 2316 + struct cifs_ses *ses __maybe_unused) 2317 2317 { 2318 2318 return -ENOSYS; 2319 2319 }
+2 -2
fs/smb/client/inode.c
··· 1329 1329 /* for easier reading */ 1330 1330 FILE_ALL_INFO *fi; 1331 1331 FILE_DIRECTORY_INFO *fdi; 1332 - SEARCH_ID_FULL_DIR_INFO *si; 1332 + FILE_ID_FULL_DIR_INFO *si; 1333 1333 1334 1334 rc = cifs_backup_query_path_info(xid, tcon, sb, 1335 1335 full_path, ··· 1340 1340 1341 1341 move_cifs_info_to_smb2(&data->fi, fi); 1342 1342 fdi = (FILE_DIRECTORY_INFO *)fi; 1343 - si = (SEARCH_ID_FULL_DIR_INFO *)fi; 1343 + si = (FILE_ID_FULL_DIR_INFO *)fi; 1344 1344 1345 1345 cifs_dir_info_to_fattr(fattr, fdi, cifs_sb); 1346 1346 fattr->cf_uniqueid = le64_to_cpu(si->UniqueId);
+1 -1
fs/smb/client/misc.c
··· 318 318 check_smb_hdr(struct smb_hdr *smb) 319 319 { 320 320 /* does it have the right SMB "signature" ? */ 321 - if (*(__le32 *) smb->Protocol != cpu_to_le32(0x424d53ff)) { 321 + if (*(__le32 *) smb->Protocol != SMB1_PROTO_NUMBER) { 322 322 cifs_dbg(VFS, "Bad protocol string signature header 0x%x\n", 323 323 *(unsigned int *)smb->Protocol); 324 324 return 1;
+4 -4
fs/smb/client/ntlmssp.h
··· 73 73 __le16 Length; 74 74 __le16 MaximumLength; 75 75 __le32 BufferOffset; /* offset to buffer */ 76 - } __attribute__((packed)) SECURITY_BUFFER; 76 + } __packed SECURITY_BUFFER; 77 77 78 78 typedef struct _NEGOTIATE_MESSAGE { 79 79 __u8 Signature[sizeof(NTLMSSP_SIGNATURE)]; ··· 85 85 do not set the version is present flag */ 86 86 char DomainString[]; 87 87 /* followed by WorkstationString */ 88 - } __attribute__((packed)) NEGOTIATE_MESSAGE, *PNEGOTIATE_MESSAGE; 88 + } __packed NEGOTIATE_MESSAGE, *PNEGOTIATE_MESSAGE; 89 89 90 90 #define NTLMSSP_REVISION_W2K3 0x0F 91 91 ··· 121 121 SECURITY_BUFFER TargetInfoArray; 122 122 /* SECURITY_BUFFER for version info not present since we 123 123 do not set the version is present flag */ 124 - } __attribute__((packed)) CHALLENGE_MESSAGE, *PCHALLENGE_MESSAGE; 124 + } __packed CHALLENGE_MESSAGE, *PCHALLENGE_MESSAGE; 125 125 126 126 typedef struct _AUTHENTICATE_MESSAGE { 127 127 __u8 Signature[sizeof(NTLMSSP_SIGNATURE)]; ··· 136 136 struct ntlmssp_version Version; 137 137 /* SECURITY_BUFFER */ 138 138 char UserString[]; 139 - } __attribute__((packed)) AUTHENTICATE_MESSAGE, *PAUTHENTICATE_MESSAGE; 139 + } __packed AUTHENTICATE_MESSAGE, *PAUTHENTICATE_MESSAGE; 140 140 141 141 /* 142 142 * Size of the session key (crypto key encrypted with the password
+6 -6
fs/smb/client/readdir.c
··· 98 98 default: 99 99 break; 100 100 } 101 - } else if (fattr->cf_cifsattrs & ATTR_REPARSE) { 101 + } else if (fattr->cf_cifsattrs & ATTR_REPARSE_POINT) { 102 102 reparse_need_reval = true; 103 103 } 104 104 ··· 138 138 * reparse tag and ctime haven't changed. 139 139 */ 140 140 rc = 0; 141 - if (fattr->cf_cifsattrs & ATTR_REPARSE) { 141 + if (fattr->cf_cifsattrs & ATTR_REPARSE_POINT) { 142 142 if (likely(reparse_inode_match(inode, fattr))) { 143 143 fattr->cf_mode = inode->i_mode; 144 144 fattr->cf_rdev = inode->i_rdev; ··· 190 190 * TODO: go through all documented reparse tags to see if we can 191 191 * reasonably map some of them to directories vs. files vs. symlinks 192 192 */ 193 - if ((fattr->cf_cifsattrs & ATTR_REPARSE) && 193 + if ((fattr->cf_cifsattrs & ATTR_REPARSE_POINT) && 194 194 cifs_reparse_point_to_fattr(cifs_sb, fattr, &data)) 195 195 goto out_reparse; 196 196 ··· 258 258 fattr->cf_nlink = le32_to_cpu(info->HardLinks); 259 259 fattr->cf_cifsattrs = le32_to_cpu(info->DosAttributes); 260 260 261 - if (fattr->cf_cifsattrs & ATTR_REPARSE) 261 + if (fattr->cf_cifsattrs & ATTR_REPARSE_POINT) 262 262 fattr->cf_cifstag = le32_to_cpu(info->ReparseTag); 263 263 264 264 /* The Mode field in the response can now include the file type as well */ ··· 316 316 __dir_info_to_fattr(fattr, info); 317 317 318 318 /* See MS-FSCC 2.4.14, 2.4.19 */ 319 - if (fattr->cf_cifsattrs & ATTR_REPARSE) 319 + if (fattr->cf_cifsattrs & ATTR_REPARSE_POINT) 320 320 fattr->cf_cifstag = le32_to_cpu(di->EaSize); 321 321 cifs_fill_common_info(fattr, cifs_sb); 322 322 } ··· 548 548 } 549 549 550 550 static void cifs_fill_dirent_search(struct cifs_dirent *de, 551 - const SEARCH_ID_FULL_DIR_INFO *info) 551 + const FILE_ID_FULL_DIR_INFO *info) 552 552 { 553 553 de->name = &info->FileName[0]; 554 554 de->namelen = le32_to_cpu(info->FileNameLength);
+4 -4
fs/smb/client/reparse.h
··· 93 93 if (cinode->reparse_tag != IO_REPARSE_TAG_INTERNAL && 94 94 cinode->reparse_tag != fattr->cf_cifstag) 95 95 return false; 96 - return (cinode->cifsAttrs & ATTR_REPARSE) && 96 + return (cinode->cifsAttrs & ATTR_REPARSE_POINT) && 97 97 timespec64_equal(&ctime, &fattr->cf_ctime); 98 98 } 99 99 ··· 107 107 108 108 attrs = le32_to_cpu(fi->DosAttributes); 109 109 if (data->reparse_point) { 110 - attrs |= ATTR_REPARSE; 110 + attrs |= ATTR_REPARSE_POINT; 111 111 fi->DosAttributes = cpu_to_le32(attrs); 112 112 } 113 113 ··· 116 116 117 117 attrs = le32_to_cpu(fi->Attributes); 118 118 if (data->reparse_point) { 119 - attrs |= ATTR_REPARSE; 119 + attrs |= ATTR_REPARSE_POINT; 120 120 fi->Attributes = cpu_to_le32(attrs); 121 121 } 122 122 } 123 123 124 - ret = attrs & ATTR_REPARSE; 124 + ret = attrs & ATTR_REPARSE_POINT; 125 125 126 126 return ret; 127 127 }
+4 -4
fs/smb/client/rfc1002pdu.h
··· 33 33 __u8 calling_len; 34 34 __u8 calling_name[32]; 35 35 __u8 scope2; /* null */ 36 - } __attribute__((packed)) session_req; 36 + } __packed session_req; 37 37 struct { 38 38 __be32 retarget_ip_addr; 39 39 __be16 port; 40 - } __attribute__((packed)) retarget_resp; 40 + } __packed retarget_resp; 41 41 __u8 neg_ses_resp_error_code; 42 42 /* POSITIVE_SESSION_RESPONSE packet does not include trailer. 43 43 SESSION_KEEP_ALIVE packet also does not include a trailer. 44 44 Trailer for the SESSION_MESSAGE packet is SMB/CIFS header */ 45 - } __attribute__((packed)) trailer; 46 - } __attribute__((packed)); 45 + } __packed trailer; 46 + } __packed; 47 47 48 48 /* Negative Session Response error codes */ 49 49 #define RFC1002_NOT_LISTENING_CALLED 0x80 /* not listening on called name */
+1 -1
fs/smb/client/smb1ops.c
··· 648 648 649 649 if (!rc) { 650 650 move_cifs_info_to_smb2(&data->fi, &fi); 651 - data->reparse_point = le32_to_cpu(fi.Attributes) & ATTR_REPARSE; 651 + data->reparse_point = le32_to_cpu(fi.Attributes) & ATTR_REPARSE_POINT; 652 652 } 653 653 654 654 #ifdef CONFIG_CIFS_XATTR
+1 -1
fs/smb/client/smb2inode.c
··· 50 50 51 51 if (dentry) { 52 52 ci = CIFS_I(d_inode(dentry)); 53 - if (ci->cifsAttrs & ATTR_REPARSE) 53 + if (ci->cifsAttrs & ATTR_REPARSE_POINT) 54 54 return OPEN_REPARSE_POINT; 55 55 } 56 56 return 0;
+19 -72
fs/smb/client/smb2ops.c
··· 624 624 struct network_interface_info_ioctl_rsp *p; 625 625 struct sockaddr_in *addr4; 626 626 struct sockaddr_in6 *addr6; 627 - struct iface_info_ipv4 *p4; 628 - struct iface_info_ipv6 *p6; 627 + struct smb_sockaddr_in *p4; 628 + struct smb_sockaddr_in6 *p6; 629 629 struct cifs_server_iface *info = NULL, *iface = NULL, *niface = NULL; 630 630 struct cifs_server_iface tmp_iface; 631 631 ssize_t bytes_left; ··· 685 685 */ 686 686 case INTERNETWORK: 687 687 addr4 = (struct sockaddr_in *)&tmp_iface.sockaddr; 688 - p4 = (struct iface_info_ipv4 *)p->Buffer; 688 + p4 = (struct smb_sockaddr_in *)p->Buffer; 689 689 addr4->sin_family = AF_INET; 690 690 memcpy(&addr4->sin_addr, &p4->IPv4Address, 4); 691 691 ··· 697 697 break; 698 698 case INTERNETWORKV6: 699 699 addr6 = (struct sockaddr_in6 *)&tmp_iface.sockaddr; 700 - p6 = (struct iface_info_ipv6 *)p->Buffer; 700 + p6 = (struct smb_sockaddr_in6 *)p->Buffer; 701 701 addr6->sin6_family = AF_INET6; 702 702 memcpy(&addr6->sin6_addr, &p6->IPv6Address, 16); 703 703 ··· 1524 1524 static int 1525 1525 SMB2_request_res_key(const unsigned int xid, struct cifs_tcon *tcon, 1526 1526 u64 persistent_fid, u64 volatile_fid, 1527 - struct copychunk_ioctl *pcchunk) 1527 + struct copychunk_ioctl_req *pcchunk) 1528 1528 { 1529 1529 int rc; 1530 1530 unsigned int ret_data_len; 1531 - struct resume_key_req *res_key; 1531 + struct resume_key_ioctl_rsp *res_key; 1532 1532 1533 1533 rc = SMB2_ioctl(xid, tcon, persistent_fid, volatile_fid, 1534 1534 FSCTL_SRV_REQUEST_RESUME_KEY, NULL, 0 /* no input */, ··· 1541 1541 cifs_tcon_dbg(VFS, "refcpy ioctl error %d getting resume key\n", rc); 1542 1542 goto req_res_key_exit; 1543 1543 } 1544 - if (ret_data_len < sizeof(struct resume_key_req)) { 1544 + if (ret_data_len < sizeof(struct resume_key_ioctl_rsp)) { 1545 1545 cifs_tcon_dbg(VFS, "Invalid refcopy resume key length\n"); 1546 1546 rc = -EINVAL; 1547 1547 goto req_res_key_exit; ··· 1857 1857 { 1858 1858 int rc = 0; 1859 1859 unsigned int ret_data_len = 0; 1860 - struct copychunk_ioctl *cc_req = NULL; 1860 + struct copychunk_ioctl_req *cc_req = NULL; 1861 1861 struct copychunk_ioctl_rsp *cc_rsp = NULL; 1862 1862 struct cifs_tcon *tcon; 1863 - struct copychunk *chunk; 1863 + struct srv_copychunk *chunk; 1864 1864 u32 chunks, chunk_count, chunk_bytes; 1865 1865 u32 copy_bytes, copy_bytes_left; 1866 1866 u32 chunks_written, bytes_written; ··· 4485 4485 } 4486 4486 4487 4487 /* 4488 - * Clear a read buffer, discarding the folios which have the 1st mark set. 4489 - */ 4490 - static void cifs_clear_folioq_buffer(struct folio_queue *buffer) 4491 - { 4492 - struct folio_queue *folioq; 4493 - 4494 - while ((folioq = buffer)) { 4495 - for (int s = 0; s < folioq_count(folioq); s++) 4496 - if (folioq_is_marked(folioq, s)) 4497 - folio_put(folioq_folio(folioq, s)); 4498 - buffer = folioq->next; 4499 - kfree(folioq); 4500 - } 4501 - } 4502 - 4503 - /* 4504 - * Allocate buffer space into a folio queue. 4505 - */ 4506 - static struct folio_queue *cifs_alloc_folioq_buffer(ssize_t size) 4507 - { 4508 - struct folio_queue *buffer = NULL, *tail = NULL, *p; 4509 - struct folio *folio; 4510 - unsigned int slot; 4511 - 4512 - do { 4513 - if (!tail || folioq_full(tail)) { 4514 - p = kmalloc(sizeof(*p), GFP_NOFS); 4515 - if (!p) 4516 - goto nomem; 4517 - folioq_init(p, 0); 4518 - if (tail) { 4519 - tail->next = p; 4520 - p->prev = tail; 4521 - } else { 4522 - buffer = p; 4523 - } 4524 - tail = p; 4525 - } 4526 - 4527 - folio = folio_alloc(GFP_KERNEL|__GFP_HIGHMEM, 0); 4528 - if (!folio) 4529 - goto nomem; 4530 - 4531 - slot = folioq_append_mark(tail, folio); 4532 - size -= folioq_folio_size(tail, slot); 4533 - } while (size > 0); 4534 - 4535 - return buffer; 4536 - 4537 - nomem: 4538 - cifs_clear_folioq_buffer(buffer); 4539 - return NULL; 4540 - } 4541 - 4542 - /* 4543 4488 * Copy data from an iterator to the folios in a folio queue buffer. 4544 4489 */ 4545 4490 static bool cifs_copy_iter_to_folioq(struct iov_iter *iter, size_t size, ··· 4509 4564 smb3_free_compound_rqst(int num_rqst, struct smb_rqst *rqst) 4510 4565 { 4511 4566 for (int i = 0; i < num_rqst; i++) 4512 - cifs_clear_folioq_buffer(rqst[i].rq_buffer); 4567 + netfs_free_folioq_buffer(rqst[i].rq_buffer); 4513 4568 } 4514 4569 4515 4570 /* ··· 4544 4599 new->rq_nvec = old->rq_nvec; 4545 4600 4546 4601 if (size > 0) { 4547 - buffer = cifs_alloc_folioq_buffer(size); 4548 - if (!buffer) 4602 + size_t cur_size = 0; 4603 + rc = netfs_alloc_folioq_buffer(NULL, &buffer, &cur_size, 4604 + size, GFP_NOFS); 4605 + if (rc < 0) 4549 4606 goto err_free; 4550 4607 4551 4608 new->rq_buffer = buffer; ··· 4879 4932 } 4880 4933 4881 4934 free_pages: 4882 - cifs_clear_folioq_buffer(dw->buffer); 4935 + netfs_free_folioq_buffer(dw->buffer); 4883 4936 cifs_small_buf_release(dw->buf); 4884 4937 kfree(dw); 4885 4938 } ··· 4917 4970 dw->len = len; 4918 4971 len = round_up(dw->len, PAGE_SIZE); 4919 4972 4920 - rc = -ENOMEM; 4921 - dw->buffer = cifs_alloc_folioq_buffer(len); 4922 - if (!dw->buffer) 4973 + size_t cur_size = 0; 4974 + rc = netfs_alloc_folioq_buffer(NULL, &dw->buffer, &cur_size, len, GFP_NOFS); 4975 + if (rc < 0) 4923 4976 goto discard_data; 4924 4977 4925 4978 iov_iter_folio_queue(&iter, ITER_DEST, dw->buffer, 0, 0, len); ··· 4980 5033 } 4981 5034 4982 5035 free_pages: 4983 - cifs_clear_folioq_buffer(dw->buffer); 5036 + netfs_free_folioq_buffer(dw->buffer); 4984 5037 free_dw: 4985 5038 kfree(dw); 4986 5039 return rc;
+22 -23
fs/smb/client/smb2pdu.c
··· 2229 2229 return rc; 2230 2230 } 2231 2231 2232 - 2233 - static struct create_durable * 2232 + static create_durable_req_t * 2234 2233 create_durable_buf(void) 2235 2234 { 2236 - struct create_durable *buf; 2235 + create_durable_req_t *buf; 2237 2236 2238 - buf = kzalloc(sizeof(struct create_durable), GFP_KERNEL); 2237 + buf = kzalloc(sizeof(create_durable_req_t), GFP_KERNEL); 2239 2238 if (!buf) 2240 2239 return NULL; 2241 2240 2242 2241 buf->ccontext.DataOffset = cpu_to_le16(offsetof 2243 - (struct create_durable, Data)); 2242 + (create_durable_req_t, Data)); 2244 2243 buf->ccontext.DataLength = cpu_to_le32(16); 2245 2244 buf->ccontext.NameOffset = cpu_to_le16(offsetof 2246 - (struct create_durable, Name)); 2245 + (create_durable_req_t, Name)); 2247 2246 buf->ccontext.NameLength = cpu_to_le16(4); 2248 2247 /* SMB2_CREATE_DURABLE_HANDLE_REQUEST is "DHnQ" */ 2249 2248 buf->Name[0] = 'D'; ··· 2252 2253 return buf; 2253 2254 } 2254 2255 2255 - static struct create_durable * 2256 + static create_durable_req_t * 2256 2257 create_reconnect_durable_buf(struct cifs_fid *fid) 2257 2258 { 2258 - struct create_durable *buf; 2259 + create_durable_req_t *buf; 2259 2260 2260 - buf = kzalloc(sizeof(struct create_durable), GFP_KERNEL); 2261 + buf = kzalloc(sizeof(create_durable_req_t), GFP_KERNEL); 2261 2262 if (!buf) 2262 2263 return NULL; 2263 2264 2264 2265 buf->ccontext.DataOffset = cpu_to_le16(offsetof 2265 - (struct create_durable, Data)); 2266 + (create_durable_req_t, Data)); 2266 2267 buf->ccontext.DataLength = cpu_to_le32(16); 2267 2268 buf->ccontext.NameOffset = cpu_to_le16(offsetof 2268 - (struct create_durable, Name)); 2269 + (create_durable_req_t, Name)); 2269 2270 buf->ccontext.NameLength = cpu_to_le16(4); 2270 2271 buf->Data.Fid.PersistentFileId = fid->persistent_fid; 2271 2272 buf->Data.Fid.VolatileFileId = fid->volatile_fid; ··· 2423 2424 return 0; 2424 2425 } 2425 2426 2426 - static struct create_durable_v2 * 2427 + static struct create_durable_req_v2 * 2427 2428 create_durable_v2_buf(struct cifs_open_parms *oparms) 2428 2429 { 2429 2430 struct cifs_fid *pfid = oparms->fid; 2430 - struct create_durable_v2 *buf; 2431 + struct create_durable_req_v2 *buf; 2431 2432 2432 - buf = kzalloc(sizeof(struct create_durable_v2), GFP_KERNEL); 2433 + buf = kzalloc(sizeof(struct create_durable_req_v2), GFP_KERNEL); 2433 2434 if (!buf) 2434 2435 return NULL; 2435 2436 2436 2437 buf->ccontext.DataOffset = cpu_to_le16(offsetof 2437 - (struct create_durable_v2, dcontext)); 2438 - buf->ccontext.DataLength = cpu_to_le32(sizeof(struct durable_context_v2)); 2438 + (struct create_durable_req_v2, dcontext)); 2439 + buf->ccontext.DataLength = cpu_to_le32(sizeof(struct durable_context_v2_req)); 2439 2440 buf->ccontext.NameOffset = cpu_to_le16(offsetof 2440 - (struct create_durable_v2, Name)); 2441 + (struct create_durable_req_v2, Name)); 2441 2442 buf->ccontext.NameLength = cpu_to_le16(4); 2442 2443 2443 2444 /* ··· 2507 2508 iov[num].iov_base = create_durable_v2_buf(oparms); 2508 2509 if (iov[num].iov_base == NULL) 2509 2510 return -ENOMEM; 2510 - iov[num].iov_len = sizeof(struct create_durable_v2); 2511 + iov[num].iov_len = sizeof(struct create_durable_req_v2); 2511 2512 *num_iovec = num + 1; 2512 2513 return 0; 2513 2514 } ··· 2551 2552 iov[num].iov_base = create_durable_buf(); 2552 2553 if (iov[num].iov_base == NULL) 2553 2554 return -ENOMEM; 2554 - iov[num].iov_len = sizeof(struct create_durable); 2555 + iov[num].iov_len = sizeof(create_durable_req_t); 2555 2556 *num_iovec = num + 1; 2556 2557 return 0; 2557 2558 } ··· 5453 5454 info_buf_size = sizeof(FILE_DIRECTORY_INFO); 5454 5455 break; 5455 5456 case SMB_FIND_FILE_ID_FULL_DIR_INFO: 5456 - info_buf_size = sizeof(SEARCH_ID_FULL_DIR_INFO); 5457 + info_buf_size = sizeof(FILE_ID_FULL_DIR_INFO); 5457 5458 break; 5458 5459 case SMB_FIND_FILE_POSIX_INFO: 5459 5460 /* note that posix payload are variable size */ ··· 5981 5982 max_len = sizeof(FILE_SYSTEM_DEVICE_INFO); 5982 5983 min_len = sizeof(FILE_SYSTEM_DEVICE_INFO); 5983 5984 } else if (level == FS_ATTRIBUTE_INFORMATION) { 5984 - max_len = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO); 5985 - min_len = MIN_FS_ATTR_INFO_SIZE; 5985 + max_len = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO) + MAX_FS_NAME_LEN; 5986 + min_len = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO); 5986 5987 } else if (level == FS_SECTOR_SIZE_INFORMATION) { 5987 5988 max_len = sizeof(struct smb3_fs_ss_info); 5988 5989 min_len = sizeof(struct smb3_fs_ss_info); ··· 6028 6029 if (level == FS_ATTRIBUTE_INFORMATION) 6029 6030 memcpy(&tcon->fsAttrInfo, offset 6030 6031 + (char *)rsp, min_t(unsigned int, 6031 - rsp_len, max_len)); 6032 + rsp_len, min_len)); 6032 6033 else if (level == FS_DEVICE_INFORMATION) 6033 6034 memcpy(&tcon->fsDevInfo, offset 6034 6035 + (char *)rsp, sizeof(FILE_SYSTEM_DEVICE_INFO));
-112
fs/smb/client/smb2pdu.h
··· 133 133 #define SMB2_LEASE_HANDLE_CACHING_HE 0x02 134 134 #define SMB2_LEASE_WRITE_CACHING_HE 0x04 135 135 136 - 137 - /* See MS-SMB2 2.2.13.2.11 */ 138 - /* Flags */ 139 - #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 140 - struct durable_context_v2 { 141 - __le32 Timeout; 142 - __le32 Flags; 143 - __u64 Reserved; 144 - __u8 CreateGuid[16]; 145 - } __packed; 146 - 147 - struct create_durable_v2 { 148 - struct create_context_hdr ccontext; 149 - __u8 Name[8]; 150 - struct durable_context_v2 dcontext; 151 - } __packed; 152 - 153 - /* See MS-SMB2 2.2.13.2.12 */ 154 - struct durable_reconnect_context_v2 { 155 - struct { 156 - __u64 PersistentFileId; 157 - __u64 VolatileFileId; 158 - } Fid; 159 - __u8 CreateGuid[16]; 160 - __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */ 161 - } __packed; 162 - 163 - /* See MS-SMB2 2.2.14.2.12 */ 164 - struct durable_reconnect_context_v2_rsp { 165 - __le32 Timeout; 166 - __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */ 167 - } __packed; 168 - 169 - struct create_durable_handle_reconnect_v2 { 170 - struct create_context_hdr ccontext; 171 - __u8 Name[8]; 172 - struct durable_reconnect_context_v2 dcontext; 173 - __u8 Pad[4]; 174 - } __packed; 175 - 176 136 /* See MS-SMB2 2.2.13.2.5 */ 177 137 struct crt_twarp_ctxt { 178 138 struct create_context_hdr ccontext; ··· 151 191 struct create_context_hdr ccontext; 152 192 __u8 Name[8]; 153 193 struct smb3_sd sd; 154 - } __packed; 155 - 156 - 157 - #define COPY_CHUNK_RES_KEY_SIZE 24 158 - struct resume_key_req { 159 - char ResumeKey[COPY_CHUNK_RES_KEY_SIZE]; 160 - __le32 ContextLength; /* MBZ */ 161 - char Context[]; /* ignored, Windows sets to 4 bytes of zero */ 162 - } __packed; 163 - 164 - 165 - struct copychunk { 166 - __le64 SourceOffset; 167 - __le64 TargetOffset; 168 - __le32 Length; 169 - __le32 Reserved; 170 - } __packed; 171 - 172 - /* this goes in the ioctl buffer when doing a copychunk request */ 173 - struct copychunk_ioctl { 174 - char SourceKey[COPY_CHUNK_RES_KEY_SIZE]; 175 - __le32 ChunkCount; 176 - __le32 Reserved; 177 - struct copychunk Chunks[]; 178 - } __packed; 179 - 180 - struct copychunk_ioctl_rsp { 181 - __le32 ChunksWritten; 182 - __le32 ChunkBytesWritten; 183 - __le32 TotalBytesWritten; 184 194 } __packed; 185 195 186 196 /* See MS-FSCC 2.3.29 and 2.3.30 */ ··· 193 263 } __packed; 194 264 /* There is no buffer for the response ie no struct network_resiliency_rsp */ 195 265 196 - #define RSS_CAPABLE cpu_to_le32(0x00000001) 197 - #define RDMA_CAPABLE cpu_to_le32(0x00000002) 198 - 199 - #define INTERNETWORK cpu_to_le16(0x0002) 200 - #define INTERNETWORKV6 cpu_to_le16(0x0017) 201 - 202 - struct network_interface_info_ioctl_rsp { 203 - __le32 Next; /* next interface. zero if this is last one */ 204 - __le32 IfIndex; 205 - __le32 Capability; /* RSS or RDMA Capable */ 206 - __le32 Reserved; 207 - __le64 LinkSpeed; 208 - __le16 Family; 209 - __u8 Buffer[126]; 210 - } __packed; 211 - 212 - struct iface_info_ipv4 { 213 - __be16 Port; 214 - __be32 IPv4Address; 215 - __be64 Reserved; 216 - } __packed; 217 - 218 - struct iface_info_ipv6 { 219 - __be16 Port; 220 - __be32 FlowInfo; 221 - __u8 IPv6Address[16]; 222 - __be32 ScopeId; 223 - } __packed; 224 - 225 266 #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */ 226 267 227 268 struct compress_ioctl { ··· 223 322 __le64 IndexNumber; 224 323 __le32 Tag; 225 324 } __packed; 226 - 227 - struct smb2_file_network_open_info { 228 - struct_group_attr(network_open_info, __packed, 229 - __le64 CreationTime; 230 - __le64 LastAccessTime; 231 - __le64 LastWriteTime; 232 - __le64 ChangeTime; 233 - __le64 AllocationSize; 234 - __le64 EndOfFile; 235 - __le32 Attributes; 236 - ); 237 - __le32 Reserved; 238 - } __packed; /* level 34 Query also similar returned in close rsp and open rsp */ 239 325 240 326 /* See MS-FSCC 2.4.21 */ 241 327 struct smb2_file_id_information {
+15 -13
fs/smb/client/smbdirect.c
··· 7 7 #include <linux/module.h> 8 8 #include <linux/highmem.h> 9 9 #include <linux/folio_queue.h> 10 + #define __SMBDIRECT_SOCKET_DISCONNECT(__sc) smbd_disconnect_rdma_connection(__sc) 10 11 #include "../common/smbdirect/smbdirect_pdu.h" 11 12 #include "smbdirect.h" 12 13 #include "cifs_debug.h" ··· 187 186 struct smbdirect_socket *sc = 188 187 container_of(work, struct smbdirect_socket, disconnect_work); 189 188 189 + if (sc->first_error == 0) 190 + sc->first_error = -ECONNABORTED; 191 + 190 192 /* 191 193 * make sure this and other work is not queued again 192 194 * but here we don't block and avoid ··· 200 196 disable_work(&sc->mr_io.recovery_work); 201 197 disable_work(&sc->idle.immediate_work); 202 198 disable_delayed_work(&sc->idle.timer_work); 203 - 204 - if (sc->first_error == 0) 205 - sc->first_error = -ECONNABORTED; 206 199 207 200 switch (sc->status) { 208 201 case SMBDIRECT_SOCKET_NEGOTIATE_NEEDED: ··· 243 242 244 243 static void smbd_disconnect_rdma_connection(struct smbdirect_socket *sc) 245 244 { 245 + if (sc->first_error == 0) 246 + sc->first_error = -ECONNABORTED; 247 + 246 248 /* 247 249 * make sure other work (than disconnect_work) is 248 250 * not queued again but here we don't block and avoid ··· 255 251 disable_work(&sc->mr_io.recovery_work); 256 252 disable_work(&sc->idle.immediate_work); 257 253 disable_delayed_work(&sc->idle.timer_work); 258 - 259 - if (sc->first_error == 0) 260 - sc->first_error = -ECONNABORTED; 261 254 262 255 switch (sc->status) { 263 256 case SMBDIRECT_SOCKET_RESOLVE_ADDR_FAILED: ··· 323 322 324 323 switch (event->event) { 325 324 case RDMA_CM_EVENT_ADDR_RESOLVED: 326 - WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RESOLVE_ADDR_RUNNING); 325 + if (SMBDIRECT_CHECK_STATUS_DISCONNECT(sc, SMBDIRECT_SOCKET_RESOLVE_ADDR_RUNNING)) 326 + break; 327 327 sc->status = SMBDIRECT_SOCKET_RESOLVE_ROUTE_NEEDED; 328 328 wake_up(&sc->status_wait); 329 329 break; 330 330 331 331 case RDMA_CM_EVENT_ROUTE_RESOLVED: 332 - WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RESOLVE_ROUTE_RUNNING); 332 + if (SMBDIRECT_CHECK_STATUS_DISCONNECT(sc, SMBDIRECT_SOCKET_RESOLVE_ROUTE_RUNNING)) 333 + break; 333 334 sc->status = SMBDIRECT_SOCKET_RDMA_CONNECT_NEEDED; 334 335 wake_up(&sc->status_wait); 335 336 break; 336 337 337 338 case RDMA_CM_EVENT_ADDR_ERROR: 338 339 log_rdma_event(ERR, "connecting failed event=%s\n", event_name); 339 - WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RESOLVE_ADDR_RUNNING); 340 340 sc->status = SMBDIRECT_SOCKET_RESOLVE_ADDR_FAILED; 341 341 smbd_disconnect_rdma_work(&sc->disconnect_work); 342 342 break; 343 343 344 344 case RDMA_CM_EVENT_ROUTE_ERROR: 345 345 log_rdma_event(ERR, "connecting failed event=%s\n", event_name); 346 - WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RESOLVE_ROUTE_RUNNING); 347 346 sc->status = SMBDIRECT_SOCKET_RESOLVE_ROUTE_FAILED; 348 347 smbd_disconnect_rdma_work(&sc->disconnect_work); 349 348 break; ··· 429 428 min_t(u8, sp->responder_resources, 430 429 peer_responder_resources); 431 430 432 - WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RDMA_CONNECT_RUNNING); 431 + if (SMBDIRECT_CHECK_STATUS_DISCONNECT(sc, SMBDIRECT_SOCKET_RDMA_CONNECT_RUNNING)) 432 + break; 433 433 sc->status = SMBDIRECT_SOCKET_NEGOTIATE_NEEDED; 434 434 wake_up(&sc->status_wait); 435 435 break; ··· 439 437 case RDMA_CM_EVENT_UNREACHABLE: 440 438 case RDMA_CM_EVENT_REJECTED: 441 439 log_rdma_event(ERR, "connecting failed event=%s\n", event_name); 442 - WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RDMA_CONNECT_RUNNING); 443 440 sc->status = SMBDIRECT_SOCKET_RDMA_CONNECT_FAILED; 444 441 smbd_disconnect_rdma_work(&sc->disconnect_work); 445 442 break; ··· 700 699 negotiate_done = 701 700 process_negotiation_response(response, wc->byte_len); 702 701 put_receive_buffer(sc, response); 703 - WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_NEGOTIATE_RUNNING); 702 + if (SMBDIRECT_CHECK_STATUS_WARN(sc, SMBDIRECT_SOCKET_NEGOTIATE_RUNNING)) 703 + negotiate_done = false; 704 704 if (!negotiate_done) { 705 705 sc->status = SMBDIRECT_SOCKET_NEGOTIATE_FAILED; 706 706 smbd_disconnect_rdma_connection(sc);
-30
fs/smb/common/cifsglob.h
··· 1 - /* SPDX-License-Identifier: LGPL-2.1 */ 2 - /* 3 - * 4 - * Copyright (C) International Business Machines Corp., 2002,2008 5 - * Author(s): Steve French (sfrench@us.ibm.com) 6 - * Jeremy Allison (jra@samba.org) 7 - * 8 - */ 9 - #ifndef _COMMON_CIFS_GLOB_H 10 - #define _COMMON_CIFS_GLOB_H 11 - 12 - static inline void inc_rfc1001_len(void *buf, int count) 13 - { 14 - be32_add_cpu((__be32 *)buf, count); 15 - } 16 - 17 - #define SMB1_VERSION_STRING "1.0" 18 - #define SMB20_VERSION_STRING "2.0" 19 - #define SMB21_VERSION_STRING "2.1" 20 - #define SMBDEFAULT_VERSION_STRING "default" 21 - #define SMB3ANY_VERSION_STRING "3" 22 - #define SMB30_VERSION_STRING "3.0" 23 - #define SMB302_VERSION_STRING "3.02" 24 - #define ALT_SMB302_VERSION_STRING "3.0.2" 25 - #define SMB311_VERSION_STRING "3.1.1" 26 - #define ALT_SMB311_VERSION_STRING "3.11" 27 - 28 - #define CIFS_DEFAULT_IOSIZE (1024 * 1024) 29 - 30 - #endif /* _COMMON_CIFS_GLOB_H */
+174
fs/smb/common/fscc.h
··· 1 + /* SPDX-License-Identifier: LGPL-2.1 */ 2 + /* 3 + * 4 + * Copyright (c) International Business Machines Corp., 2009, 2013 5 + * Etersoft, 2012 6 + * 2018 Samsung Electronics Co., Ltd. 7 + * Author(s): Steve French (sfrench@us.ibm.com) 8 + * Pavel Shilovsky (pshilovsky@samba.org) 2012 9 + * Namjae Jeon (linkinjeon@kernel.org) 10 + * 11 + */ 12 + #ifndef _COMMON_SMB_FSCC_H 13 + #define _COMMON_SMB_FSCC_H 14 + 15 + /* See MS-FSCC 2.4.8 */ 16 + typedef struct { 17 + __le32 NextEntryOffset; 18 + __u32 FileIndex; 19 + __le64 CreationTime; 20 + __le64 LastAccessTime; 21 + __le64 LastWriteTime; 22 + __le64 ChangeTime; 23 + __le64 EndOfFile; 24 + __le64 AllocationSize; 25 + __le32 ExtFileAttributes; 26 + __le32 FileNameLength; 27 + __le32 EaSize; /* length of the xattrs */ 28 + __u8 ShortNameLength; 29 + __u8 Reserved; 30 + __u8 ShortName[24]; 31 + char FileName[]; 32 + } __packed FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FFrsp data */ 33 + 34 + /* See MS-FSCC 2.4.10 */ 35 + typedef struct { 36 + __le32 NextEntryOffset; 37 + __u32 FileIndex; 38 + __le64 CreationTime; 39 + __le64 LastAccessTime; 40 + __le64 LastWriteTime; 41 + __le64 ChangeTime; 42 + __le64 EndOfFile; 43 + __le64 AllocationSize; 44 + __le32 ExtFileAttributes; 45 + __le32 FileNameLength; 46 + char FileName[]; 47 + } __packed FILE_DIRECTORY_INFO; /* level 0x101 FF resp data */ 48 + 49 + /* See MS-FSCC 2.4.14 */ 50 + typedef struct { 51 + __le32 NextEntryOffset; 52 + __u32 FileIndex; 53 + __le64 CreationTime; 54 + __le64 LastAccessTime; 55 + __le64 LastWriteTime; 56 + __le64 ChangeTime; 57 + __le64 EndOfFile; 58 + __le64 AllocationSize; 59 + __le32 ExtFileAttributes; 60 + __le32 FileNameLength; 61 + __le32 EaSize; /* length of the xattrs */ 62 + char FileName[]; 63 + } __packed FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */ 64 + 65 + /* See MS-FSCC 2.4.24 */ 66 + typedef struct { 67 + __le32 NextEntryOffset; 68 + __u32 FileIndex; 69 + __le64 CreationTime; 70 + __le64 LastAccessTime; 71 + __le64 LastWriteTime; 72 + __le64 ChangeTime; 73 + __le64 EndOfFile; 74 + __le64 AllocationSize; 75 + __le32 ExtFileAttributes; 76 + __le32 FileNameLength; 77 + __le32 EaSize; /* EA size */ 78 + __le32 Reserved; 79 + __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/ 80 + char FileName[]; 81 + } __packed FILE_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */ 82 + 83 + /* See MS-FSCC 2.4.34 */ 84 + struct smb2_file_network_open_info { 85 + struct_group_attr(network_open_info, __packed, 86 + __le64 CreationTime; 87 + __le64 LastAccessTime; 88 + __le64 LastWriteTime; 89 + __le64 ChangeTime; 90 + __le64 AllocationSize; 91 + __le64 EndOfFile; 92 + __le32 Attributes; 93 + ); 94 + __le32 Reserved; 95 + } __packed; /* level 34 Query also similar returned in close rsp and open rsp */ 96 + 97 + /* See MS-FSCC 2.5.1 */ 98 + #define MAX_FS_NAME_LEN 52 99 + typedef struct { 100 + __le32 Attributes; 101 + __le32 MaxPathNameComponentLength; 102 + __le32 FileSystemNameLen; 103 + __le16 FileSystemName[]; /* do not have to save this - get subset? */ 104 + } __packed FILE_SYSTEM_ATTRIBUTE_INFO; 105 + 106 + /* List of FileSystemAttributes - see MS-FSCC 2.5.1 */ 107 + #define FILE_SUPPORTS_SPARSE_VDL 0x10000000 /* faster nonsparse extend */ 108 + #define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000 /* allow ioctl dup extents */ 109 + #define FILE_SUPPORT_INTEGRITY_STREAMS 0x04000000 110 + #define FILE_SUPPORTS_USN_JOURNAL 0x02000000 111 + #define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000 112 + #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000 113 + #define FILE_SUPPORTS_HARD_LINKS 0x00400000 114 + #define FILE_SUPPORTS_TRANSACTIONS 0x00200000 115 + #define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000 116 + #define FILE_READ_ONLY_VOLUME 0x00080000 117 + #define FILE_NAMED_STREAMS 0x00040000 118 + #define FILE_SUPPORTS_ENCRYPTION 0x00020000 119 + #define FILE_SUPPORTS_OBJECT_IDS 0x00010000 120 + #define FILE_VOLUME_IS_COMPRESSED 0x00008000 121 + #define FILE_SUPPORTS_POSIX_UNLINK_RENAME 0x00000400 122 + #define FILE_RETURNS_CLEANUP_RESULT_INFO 0x00000200 123 + #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100 124 + #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080 125 + #define FILE_SUPPORTS_SPARSE_FILES 0x00000040 126 + #define FILE_VOLUME_QUOTAS 0x00000020 127 + #define FILE_FILE_COMPRESSION 0x00000010 128 + #define FILE_PERSISTENT_ACLS 0x00000008 129 + #define FILE_UNICODE_ON_DISK 0x00000004 130 + #define FILE_CASE_PRESERVED_NAMES 0x00000002 131 + #define FILE_CASE_SENSITIVE_SEARCH 0x00000001 132 + 133 + /* See MS-FSCC 2.5.8 */ 134 + typedef struct { 135 + __le64 TotalAllocationUnits; 136 + __le64 AvailableAllocationUnits; 137 + __le32 SectorsPerAllocationUnit; 138 + __le32 BytesPerSector; 139 + } __packed FILE_SYSTEM_SIZE_INFO; /* size info, level 0x103 */ 140 + 141 + /* See MS-FSCC 2.5.10 */ 142 + typedef struct { 143 + __le32 DeviceType; 144 + __le32 DeviceCharacteristics; 145 + } __packed FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */ 146 + 147 + /* 148 + * See POSIX Extensions to MS-FSCC 2.3.2.1 149 + * Link: https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/fscc_posix_extensions.md 150 + */ 151 + typedef struct { 152 + /* For undefined recommended transfer size return -1 in that field */ 153 + __le32 OptimalTransferSize; /* bsize on some os, iosize on other os */ 154 + __le32 BlockSize; 155 + /* The next three fields are in terms of the block size. 156 + * (above). If block size is unknown, 4096 would be a 157 + * reasonable block size for a server to report. 158 + * Note that returning the blocks/blocksavail removes need 159 + * to make a second call (to QFSInfo level 0x103 to get this info. 160 + * UserBlockAvail is typically less than or equal to BlocksAvail, 161 + * if no distinction is made return the same value in each 162 + */ 163 + __le64 TotalBlocks; 164 + __le64 BlocksAvail; /* bfree */ 165 + __le64 UserBlocksAvail; /* bavail */ 166 + /* For undefined Node fields or FSID return -1 */ 167 + __le64 TotalFileNodes; 168 + __le64 FreeFileNodes; 169 + __le64 FileSysIdentifier; /* fsid */ 170 + /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */ 171 + /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */ 172 + } __packed FILE_SYSTEM_POSIX_INFO; 173 + 174 + #endif /* _COMMON_SMB_FSCC_H */
+271 -8
fs/smb/common/smb2pdu.h
··· 1149 1149 #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005) 1150 1150 #define FILE_CREATE_MASK_LE cpu_to_le32(0x00000007) 1151 1151 1152 - #define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \ 1153 - | FILE_READ_ATTRIBUTES) 1154 - #define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \ 1155 - | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES) 1156 - #define FILE_EXEC_RIGHTS (FILE_EXECUTE) 1157 - 1158 1152 /* CreateOptions Flags */ 1159 1153 #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001) 1160 1154 /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */ ··· 1265 1271 } __packed; 1266 1272 1267 1273 /* See MS-SMB2 2.2.13.2.3 and MS-SMB2 2.2.13.2.4 */ 1268 - struct create_durable { 1274 + typedef struct { 1269 1275 struct create_context_hdr ccontext; 1270 1276 __u8 Name[8]; 1271 1277 union { ··· 1275 1281 __u64 VolatileFileId; 1276 1282 } Fid; 1277 1283 } Data; 1278 - } __packed; 1284 + } __packed create_durable_req_t, create_durable_reconn_t; 1279 1285 1280 1286 /* See MS-SMB2 2.2.13.2.5 */ 1281 1287 struct create_mxac_req { 1282 1288 struct create_context_hdr ccontext; 1283 1289 __u8 Name[8]; 1284 1290 __le64 Timestamp; 1291 + } __packed; 1292 + 1293 + /* 1294 + * Flags 1295 + * See MS-SMB2 2.2.13.2.11 1296 + * MS-SMB2 2.2.13.2.12 1297 + * MS-SMB2 2.2.14.2.12 1298 + */ 1299 + #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 1300 + 1301 + /* See MS-SMB2 2.2.13.2.11 */ 1302 + struct durable_context_v2_req { 1303 + __le32 Timeout; 1304 + __le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */ 1305 + __u64 Reserved; 1306 + __u8 CreateGuid[16]; 1307 + } __packed; 1308 + 1309 + struct create_durable_req_v2 { 1310 + struct create_context_hdr ccontext; 1311 + __u8 Name[8]; 1312 + struct durable_context_v2_req dcontext; 1313 + } __packed; 1314 + 1315 + /* See MS-SMB2 2.2.13.2.12 */ 1316 + struct durable_reconnect_context_v2 { 1317 + struct { 1318 + __u64 PersistentFileId; 1319 + __u64 VolatileFileId; 1320 + } Fid; 1321 + __u8 CreateGuid[16]; 1322 + __le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */ 1323 + } __packed; 1324 + 1325 + struct create_durable_handle_reconnect_v2 { 1326 + struct create_context_hdr ccontext; 1327 + __u8 Name[8]; 1328 + struct durable_reconnect_context_v2 dcontext; 1329 + } __packed; 1330 + 1331 + /* See MS-SMB2 2.2.14.2.12 */ 1332 + struct durable_context_v2_rsp { 1333 + __le32 Timeout; 1334 + __le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */ 1335 + } __packed; 1336 + 1337 + struct create_durable_rsp_v2 { 1338 + struct create_context_hdr ccontext; 1339 + __u8 Name[8]; 1340 + struct durable_context_v2_rsp dcontext; 1285 1341 } __packed; 1286 1342 1287 1343 /* See MS-SMB2 2.2.14.2.5 */ ··· 1432 1388 __u8 Buffer[]; 1433 1389 } __packed; 1434 1390 1391 + /* See MS-SMB2 2.2.31.1.1 */ 1392 + struct srv_copychunk { 1393 + __le64 SourceOffset; 1394 + __le64 TargetOffset; 1395 + __le32 Length; 1396 + __le32 Reserved; 1397 + } __packed; 1398 + 1399 + #define COPY_CHUNK_RES_KEY_SIZE 24 1400 + 1401 + /* See MS-SMB2 2.2.31.1 */ 1402 + /* this goes in the ioctl buffer when doing a copychunk request */ 1403 + struct copychunk_ioctl_req { 1404 + union { 1405 + char SourceKey[COPY_CHUNK_RES_KEY_SIZE]; 1406 + __le64 SourceKeyU64[3]; 1407 + }; 1408 + __le32 ChunkCount; 1409 + __le32 Reserved; 1410 + struct srv_copychunk Chunks[] __counted_by_le(ChunkCount); 1411 + } __packed; 1412 + 1413 + /* See MS-SMB2 2.2.32.1 */ 1414 + struct copychunk_ioctl_rsp { 1415 + __le32 ChunksWritten; 1416 + __le32 ChunkBytesWritten; 1417 + __le32 TotalBytesWritten; 1418 + } __packed; 1419 + 1420 + /* See MS-SMB2 2.2.32.3 */ 1421 + struct resume_key_ioctl_rsp { 1422 + union { 1423 + char ResumeKey[COPY_CHUNK_RES_KEY_SIZE]; 1424 + __u64 ResumeKeyU64[3]; 1425 + }; 1426 + __le32 ContextLength; /* MBZ */ 1427 + char Context[]; /* ignored, Windows sets to 4 bytes of zero */ 1428 + } __packed; 1429 + 1435 1430 struct smb2_ioctl_rsp { 1436 1431 struct smb2_hdr hdr; 1437 1432 __le16 StructureSize; /* Must be 49 */ ··· 1485 1402 __le32 Flags; 1486 1403 __le32 Reserved2; 1487 1404 __u8 Buffer[]; 1405 + } __packed; 1406 + 1407 + /* See MS-SMB2 2.2.32.5.1.1 */ 1408 + struct smb_sockaddr_in { 1409 + __be16 Port; 1410 + __be32 IPv4Address; 1411 + __u8 Reserved[8]; 1412 + } __packed; 1413 + 1414 + /* See MS-SMB2 2.2.32.5.1.2 */ 1415 + struct smb_sockaddr_in6 { 1416 + __be16 Port; 1417 + __be32 FlowInfo; 1418 + __u8 IPv6Address[16]; 1419 + __be32 ScopeId; 1420 + } __packed; 1421 + 1422 + /* See MS-SMB2 2.2.32.5 and MS-SMB2 2.2.32.5.1 */ 1423 + #define RSS_CAPABLE cpu_to_le32(0x00000001) 1424 + #define RDMA_CAPABLE cpu_to_le32(0x00000002) 1425 + #define INTERNETWORK cpu_to_le16(0x0002) 1426 + #define INTERNETWORKV6 cpu_to_le16(0x0017) 1427 + struct network_interface_info_ioctl_rsp { 1428 + __le32 Next; /* next interface. zero if this is last one */ 1429 + __le32 IfIndex; 1430 + __le32 Capability; /* RSS or RDMA Capable */ 1431 + __le32 Reserved; 1432 + __le64 LinkSpeed; 1433 + union { 1434 + char SockAddr_Storage[128]; 1435 + struct { 1436 + __le16 Family; 1437 + __u8 Buffer[126]; 1438 + }; 1439 + }; 1488 1440 } __packed; 1489 1441 1490 1442 /* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */ ··· 2011 1893 __le64 LeaseDuration; 2012 1894 } __packed; 2013 1895 1896 + /* 1897 + * See MS-CIFS 2.2.3.1 1898 + * MS-SMB 2.2.3.1 1899 + */ 1900 + struct smb_hdr { 1901 + __be32 smb_buf_length; /* BB length is only two (rarely three) bytes, 1902 + with one or two byte "type" preceding it that will be 1903 + zero - we could mask the type byte off */ 1904 + __u8 Protocol[4]; 1905 + __u8 Command; 1906 + union { 1907 + struct { 1908 + __u8 ErrorClass; 1909 + __u8 Reserved; 1910 + __le16 Error; 1911 + } __packed DosError; 1912 + __le32 CifsError; 1913 + } __packed Status; 1914 + __u8 Flags; 1915 + __le16 Flags2; /* note: le */ 1916 + __le16 PidHigh; 1917 + union { 1918 + struct { 1919 + __le32 SequenceNumber; /* le */ 1920 + __u32 Reserved; /* zero */ 1921 + } __packed Sequence; 1922 + __u8 SecuritySignature[8]; /* le */ 1923 + } __packed Signature; 1924 + __u8 pad[2]; 1925 + __u16 Tid; 1926 + __le16 Pid; 1927 + __u16 Uid; 1928 + __le16 Mid; 1929 + __u8 WordCount; 1930 + } __packed; 1931 + 2014 1932 #define OP_BREAK_STRUCT_SIZE_20 24 2015 1933 #define OP_BREAK_STRUCT_SIZE_21 36 1934 + 1935 + /* 1936 + * See MS-SMB2 2.2.13.1.1 1937 + * MS-SMB 2.2.1.4.1 1938 + * These are the file access permission bits defined in CIFS for the 1939 + * NTCreateAndX as well as the level 0x107 1940 + * TRANS2_QUERY_PATH_INFORMATION API. The level 0x107, SMB_QUERY_FILE_ALL_INFO 1941 + * responds with the AccessFlags. 1942 + * The AccessFlags specifies the access permissions a caller has to the 1943 + * file and can have any suitable combination of the following values: 1944 + */ 1945 + #define FILE_READ_DATA 0x00000001 /* Data can be read from the file */ 1946 + /* or directory child entries can */ 1947 + /* be listed together with the */ 1948 + /* associated child attributes */ 1949 + /* (so the FILE_READ_ATTRIBUTES on */ 1950 + /* the child entry is not needed) */ 1951 + #define FILE_WRITE_DATA 0x00000002 /* Data can be written to the file */ 1952 + /* or new file can be created in */ 1953 + /* the directory */ 1954 + #define FILE_APPEND_DATA 0x00000004 /* Data can be appended to the file */ 1955 + /* (for non-local files over SMB it */ 1956 + /* is same as FILE_WRITE_DATA) */ 1957 + /* or new subdirectory can be */ 1958 + /* created in the directory */ 1959 + #define FILE_READ_EA 0x00000008 /* Extended attributes associated */ 1960 + /* with the file can be read */ 1961 + #define FILE_WRITE_EA 0x00000010 /* Extended attributes associated */ 1962 + /* with the file can be written */ 1963 + #define FILE_EXECUTE 0x00000020 /*Data can be read into memory from */ 1964 + /* the file using system paging I/O */ 1965 + /* for executing the file / script */ 1966 + /* or right to traverse directory */ 1967 + /* (but by default all users have */ 1968 + /* directory bypass traverse */ 1969 + /* privilege and do not need this */ 1970 + /* permission on directories at all)*/ 1971 + #define FILE_DELETE_CHILD 0x00000040 /* Child entry can be deleted from */ 1972 + /* the directory (so the DELETE on */ 1973 + /* the child entry is not needed) */ 1974 + #define FILE_READ_ATTRIBUTES 0x00000080 /* Attributes associated with the */ 1975 + /* file or directory can be read */ 1976 + #define FILE_WRITE_ATTRIBUTES 0x00000100 /* Attributes associated with the */ 1977 + /* file or directory can be written */ 1978 + #define DELETE 0x00010000 /* The file or dir can be deleted */ 1979 + #define READ_CONTROL 0x00020000 /* The discretionary access control */ 1980 + /* list and ownership associated */ 1981 + /* with the file or dir can be read */ 1982 + #define WRITE_DAC 0x00040000 /* The discretionary access control */ 1983 + /* list associated with the file or */ 1984 + /* directory can be written */ 1985 + #define WRITE_OWNER 0x00080000 /* Ownership information associated */ 1986 + /* with the file/dir can be written */ 1987 + #define SYNCHRONIZE 0x00100000 /* The file handle can waited on to */ 1988 + /* synchronize with the completion */ 1989 + /* of an input/output request */ 1990 + #define SYSTEM_SECURITY 0x01000000 /* The system access control list */ 1991 + /* associated with the file or */ 1992 + /* directory can be read or written */ 1993 + /* (cannot be in DACL, can in SACL) */ 1994 + #define MAXIMUM_ALLOWED 0x02000000 /* Maximal subset of GENERIC_ALL */ 1995 + /* permissions which can be granted */ 1996 + /* (cannot be in DACL nor SACL) */ 1997 + #define GENERIC_ALL 0x10000000 /* Same as: GENERIC_EXECUTE | */ 1998 + /* GENERIC_WRITE | */ 1999 + /* GENERIC_READ | */ 2000 + /* FILE_DELETE_CHILD | */ 2001 + /* DELETE | */ 2002 + /* WRITE_DAC | */ 2003 + /* WRITE_OWNER */ 2004 + /* So GENERIC_ALL contains all bits */ 2005 + /* mentioned above except these two */ 2006 + /* SYSTEM_SECURITY MAXIMUM_ALLOWED */ 2007 + #define GENERIC_EXECUTE 0x20000000 /* Same as: FILE_EXECUTE | */ 2008 + /* FILE_READ_ATTRIBUTES | */ 2009 + /* READ_CONTROL | */ 2010 + /* SYNCHRONIZE */ 2011 + #define GENERIC_WRITE 0x40000000 /* Same as: FILE_WRITE_DATA | */ 2012 + /* FILE_APPEND_DATA | */ 2013 + /* FILE_WRITE_EA | */ 2014 + /* FILE_WRITE_ATTRIBUTES | */ 2015 + /* READ_CONTROL | */ 2016 + /* SYNCHRONIZE */ 2017 + #define GENERIC_READ 0x80000000 /* Same as: FILE_READ_DATA | */ 2018 + /* FILE_READ_EA | */ 2019 + /* FILE_READ_ATTRIBUTES | */ 2020 + /* READ_CONTROL | */ 2021 + /* SYNCHRONIZE */ 2022 + 2023 + /* Combinations of file access permission bits */ 2024 + #define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES) 2025 + #define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \ 2026 + | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES) 2027 + #define FILE_EXEC_RIGHTS (FILE_EXECUTE) 2028 + #define SET_FILE_EXEC_RIGHTS (FILE_READ_EA | FILE_WRITE_EA | FILE_EXECUTE \ 2029 + | FILE_READ_ATTRIBUTES \ 2030 + | FILE_WRITE_ATTRIBUTES \ 2031 + | DELETE | READ_CONTROL | WRITE_DAC \ 2032 + | WRITE_OWNER | SYNCHRONIZE) 2033 + #define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \ 2034 + | READ_CONTROL | SYNCHRONIZE) 2035 + 2036 + /* See MS-CIFS 2.2.4.52.1 */ 2037 + typedef struct smb_negotiate_req { 2038 + struct smb_hdr hdr; /* wct = 0 */ 2039 + __le16 ByteCount; 2040 + unsigned char DialectsArray[]; 2041 + } __packed SMB_NEGOTIATE_REQ; 2042 + 2016 2043 #endif /* _COMMON_SMB2PDU_H */
+4 -4
fs/smb/common/smbacl.h
··· 92 92 __le32 gsidoffset; 93 93 __le32 sacloffset; 94 94 __le32 dacloffset; 95 - } __attribute__((packed)); 95 + } __packed; 96 96 97 97 struct smb_sid { 98 98 __u8 revision; /* revision level */ 99 99 __u8 num_subauth; 100 100 __u8 authority[NUM_AUTHS]; 101 101 __le32 sub_auth[SID_MAX_SUB_AUTHORITIES]; /* sub_auth[num_subauth] */ 102 - } __attribute__((packed)); 102 + } __packed; 103 103 104 104 /* size of a struct smb_sid, sans sub_auth array */ 105 105 #define CIFS_SID_BASE_SIZE (1 + 1 + NUM_AUTHS) ··· 109 109 __le16 size; 110 110 __le16 num_aces; 111 111 __le16 reserved; 112 - } __attribute__((packed)); 112 + } __packed; 113 113 114 114 struct smb_ace { 115 115 __u8 type; /* see above and MS-DTYP 2.4.4.1 */ ··· 117 117 __le16 size; 118 118 __le32 access_req; 119 119 struct smb_sid sid; /* ie UUID of user or group who gets these perms */ 120 - } __attribute__((packed)); 120 + } __packed; 121 121 122 122 #endif /* _COMMON_SMBACL_H */
+51
fs/smb/common/smbdirect/smbdirect_socket.h
··· 74 74 return "<unknown>"; 75 75 } 76 76 77 + /* 78 + * This can be used with %1pe to print errors as strings or '0' 79 + * And it avoids warnings like: warn: passing zero to 'ERR_PTR' 80 + * from smatch -p=kernel --pedantic 81 + */ 82 + static __always_inline 83 + const void * __must_check SMBDIRECT_DEBUG_ERR_PTR(long error) 84 + { 85 + if (error == 0) 86 + return NULL; 87 + return ERR_PTR(error); 88 + } 89 + 77 90 enum smbdirect_keepalive_status { 78 91 SMBDIRECT_KEEPALIVE_NONE, 79 92 SMBDIRECT_KEEPALIVE_PENDING, ··· 393 380 disable_work_sync(&sc->mr_io.recovery_work); 394 381 init_waitqueue_head(&sc->mr_io.cleanup.wait_queue); 395 382 } 383 + 384 + #define __SMBDIRECT_CHECK_STATUS_FAILED(__sc, __expected_status, __error_cmd, __unexpected_cmd) ({ \ 385 + bool __failed = false; \ 386 + if (unlikely((__sc)->first_error)) { \ 387 + __failed = true; \ 388 + __error_cmd \ 389 + } else if (unlikely((__sc)->status != (__expected_status))) { \ 390 + __failed = true; \ 391 + __unexpected_cmd \ 392 + } \ 393 + __failed; \ 394 + }) 395 + 396 + #define __SMBDIRECT_CHECK_STATUS_WARN(__sc, __expected_status, __unexpected_cmd) \ 397 + __SMBDIRECT_CHECK_STATUS_FAILED(__sc, __expected_status, \ 398 + , \ 399 + { \ 400 + const struct sockaddr_storage *__src = NULL; \ 401 + const struct sockaddr_storage *__dst = NULL; \ 402 + if ((__sc)->rdma.cm_id) { \ 403 + __src = &(__sc)->rdma.cm_id->route.addr.src_addr; \ 404 + __dst = &(__sc)->rdma.cm_id->route.addr.dst_addr; \ 405 + } \ 406 + WARN_ONCE(1, \ 407 + "expected[%s] != %s first_error=%1pe local=%pISpsfc remote=%pISpsfc\n", \ 408 + smbdirect_socket_status_string(__expected_status), \ 409 + smbdirect_socket_status_string((__sc)->status), \ 410 + SMBDIRECT_DEBUG_ERR_PTR((__sc)->first_error), \ 411 + __src, __dst); \ 412 + __unexpected_cmd \ 413 + }) 414 + 415 + #define SMBDIRECT_CHECK_STATUS_WARN(__sc, __expected_status) \ 416 + __SMBDIRECT_CHECK_STATUS_WARN(__sc, __expected_status, /* nothing */) 417 + 418 + #define SMBDIRECT_CHECK_STATUS_DISCONNECT(__sc, __expected_status) \ 419 + __SMBDIRECT_CHECK_STATUS_WARN(__sc, __expected_status, \ 420 + __SMBDIRECT_SOCKET_DISCONNECT(__sc);) 396 421 397 422 struct smbdirect_send_io { 398 423 struct smbdirect_socket *socket;
+72
fs/smb/common/smbglob.h
··· 1 + /* SPDX-License-Identifier: LGPL-2.1 */ 2 + /* 3 + * 4 + * Copyright (C) International Business Machines Corp., 2002,2008 5 + * 2018 Samsung Electronics Co., Ltd. 6 + * Author(s): Steve French (sfrench@us.ibm.com) 7 + * Jeremy Allison (jra@samba.org) 8 + * Namjae Jeon (linkinjeon@kernel.org) 9 + * 10 + */ 11 + #ifndef _COMMON_SMB_GLOB_H 12 + #define _COMMON_SMB_GLOB_H 13 + 14 + #define SMB1_PROTO_NUMBER cpu_to_le32(0x424d53ff) 15 + 16 + struct smb_version_values { 17 + char *version_string; 18 + __u16 protocol_id; 19 + __le16 lock_cmd; 20 + __u32 req_capabilities; 21 + __u32 max_read_size; 22 + __u32 max_write_size; 23 + __u32 max_trans_size; 24 + __u32 max_credits; 25 + __u32 large_lock_type; 26 + __u32 exclusive_lock_type; 27 + __u32 shared_lock_type; 28 + __u32 unlock_lock_type; 29 + size_t header_preamble_size; 30 + size_t header_size; 31 + size_t max_header_size; 32 + size_t read_rsp_size; 33 + unsigned int cap_unix; 34 + unsigned int cap_nt_find; 35 + unsigned int cap_large_files; 36 + unsigned int cap_unicode; 37 + __u16 signing_enabled; 38 + __u16 signing_required; 39 + size_t create_lease_size; 40 + size_t create_durable_size; 41 + size_t create_durable_v2_size; 42 + size_t create_mxac_size; 43 + size_t create_disk_id_size; 44 + size_t create_posix_size; 45 + }; 46 + 47 + static inline unsigned int get_rfc1002_len(void *buf) 48 + { 49 + return be32_to_cpu(*((__be32 *)buf)) & 0xffffff; 50 + } 51 + 52 + static inline void inc_rfc1001_len(void *buf, int count) 53 + { 54 + be32_add_cpu((__be32 *)buf, count); 55 + } 56 + 57 + #define SMB1_VERSION_STRING "1.0" 58 + #define SMB20_VERSION_STRING "2.0" 59 + #define SMB21_VERSION_STRING "2.1" 60 + #define SMBDEFAULT_VERSION_STRING "default" 61 + #define SMB3ANY_VERSION_STRING "3" 62 + #define SMB30_VERSION_STRING "3.0" 63 + #define SMB302_VERSION_STRING "3.02" 64 + #define ALT_SMB302_VERSION_STRING "3.0.2" 65 + #define SMB311_VERSION_STRING "3.1.1" 66 + #define ALT_SMB311_VERSION_STRING "3.11" 67 + 68 + #define CIFS_DEFAULT_IOSIZE (1024 * 1024) 69 + 70 + #define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */ 71 + 72 + #endif /* _COMMON_SMB_GLOB_H */
+2 -4
fs/smb/server/Kconfig
··· 7 7 select NLS_UTF8 8 8 select NLS_UCS2_UTILS 9 9 select CRYPTO 10 - select CRYPTO_MD5 11 - select CRYPTO_HMAC 12 10 select CRYPTO_ECB 13 11 select CRYPTO_LIB_ARC4 14 12 select CRYPTO_LIB_DES 13 + select CRYPTO_LIB_MD5 15 14 select CRYPTO_LIB_SHA256 16 - select CRYPTO_SHA256 15 + select CRYPTO_LIB_SHA512 17 16 select CRYPTO_CMAC 18 - select CRYPTO_SHA512 19 17 select CRYPTO_AEAD2 20 18 select CRYPTO_CCM 21 19 select CRYPTO_GCM
+71 -319
fs/smb/server/auth.c
··· 13 13 #include <linux/xattr.h> 14 14 #include <crypto/hash.h> 15 15 #include <crypto/aead.h> 16 + #include <crypto/md5.h> 17 + #include <crypto/sha2.h> 16 18 #include <linux/random.h> 17 19 #include <linux/scatterlist.h> 18 20 ··· 71 69 memcpy(buf, NEGOTIATE_GSS_HEADER, AUTH_GSS_LENGTH); 72 70 } 73 71 74 - /** 75 - * ksmbd_gen_sess_key() - function to generate session key 76 - * @sess: session of connection 77 - * @hash: source hash value to be used for find session key 78 - * @hmac: source hmac value to be used for finding session key 79 - * 80 - */ 81 - static int ksmbd_gen_sess_key(struct ksmbd_session *sess, char *hash, 82 - char *hmac) 83 - { 84 - struct ksmbd_crypto_ctx *ctx; 85 - int rc; 86 - 87 - ctx = ksmbd_crypto_ctx_find_hmacmd5(); 88 - if (!ctx) { 89 - ksmbd_debug(AUTH, "could not crypto alloc hmacmd5\n"); 90 - return -ENOMEM; 91 - } 92 - 93 - rc = crypto_shash_setkey(CRYPTO_HMACMD5_TFM(ctx), 94 - hash, 95 - CIFS_HMAC_MD5_HASH_SIZE); 96 - if (rc) { 97 - ksmbd_debug(AUTH, "hmacmd5 set key fail error %d\n", rc); 98 - goto out; 99 - } 100 - 101 - rc = crypto_shash_init(CRYPTO_HMACMD5(ctx)); 102 - if (rc) { 103 - ksmbd_debug(AUTH, "could not init hmacmd5 error %d\n", rc); 104 - goto out; 105 - } 106 - 107 - rc = crypto_shash_update(CRYPTO_HMACMD5(ctx), 108 - hmac, 109 - SMB2_NTLMV2_SESSKEY_SIZE); 110 - if (rc) { 111 - ksmbd_debug(AUTH, "Could not update with response error %d\n", rc); 112 - goto out; 113 - } 114 - 115 - rc = crypto_shash_final(CRYPTO_HMACMD5(ctx), sess->sess_key); 116 - if (rc) { 117 - ksmbd_debug(AUTH, "Could not generate hmacmd5 hash error %d\n", rc); 118 - goto out; 119 - } 120 - 121 - out: 122 - ksmbd_release_crypto_ctx(ctx); 123 - return rc; 124 - } 125 - 126 72 static int calc_ntlmv2_hash(struct ksmbd_conn *conn, struct ksmbd_session *sess, 127 73 char *ntlmv2_hash, char *dname) 128 74 { 129 75 int ret, len, conv_len; 130 76 wchar_t *domain = NULL; 131 77 __le16 *uniname = NULL; 132 - struct ksmbd_crypto_ctx *ctx; 78 + struct hmac_md5_ctx ctx; 133 79 134 - ctx = ksmbd_crypto_ctx_find_hmacmd5(); 135 - if (!ctx) { 136 - ksmbd_debug(AUTH, "can't generate ntlmv2 hash\n"); 137 - return -ENOMEM; 138 - } 139 - 140 - ret = crypto_shash_setkey(CRYPTO_HMACMD5_TFM(ctx), 141 - user_passkey(sess->user), 80 + hmac_md5_init_usingrawkey(&ctx, user_passkey(sess->user), 142 81 CIFS_ENCPWD_SIZE); 143 - if (ret) { 144 - ksmbd_debug(AUTH, "Could not set NT Hash as a key\n"); 145 - goto out; 146 - } 147 - 148 - ret = crypto_shash_init(CRYPTO_HMACMD5(ctx)); 149 - if (ret) { 150 - ksmbd_debug(AUTH, "could not init hmacmd5\n"); 151 - goto out; 152 - } 153 82 154 83 /* convert user_name to unicode */ 155 84 len = strlen(user_name(sess->user)); ··· 98 165 } 99 166 UniStrupr(uniname); 100 167 101 - ret = crypto_shash_update(CRYPTO_HMACMD5(ctx), 102 - (char *)uniname, 103 - UNICODE_LEN(conv_len)); 104 - if (ret) { 105 - ksmbd_debug(AUTH, "Could not update with user\n"); 106 - goto out; 107 - } 168 + hmac_md5_update(&ctx, (const u8 *)uniname, UNICODE_LEN(conv_len)); 108 169 109 170 /* Convert domain name or conn name to unicode and uppercase */ 110 171 len = strlen(dname); ··· 115 188 goto out; 116 189 } 117 190 118 - ret = crypto_shash_update(CRYPTO_HMACMD5(ctx), 119 - (char *)domain, 120 - UNICODE_LEN(conv_len)); 121 - if (ret) { 122 - ksmbd_debug(AUTH, "Could not update with domain\n"); 123 - goto out; 124 - } 125 - 126 - ret = crypto_shash_final(CRYPTO_HMACMD5(ctx), ntlmv2_hash); 127 - if (ret) 128 - ksmbd_debug(AUTH, "Could not generate md5 hash\n"); 191 + hmac_md5_update(&ctx, (const u8 *)domain, UNICODE_LEN(conv_len)); 192 + hmac_md5_final(&ctx, ntlmv2_hash); 193 + ret = 0; 129 194 out: 130 195 kfree(uniname); 131 196 kfree(domain); 132 - ksmbd_release_crypto_ctx(ctx); 133 197 return ret; 134 198 } 135 199 ··· 141 223 { 142 224 char ntlmv2_hash[CIFS_ENCPWD_SIZE]; 143 225 char ntlmv2_rsp[CIFS_HMAC_MD5_HASH_SIZE]; 144 - struct ksmbd_crypto_ctx *ctx = NULL; 145 - char *construct = NULL; 146 - int rc, len; 226 + struct hmac_md5_ctx ctx; 227 + int rc; 228 + 229 + if (fips_enabled) { 230 + ksmbd_debug(AUTH, "NTLMv2 support is disabled due to FIPS\n"); 231 + return -EOPNOTSUPP; 232 + } 147 233 148 234 rc = calc_ntlmv2_hash(conn, sess, ntlmv2_hash, domain_name); 149 235 if (rc) { 150 236 ksmbd_debug(AUTH, "could not get v2 hash rc %d\n", rc); 151 - goto out; 237 + return rc; 152 238 } 153 239 154 - ctx = ksmbd_crypto_ctx_find_hmacmd5(); 155 - if (!ctx) { 156 - ksmbd_debug(AUTH, "could not crypto alloc hmacmd5\n"); 157 - return -ENOMEM; 158 - } 240 + hmac_md5_init_usingrawkey(&ctx, ntlmv2_hash, CIFS_HMAC_MD5_HASH_SIZE); 241 + hmac_md5_update(&ctx, cryptkey, CIFS_CRYPTO_KEY_SIZE); 242 + hmac_md5_update(&ctx, (const u8 *)&ntlmv2->blob_signature, blen); 243 + hmac_md5_final(&ctx, ntlmv2_rsp); 159 244 160 - rc = crypto_shash_setkey(CRYPTO_HMACMD5_TFM(ctx), 161 - ntlmv2_hash, 162 - CIFS_HMAC_MD5_HASH_SIZE); 163 - if (rc) { 164 - ksmbd_debug(AUTH, "Could not set NTLMV2 Hash as a key\n"); 165 - goto out; 166 - } 167 - 168 - rc = crypto_shash_init(CRYPTO_HMACMD5(ctx)); 169 - if (rc) { 170 - ksmbd_debug(AUTH, "Could not init hmacmd5\n"); 171 - goto out; 172 - } 173 - 174 - len = CIFS_CRYPTO_KEY_SIZE + blen; 175 - construct = kzalloc(len, KSMBD_DEFAULT_GFP); 176 - if (!construct) { 177 - rc = -ENOMEM; 178 - goto out; 179 - } 180 - 181 - memcpy(construct, cryptkey, CIFS_CRYPTO_KEY_SIZE); 182 - memcpy(construct + CIFS_CRYPTO_KEY_SIZE, &ntlmv2->blob_signature, blen); 183 - 184 - rc = crypto_shash_update(CRYPTO_HMACMD5(ctx), construct, len); 185 - if (rc) { 186 - ksmbd_debug(AUTH, "Could not update with response\n"); 187 - goto out; 188 - } 189 - 190 - rc = crypto_shash_final(CRYPTO_HMACMD5(ctx), ntlmv2_rsp); 191 - if (rc) { 192 - ksmbd_debug(AUTH, "Could not generate md5 hash\n"); 193 - goto out; 194 - } 195 - ksmbd_release_crypto_ctx(ctx); 196 - ctx = NULL; 197 - 198 - rc = ksmbd_gen_sess_key(sess, ntlmv2_hash, ntlmv2_rsp); 199 - if (rc) { 200 - ksmbd_debug(AUTH, "Could not generate sess key\n"); 201 - goto out; 202 - } 245 + /* Generate the session key */ 246 + hmac_md5_usingrawkey(ntlmv2_hash, CIFS_HMAC_MD5_HASH_SIZE, 247 + ntlmv2_rsp, CIFS_HMAC_MD5_HASH_SIZE, 248 + sess->sess_key); 203 249 204 250 if (memcmp(ntlmv2->ntlmv2_hash, ntlmv2_rsp, CIFS_HMAC_MD5_HASH_SIZE) != 0) 205 - rc = -EINVAL; 206 - out: 207 - if (ctx) 208 - ksmbd_release_crypto_ctx(ctx); 209 - kfree(construct); 210 - return rc; 251 + return -EINVAL; 252 + return 0; 211 253 } 212 254 213 255 /** ··· 467 589 * @sig: signature value generated for client request packet 468 590 * 469 591 */ 470 - int ksmbd_sign_smb2_pdu(struct ksmbd_conn *conn, char *key, struct kvec *iov, 471 - int n_vec, char *sig) 592 + void ksmbd_sign_smb2_pdu(struct ksmbd_conn *conn, char *key, struct kvec *iov, 593 + int n_vec, char *sig) 472 594 { 473 - struct ksmbd_crypto_ctx *ctx; 474 - int rc, i; 595 + struct hmac_sha256_ctx ctx; 596 + int i; 475 597 476 - ctx = ksmbd_crypto_ctx_find_hmacsha256(); 477 - if (!ctx) { 478 - ksmbd_debug(AUTH, "could not crypto alloc hmacmd5\n"); 479 - return -ENOMEM; 480 - } 481 - 482 - rc = crypto_shash_setkey(CRYPTO_HMACSHA256_TFM(ctx), 483 - key, 484 - SMB2_NTLMV2_SESSKEY_SIZE); 485 - if (rc) 486 - goto out; 487 - 488 - rc = crypto_shash_init(CRYPTO_HMACSHA256(ctx)); 489 - if (rc) { 490 - ksmbd_debug(AUTH, "hmacsha256 init error %d\n", rc); 491 - goto out; 492 - } 493 - 494 - for (i = 0; i < n_vec; i++) { 495 - rc = crypto_shash_update(CRYPTO_HMACSHA256(ctx), 496 - iov[i].iov_base, 497 - iov[i].iov_len); 498 - if (rc) { 499 - ksmbd_debug(AUTH, "hmacsha256 update error %d\n", rc); 500 - goto out; 501 - } 502 - } 503 - 504 - rc = crypto_shash_final(CRYPTO_HMACSHA256(ctx), sig); 505 - if (rc) 506 - ksmbd_debug(AUTH, "hmacsha256 generation error %d\n", rc); 507 - out: 508 - ksmbd_release_crypto_ctx(ctx); 509 - return rc; 598 + hmac_sha256_init_usingrawkey(&ctx, key, SMB2_NTLMV2_SESSKEY_SIZE); 599 + for (i = 0; i < n_vec; i++) 600 + hmac_sha256_update(&ctx, iov[i].iov_base, iov[i].iov_len); 601 + hmac_sha256_final(&ctx, sig); 510 602 } 511 603 512 604 /** ··· 536 688 bool binding; 537 689 }; 538 690 539 - static int generate_key(struct ksmbd_conn *conn, struct ksmbd_session *sess, 540 - struct kvec label, struct kvec context, __u8 *key, 541 - unsigned int key_size) 691 + static void generate_key(struct ksmbd_conn *conn, struct ksmbd_session *sess, 692 + struct kvec label, struct kvec context, __u8 *key, 693 + unsigned int key_size) 542 694 { 543 695 unsigned char zero = 0x0; 544 696 __u8 i[4] = {0, 0, 0, 1}; 545 697 __u8 L128[4] = {0, 0, 0, 128}; 546 698 __u8 L256[4] = {0, 0, 1, 0}; 547 - int rc; 548 699 unsigned char prfhash[SMB2_HMACSHA256_SIZE]; 549 - unsigned char *hashptr = prfhash; 550 - struct ksmbd_crypto_ctx *ctx; 700 + struct hmac_sha256_ctx ctx; 551 701 552 - memset(prfhash, 0x0, SMB2_HMACSHA256_SIZE); 553 - memset(key, 0x0, key_size); 554 - 555 - ctx = ksmbd_crypto_ctx_find_hmacsha256(); 556 - if (!ctx) { 557 - ksmbd_debug(AUTH, "could not crypto alloc hmacmd5\n"); 558 - return -ENOMEM; 559 - } 560 - 561 - rc = crypto_shash_setkey(CRYPTO_HMACSHA256_TFM(ctx), 562 - sess->sess_key, 563 - SMB2_NTLMV2_SESSKEY_SIZE); 564 - if (rc) 565 - goto smb3signkey_ret; 566 - 567 - rc = crypto_shash_init(CRYPTO_HMACSHA256(ctx)); 568 - if (rc) { 569 - ksmbd_debug(AUTH, "hmacsha256 init error %d\n", rc); 570 - goto smb3signkey_ret; 571 - } 572 - 573 - rc = crypto_shash_update(CRYPTO_HMACSHA256(ctx), i, 4); 574 - if (rc) { 575 - ksmbd_debug(AUTH, "could not update with n\n"); 576 - goto smb3signkey_ret; 577 - } 578 - 579 - rc = crypto_shash_update(CRYPTO_HMACSHA256(ctx), 580 - label.iov_base, 581 - label.iov_len); 582 - if (rc) { 583 - ksmbd_debug(AUTH, "could not update with label\n"); 584 - goto smb3signkey_ret; 585 - } 586 - 587 - rc = crypto_shash_update(CRYPTO_HMACSHA256(ctx), &zero, 1); 588 - if (rc) { 589 - ksmbd_debug(AUTH, "could not update with zero\n"); 590 - goto smb3signkey_ret; 591 - } 592 - 593 - rc = crypto_shash_update(CRYPTO_HMACSHA256(ctx), 594 - context.iov_base, 595 - context.iov_len); 596 - if (rc) { 597 - ksmbd_debug(AUTH, "could not update with context\n"); 598 - goto smb3signkey_ret; 599 - } 702 + hmac_sha256_init_usingrawkey(&ctx, sess->sess_key, 703 + SMB2_NTLMV2_SESSKEY_SIZE); 704 + hmac_sha256_update(&ctx, i, 4); 705 + hmac_sha256_update(&ctx, label.iov_base, label.iov_len); 706 + hmac_sha256_update(&ctx, &zero, 1); 707 + hmac_sha256_update(&ctx, context.iov_base, context.iov_len); 600 708 601 709 if (key_size == SMB3_ENC_DEC_KEY_SIZE && 602 710 (conn->cipher_type == SMB2_ENCRYPTION_AES256_CCM || 603 711 conn->cipher_type == SMB2_ENCRYPTION_AES256_GCM)) 604 - rc = crypto_shash_update(CRYPTO_HMACSHA256(ctx), L256, 4); 712 + hmac_sha256_update(&ctx, L256, 4); 605 713 else 606 - rc = crypto_shash_update(CRYPTO_HMACSHA256(ctx), L128, 4); 607 - if (rc) { 608 - ksmbd_debug(AUTH, "could not update with L\n"); 609 - goto smb3signkey_ret; 610 - } 714 + hmac_sha256_update(&ctx, L128, 4); 611 715 612 - rc = crypto_shash_final(CRYPTO_HMACSHA256(ctx), hashptr); 613 - if (rc) { 614 - ksmbd_debug(AUTH, "Could not generate hmacmd5 hash error %d\n", 615 - rc); 616 - goto smb3signkey_ret; 617 - } 618 - 619 - memcpy(key, hashptr, key_size); 620 - 621 - smb3signkey_ret: 622 - ksmbd_release_crypto_ctx(ctx); 623 - return rc; 716 + hmac_sha256_final(&ctx, prfhash); 717 + memcpy(key, prfhash, key_size); 624 718 } 625 719 626 720 static int generate_smb3signingkey(struct ksmbd_session *sess, 627 721 struct ksmbd_conn *conn, 628 722 const struct derivation *signing) 629 723 { 630 - int rc; 631 724 struct channel *chann; 632 725 char *key; 633 726 ··· 581 792 else 582 793 key = sess->smb3signingkey; 583 794 584 - rc = generate_key(conn, sess, signing->label, signing->context, key, 585 - SMB3_SIGN_KEY_SIZE); 586 - if (rc) 587 - return rc; 795 + generate_key(conn, sess, signing->label, signing->context, key, 796 + SMB3_SIGN_KEY_SIZE); 588 797 589 798 if (!(conn->dialect >= SMB30_PROT_ID && signing->binding)) 590 799 memcpy(chann->smb3signingkey, key, SMB3_SIGN_KEY_SIZE); ··· 638 851 struct derivation decryption; 639 852 }; 640 853 641 - static int generate_smb3encryptionkey(struct ksmbd_conn *conn, 642 - struct ksmbd_session *sess, 643 - const struct derivation_twin *ptwin) 854 + static void generate_smb3encryptionkey(struct ksmbd_conn *conn, 855 + struct ksmbd_session *sess, 856 + const struct derivation_twin *ptwin) 644 857 { 645 - int rc; 858 + generate_key(conn, sess, ptwin->encryption.label, 859 + ptwin->encryption.context, sess->smb3encryptionkey, 860 + SMB3_ENC_DEC_KEY_SIZE); 646 861 647 - rc = generate_key(conn, sess, ptwin->encryption.label, 648 - ptwin->encryption.context, sess->smb3encryptionkey, 649 - SMB3_ENC_DEC_KEY_SIZE); 650 - if (rc) 651 - return rc; 652 - 653 - rc = generate_key(conn, sess, ptwin->decryption.label, 654 - ptwin->decryption.context, 655 - sess->smb3decryptionkey, SMB3_ENC_DEC_KEY_SIZE); 656 - if (rc) 657 - return rc; 862 + generate_key(conn, sess, ptwin->decryption.label, 863 + ptwin->decryption.context, 864 + sess->smb3decryptionkey, SMB3_ENC_DEC_KEY_SIZE); 658 865 659 866 ksmbd_debug(AUTH, "dumping generated AES encryption keys\n"); 660 867 ksmbd_debug(AUTH, "Cipher type %d\n", conn->cipher_type); ··· 667 886 ksmbd_debug(AUTH, "ServerOut Key %*ph\n", 668 887 SMB3_GCM128_CRYPTKEY_SIZE, sess->smb3decryptionkey); 669 888 } 670 - return 0; 671 889 } 672 890 673 - int ksmbd_gen_smb30_encryptionkey(struct ksmbd_conn *conn, 674 - struct ksmbd_session *sess) 891 + void ksmbd_gen_smb30_encryptionkey(struct ksmbd_conn *conn, 892 + struct ksmbd_session *sess) 675 893 { 676 894 struct derivation_twin twin; 677 895 struct derivation *d; ··· 687 907 d->context.iov_base = "ServerIn "; 688 908 d->context.iov_len = 10; 689 909 690 - return generate_smb3encryptionkey(conn, sess, &twin); 910 + generate_smb3encryptionkey(conn, sess, &twin); 691 911 } 692 912 693 - int ksmbd_gen_smb311_encryptionkey(struct ksmbd_conn *conn, 694 - struct ksmbd_session *sess) 913 + void ksmbd_gen_smb311_encryptionkey(struct ksmbd_conn *conn, 914 + struct ksmbd_session *sess) 695 915 { 696 916 struct derivation_twin twin; 697 917 struct derivation *d; ··· 708 928 d->context.iov_base = sess->Preauth_HashValue; 709 929 d->context.iov_len = 64; 710 930 711 - return generate_smb3encryptionkey(conn, sess, &twin); 931 + generate_smb3encryptionkey(conn, sess, &twin); 712 932 } 713 933 714 934 int ksmbd_gen_preauth_integrity_hash(struct ksmbd_conn *conn, char *buf, 715 935 __u8 *pi_hash) 716 936 { 717 - int rc; 718 937 struct smb2_hdr *rcv_hdr = smb2_get_msg(buf); 719 938 char *all_bytes_msg = (char *)&rcv_hdr->ProtocolId; 720 939 int msg_size = get_rfc1002_len(buf); 721 - struct ksmbd_crypto_ctx *ctx = NULL; 940 + struct sha512_ctx sha_ctx; 722 941 723 942 if (conn->preauth_info->Preauth_HashId != 724 943 SMB2_PREAUTH_INTEGRITY_SHA512) 725 944 return -EINVAL; 726 945 727 - ctx = ksmbd_crypto_ctx_find_sha512(); 728 - if (!ctx) { 729 - ksmbd_debug(AUTH, "could not alloc sha512\n"); 730 - return -ENOMEM; 731 - } 732 - 733 - rc = crypto_shash_init(CRYPTO_SHA512(ctx)); 734 - if (rc) { 735 - ksmbd_debug(AUTH, "could not init shashn"); 736 - goto out; 737 - } 738 - 739 - rc = crypto_shash_update(CRYPTO_SHA512(ctx), pi_hash, 64); 740 - if (rc) { 741 - ksmbd_debug(AUTH, "could not update with n\n"); 742 - goto out; 743 - } 744 - 745 - rc = crypto_shash_update(CRYPTO_SHA512(ctx), all_bytes_msg, msg_size); 746 - if (rc) { 747 - ksmbd_debug(AUTH, "could not update with n\n"); 748 - goto out; 749 - } 750 - 751 - rc = crypto_shash_final(CRYPTO_SHA512(ctx), pi_hash); 752 - if (rc) { 753 - ksmbd_debug(AUTH, "Could not generate hash err : %d\n", rc); 754 - goto out; 755 - } 756 - out: 757 - ksmbd_release_crypto_ctx(ctx); 758 - return rc; 946 + sha512_init(&sha_ctx); 947 + sha512_update(&sha_ctx, pi_hash, 64); 948 + sha512_update(&sha_ctx, all_bytes_msg, msg_size); 949 + sha512_final(&sha_ctx, pi_hash); 950 + return 0; 759 951 } 760 952 761 953 static int ksmbd_get_encryption_key(struct ksmbd_work *work, __u64 ses_id,
+5 -5
fs/smb/server/auth.h
··· 52 52 struct ksmbd_conn *conn); 53 53 int ksmbd_krb5_authenticate(struct ksmbd_session *sess, char *in_blob, 54 54 int in_len, char *out_blob, int *out_len); 55 - int ksmbd_sign_smb2_pdu(struct ksmbd_conn *conn, char *key, struct kvec *iov, 56 - int n_vec, char *sig); 55 + void ksmbd_sign_smb2_pdu(struct ksmbd_conn *conn, char *key, struct kvec *iov, 56 + int n_vec, char *sig); 57 57 int ksmbd_sign_smb3_pdu(struct ksmbd_conn *conn, char *key, struct kvec *iov, 58 58 int n_vec, char *sig); 59 59 int ksmbd_gen_smb30_signingkey(struct ksmbd_session *sess, 60 60 struct ksmbd_conn *conn); 61 61 int ksmbd_gen_smb311_signingkey(struct ksmbd_session *sess, 62 62 struct ksmbd_conn *conn); 63 - int ksmbd_gen_smb30_encryptionkey(struct ksmbd_conn *conn, 64 - struct ksmbd_session *sess); 65 - int ksmbd_gen_smb311_encryptionkey(struct ksmbd_conn *conn, 63 + void ksmbd_gen_smb30_encryptionkey(struct ksmbd_conn *conn, 66 64 struct ksmbd_session *sess); 65 + void ksmbd_gen_smb311_encryptionkey(struct ksmbd_conn *conn, 66 + struct ksmbd_session *sess); 67 67 int ksmbd_gen_preauth_integrity_hash(struct ksmbd_conn *conn, char *buf, 68 68 __u8 *pi_hash); 69 69 #endif
-24
fs/smb/server/crypto_ctx.c
··· 66 66 struct shash_desc *shash; 67 67 68 68 switch (id) { 69 - case CRYPTO_SHASH_HMACMD5: 70 - tfm = crypto_alloc_shash("hmac(md5)", 0, 0); 71 - break; 72 - case CRYPTO_SHASH_HMACSHA256: 73 - tfm = crypto_alloc_shash("hmac(sha256)", 0, 0); 74 - break; 75 69 case CRYPTO_SHASH_CMACAES: 76 70 tfm = crypto_alloc_shash("cmac(aes)", 0, 0); 77 - break; 78 - case CRYPTO_SHASH_SHA512: 79 - tfm = crypto_alloc_shash("sha512", 0, 0); 80 71 break; 81 72 default: 82 73 return NULL; ··· 171 180 return NULL; 172 181 } 173 182 174 - struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_hmacmd5(void) 175 - { 176 - return ____crypto_shash_ctx_find(CRYPTO_SHASH_HMACMD5); 177 - } 178 - 179 - struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_hmacsha256(void) 180 - { 181 - return ____crypto_shash_ctx_find(CRYPTO_SHASH_HMACSHA256); 182 - } 183 - 184 183 struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_cmacaes(void) 185 184 { 186 185 return ____crypto_shash_ctx_find(CRYPTO_SHASH_CMACAES); 187 - } 188 - 189 - struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_sha512(void) 190 - { 191 - return ____crypto_shash_ctx_find(CRYPTO_SHASH_SHA512); 192 186 } 193 187 194 188 static struct ksmbd_crypto_ctx *____crypto_aead_ctx_find(int id)
+1 -14
fs/smb/server/crypto_ctx.h
··· 10 10 #include <crypto/aead.h> 11 11 12 12 enum { 13 - CRYPTO_SHASH_HMACMD5 = 0, 14 - CRYPTO_SHASH_HMACSHA256, 15 - CRYPTO_SHASH_CMACAES, 16 - CRYPTO_SHASH_SHA512, 13 + CRYPTO_SHASH_CMACAES = 0, 17 14 CRYPTO_SHASH_MAX, 18 15 }; 19 16 ··· 32 35 struct crypto_aead *ccmaes[CRYPTO_AEAD_MAX]; 33 36 }; 34 37 35 - #define CRYPTO_HMACMD5(c) ((c)->desc[CRYPTO_SHASH_HMACMD5]) 36 - #define CRYPTO_HMACSHA256(c) ((c)->desc[CRYPTO_SHASH_HMACSHA256]) 37 38 #define CRYPTO_CMACAES(c) ((c)->desc[CRYPTO_SHASH_CMACAES]) 38 - #define CRYPTO_SHA512(c) ((c)->desc[CRYPTO_SHASH_SHA512]) 39 39 40 - #define CRYPTO_HMACMD5_TFM(c) ((c)->desc[CRYPTO_SHASH_HMACMD5]->tfm) 41 - #define CRYPTO_HMACSHA256_TFM(c)\ 42 - ((c)->desc[CRYPTO_SHASH_HMACSHA256]->tfm) 43 40 #define CRYPTO_CMACAES_TFM(c) ((c)->desc[CRYPTO_SHASH_CMACAES]->tfm) 44 - #define CRYPTO_SHA512_TFM(c) ((c)->desc[CRYPTO_SHASH_SHA512]->tfm) 45 41 46 42 #define CRYPTO_GCM(c) ((c)->ccmaes[CRYPTO_AEAD_AES_GCM]) 47 43 #define CRYPTO_CCM(c) ((c)->ccmaes[CRYPTO_AEAD_AES_CCM]) 48 44 49 45 void ksmbd_release_crypto_ctx(struct ksmbd_crypto_ctx *ctx); 50 - struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_hmacmd5(void); 51 - struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_hmacsha256(void); 52 46 struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_cmacaes(void); 53 - struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_sha512(void); 54 47 struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_gcm(void); 55 48 struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_ccm(void); 56 49 void ksmbd_crypto_destroy(void);
+4 -14
fs/smb/server/mgmt/tree_connect.c
··· 78 78 tree_conn->t_state = TREE_NEW; 79 79 status.tree_conn = tree_conn; 80 80 atomic_set(&tree_conn->refcount, 1); 81 - init_waitqueue_head(&tree_conn->refcount_q); 82 81 83 82 ret = xa_err(xa_store(&sess->tree_conns, tree_conn->id, tree_conn, 84 83 KSMBD_DEFAULT_GFP)); ··· 99 100 100 101 void ksmbd_tree_connect_put(struct ksmbd_tree_connect *tcon) 101 102 { 102 - /* 103 - * Checking waitqueue to releasing tree connect on 104 - * tree disconnect. waitqueue_active is safe because it 105 - * uses atomic operation for condition. 106 - */ 107 - if (!atomic_dec_return(&tcon->refcount) && 108 - waitqueue_active(&tcon->refcount_q)) 109 - wake_up(&tcon->refcount_q); 103 + if (atomic_dec_and_test(&tcon->refcount)) 104 + kfree(tcon); 110 105 } 111 106 112 107 int ksmbd_tree_conn_disconnect(struct ksmbd_session *sess, ··· 112 119 xa_erase(&sess->tree_conns, tree_conn->id); 113 120 write_unlock(&sess->tree_conns_lock); 114 121 115 - if (!atomic_dec_and_test(&tree_conn->refcount)) 116 - wait_event(tree_conn->refcount_q, 117 - atomic_read(&tree_conn->refcount) == 0); 118 - 119 122 ret = ksmbd_ipc_tree_disconnect_request(sess->id, tree_conn->id); 120 123 ksmbd_release_tree_conn_id(sess, tree_conn->id); 121 124 ksmbd_share_config_put(tree_conn->share_conf); 122 - kfree(tree_conn); 125 + if (atomic_dec_and_test(&tree_conn->refcount)) 126 + kfree(tree_conn); 123 127 return ret; 124 128 } 125 129
-1
fs/smb/server/mgmt/tree_connect.h
··· 33 33 int maximal_access; 34 34 bool posix_extensions; 35 35 atomic_t refcount; 36 - wait_queue_head_t refcount_q; 37 36 unsigned int t_state; 38 37 }; 39 38
+10 -5
fs/smb/server/misc.c
··· 164 164 { 165 165 char *pathname, *ab_pathname, *nt_pathname; 166 166 int share_path_len = share->path_sz; 167 + size_t ab_pathname_len; 168 + int prefix; 167 169 168 170 pathname = kmalloc(PATH_MAX, KSMBD_DEFAULT_GFP); 169 171 if (!pathname) ··· 182 180 goto free_pathname; 183 181 } 184 182 185 - nt_pathname = kzalloc(strlen(&ab_pathname[share_path_len]) + 2, 186 - KSMBD_DEFAULT_GFP); 183 + ab_pathname_len = strlen(&ab_pathname[share_path_len]); 184 + prefix = ab_pathname[share_path_len] == '\0' ? 1 : 0; 185 + nt_pathname = kmalloc(prefix + ab_pathname_len + 1, KSMBD_DEFAULT_GFP); 187 186 if (!nt_pathname) { 188 187 nt_pathname = ERR_PTR(-ENOMEM); 189 188 goto free_pathname; 190 189 } 191 - if (ab_pathname[share_path_len] == '\0') 192 - strcpy(nt_pathname, "/"); 193 - strcat(nt_pathname, &ab_pathname[share_path_len]); 190 + 191 + if (prefix) 192 + *nt_pathname = '/'; 193 + memcpy(nt_pathname + prefix, &ab_pathname[share_path_len], 194 + ab_pathname_len + 1); 194 195 195 196 ksmbd_conv_path_to_windows(nt_pathname); 196 197
+4 -4
fs/smb/server/oplock.c
··· 1617 1617 */ 1618 1618 void create_durable_v2_rsp_buf(char *cc, struct ksmbd_file *fp) 1619 1619 { 1620 - struct create_durable_v2_rsp *buf; 1620 + struct create_durable_rsp_v2 *buf; 1621 1621 1622 - buf = (struct create_durable_v2_rsp *)cc; 1622 + buf = (struct create_durable_rsp_v2 *)cc; 1623 1623 memset(buf, 0, sizeof(struct create_durable_rsp)); 1624 1624 buf->ccontext.DataOffset = cpu_to_le16(offsetof 1625 1625 (struct create_durable_rsp, Data)); ··· 1633 1633 buf->Name[2] = '2'; 1634 1634 buf->Name[3] = 'Q'; 1635 1635 1636 - buf->Timeout = cpu_to_le32(fp->durable_timeout); 1636 + buf->dcontext.Timeout = cpu_to_le32(fp->durable_timeout); 1637 1637 if (fp->is_persistent) 1638 - buf->Flags = cpu_to_le32(SMB2_DHANDLE_FLAG_PERSISTENT); 1638 + buf->dcontext.Flags = cpu_to_le32(SMB2_DHANDLE_FLAG_PERSISTENT); 1639 1639 } 1640 1640 1641 1641 /**
-4
fs/smb/server/server.c
··· 622 622 MODULE_DESCRIPTION("Linux kernel CIFS/SMB SERVER"); 623 623 MODULE_LICENSE("GPL"); 624 624 MODULE_SOFTDEP("pre: ecb"); 625 - MODULE_SOFTDEP("pre: hmac"); 626 - MODULE_SOFTDEP("pre: md5"); 627 625 MODULE_SOFTDEP("pre: nls"); 628 626 MODULE_SOFTDEP("pre: aes"); 629 627 MODULE_SOFTDEP("pre: cmac"); 630 - MODULE_SOFTDEP("pre: sha256"); 631 - MODULE_SOFTDEP("pre: sha512"); 632 628 MODULE_SOFTDEP("pre: aead2"); 633 629 MODULE_SOFTDEP("pre: ccm"); 634 630 MODULE_SOFTDEP("pre: gcm");
+1 -1
fs/smb/server/smb2misc.c
··· 460 460 } 461 461 462 462 validate_credit: 463 - if ((work->conn->vals->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU) && 463 + if ((work->conn->vals->req_capabilities & SMB2_GLOBAL_CAP_LARGE_MTU) && 464 464 smb2_validate_credit_charge(work->conn, hdr)) 465 465 return 1; 466 466
+19 -19
fs/smb/server/smb2ops.c
··· 15 15 static struct smb_version_values smb21_server_values = { 16 16 .version_string = SMB21_VERSION_STRING, 17 17 .protocol_id = SMB21_PROT_ID, 18 - .capabilities = SMB2_GLOBAL_CAP_LARGE_MTU, 18 + .req_capabilities = SMB2_GLOBAL_CAP_LARGE_MTU, 19 19 .max_read_size = SMB21_DEFAULT_IOSIZE, 20 20 .max_write_size = SMB21_DEFAULT_IOSIZE, 21 21 .max_trans_size = SMB21_DEFAULT_IOSIZE, ··· 41 41 static struct smb_version_values smb30_server_values = { 42 42 .version_string = SMB30_VERSION_STRING, 43 43 .protocol_id = SMB30_PROT_ID, 44 - .capabilities = SMB2_GLOBAL_CAP_LARGE_MTU, 44 + .req_capabilities = SMB2_GLOBAL_CAP_LARGE_MTU, 45 45 .max_read_size = SMB3_DEFAULT_IOSIZE, 46 46 .max_write_size = SMB3_DEFAULT_IOSIZE, 47 47 .max_trans_size = SMB3_DEFAULT_TRANS_SIZE, ··· 59 59 .cap_large_files = SMB2_LARGE_FILES, 60 60 .create_lease_size = sizeof(struct create_lease_v2), 61 61 .create_durable_size = sizeof(struct create_durable_rsp), 62 - .create_durable_v2_size = sizeof(struct create_durable_v2_rsp), 62 + .create_durable_v2_size = sizeof(struct create_durable_rsp_v2), 63 63 .create_mxac_size = sizeof(struct create_mxac_rsp), 64 64 .create_disk_id_size = sizeof(struct create_disk_id_rsp), 65 65 .create_posix_size = sizeof(struct create_posix_rsp), ··· 68 68 static struct smb_version_values smb302_server_values = { 69 69 .version_string = SMB302_VERSION_STRING, 70 70 .protocol_id = SMB302_PROT_ID, 71 - .capabilities = SMB2_GLOBAL_CAP_LARGE_MTU, 71 + .req_capabilities = SMB2_GLOBAL_CAP_LARGE_MTU, 72 72 .max_read_size = SMB3_DEFAULT_IOSIZE, 73 73 .max_write_size = SMB3_DEFAULT_IOSIZE, 74 74 .max_trans_size = SMB3_DEFAULT_TRANS_SIZE, ··· 86 86 .cap_large_files = SMB2_LARGE_FILES, 87 87 .create_lease_size = sizeof(struct create_lease_v2), 88 88 .create_durable_size = sizeof(struct create_durable_rsp), 89 - .create_durable_v2_size = sizeof(struct create_durable_v2_rsp), 89 + .create_durable_v2_size = sizeof(struct create_durable_rsp_v2), 90 90 .create_mxac_size = sizeof(struct create_mxac_rsp), 91 91 .create_disk_id_size = sizeof(struct create_disk_id_rsp), 92 92 .create_posix_size = sizeof(struct create_posix_rsp), ··· 95 95 static struct smb_version_values smb311_server_values = { 96 96 .version_string = SMB311_VERSION_STRING, 97 97 .protocol_id = SMB311_PROT_ID, 98 - .capabilities = SMB2_GLOBAL_CAP_LARGE_MTU, 98 + .req_capabilities = SMB2_GLOBAL_CAP_LARGE_MTU, 99 99 .max_read_size = SMB3_DEFAULT_IOSIZE, 100 100 .max_write_size = SMB3_DEFAULT_IOSIZE, 101 101 .max_trans_size = SMB3_DEFAULT_TRANS_SIZE, ··· 113 113 .cap_large_files = SMB2_LARGE_FILES, 114 114 .create_lease_size = sizeof(struct create_lease_v2), 115 115 .create_durable_size = sizeof(struct create_durable_rsp), 116 - .create_durable_v2_size = sizeof(struct create_durable_v2_rsp), 116 + .create_durable_v2_size = sizeof(struct create_durable_rsp_v2), 117 117 .create_mxac_size = sizeof(struct create_mxac_rsp), 118 118 .create_disk_id_size = sizeof(struct create_disk_id_rsp), 119 119 .create_posix_size = sizeof(struct create_posix_rsp), ··· 204 204 conn->signing_algorithm = SIGNING_ALG_HMAC_SHA256_LE; 205 205 206 206 if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_LEASES) 207 - conn->vals->capabilities |= SMB2_GLOBAL_CAP_LEASING; 207 + conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_LEASING; 208 208 } 209 209 210 210 /** ··· 221 221 conn->signing_algorithm = SIGNING_ALG_AES_CMAC_LE; 222 222 223 223 if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_LEASES) 224 - conn->vals->capabilities |= SMB2_GLOBAL_CAP_LEASING | 224 + conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_LEASING | 225 225 SMB2_GLOBAL_CAP_DIRECTORY_LEASING; 226 226 227 227 if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION && 228 228 conn->cli_cap & SMB2_GLOBAL_CAP_ENCRYPTION) 229 - conn->vals->capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION; 229 + conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION; 230 230 231 231 if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION || 232 232 (!(server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION_OFF) && 233 233 conn->cli_cap & SMB2_GLOBAL_CAP_ENCRYPTION)) 234 - conn->vals->capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION; 234 + conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION; 235 235 236 236 if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL) 237 - conn->vals->capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL; 237 + conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL; 238 238 } 239 239 240 240 /** ··· 251 251 conn->signing_algorithm = SIGNING_ALG_AES_CMAC_LE; 252 252 253 253 if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_LEASES) 254 - conn->vals->capabilities |= SMB2_GLOBAL_CAP_LEASING | 254 + conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_LEASING | 255 255 SMB2_GLOBAL_CAP_DIRECTORY_LEASING; 256 256 257 257 if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION || 258 258 (!(server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION_OFF) && 259 259 conn->cli_cap & SMB2_GLOBAL_CAP_ENCRYPTION)) 260 - conn->vals->capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION; 260 + conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION; 261 261 262 262 if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL) 263 - conn->vals->capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL; 263 + conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL; 264 264 265 265 if (server_conf.flags & KSMBD_GLOBAL_FLAG_DURABLE_HANDLE) 266 - conn->vals->capabilities |= SMB2_GLOBAL_CAP_PERSISTENT_HANDLES; 266 + conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_PERSISTENT_HANDLES; 267 267 } 268 268 269 269 /** ··· 280 280 conn->signing_algorithm = SIGNING_ALG_AES_CMAC_LE; 281 281 282 282 if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_LEASES) 283 - conn->vals->capabilities |= SMB2_GLOBAL_CAP_LEASING | 283 + conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_LEASING | 284 284 SMB2_GLOBAL_CAP_DIRECTORY_LEASING; 285 285 286 286 if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL) 287 - conn->vals->capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL; 287 + conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL; 288 288 289 289 if (server_conf.flags & KSMBD_GLOBAL_FLAG_DURABLE_HANDLE) 290 - conn->vals->capabilities |= SMB2_GLOBAL_CAP_PERSISTENT_HANDLES; 290 + conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_PERSISTENT_HANDLES; 291 291 292 292 INIT_LIST_HEAD(&conn->preauth_sess_table); 293 293 return 0;
+104 -113
fs/smb/server/smb2pdu.c
··· 282 282 /* Not setting conn guid rsp->ServerGUID, as it 283 283 * not used by client for identifying connection 284 284 */ 285 - rsp->Capabilities = cpu_to_le32(conn->vals->capabilities); 285 + rsp->Capabilities = cpu_to_le32(conn->vals->req_capabilities); 286 286 /* Default Max Message Size till SMB2.0, 64K*/ 287 287 rsp->MaxTransactSize = cpu_to_le32(conn->vals->max_trans_size); 288 288 rsp->MaxReadSize = cpu_to_le32(conn->vals->max_read_size); ··· 956 956 * SMB 3.0 and 3.0.2 dialects use the SMB2_GLOBAL_CAP_ENCRYPTION flag. 957 957 * SMB 3.1.1 uses the cipher_type field. 958 958 */ 959 - return (conn->vals->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION) || 959 + return (conn->vals->req_capabilities & SMB2_GLOBAL_CAP_ENCRYPTION) || 960 960 conn->cipher_type; 961 961 } 962 962 ··· 1210 1210 rc = -EINVAL; 1211 1211 goto err_out; 1212 1212 } 1213 - rsp->Capabilities = cpu_to_le32(conn->vals->capabilities); 1213 + rsp->Capabilities = cpu_to_le32(conn->vals->req_capabilities); 1214 1214 1215 1215 /* For stats */ 1216 1216 conn->connection_type = conn->dialect; ··· 1538 1538 1539 1539 if (smb3_encryption_negotiated(conn) && 1540 1540 !(req->Flags & SMB2_SESSION_REQ_FLAG_BINDING)) { 1541 - rc = conn->ops->generate_encryptionkey(conn, sess); 1542 - if (rc) { 1543 - ksmbd_debug(SMB, 1544 - "SMB3 encryption key generation failed\n"); 1545 - return -EINVAL; 1546 - } 1541 + conn->ops->generate_encryptionkey(conn, sess); 1547 1542 sess->enc = true; 1548 1543 if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION) 1549 1544 rsp->SessionFlags = SMB2_SESSION_FLAG_ENCRYPT_DATA_LE; ··· 1635 1640 1636 1641 if (smb3_encryption_negotiated(conn) && 1637 1642 !(req->Flags & SMB2_SESSION_REQ_FLAG_BINDING)) { 1638 - retval = conn->ops->generate_encryptionkey(conn, sess); 1639 - if (retval) { 1640 - ksmbd_debug(SMB, 1641 - "SMB3 encryption key generation failed\n"); 1642 - return -EINVAL; 1643 - } 1643 + conn->ops->generate_encryptionkey(conn, sess); 1644 1644 sess->enc = true; 1645 1645 if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION) 1646 1646 rsp->SessionFlags = SMB2_SESSION_FLAG_ENCRYPT_DATA_LE; ··· 2158 2168 * smb2_tree_disconnect() - handler for smb tree connect request 2159 2169 * @work: smb work containing request buffer 2160 2170 * 2161 - * Return: 0 2171 + * Return: 0 on success, otherwise error 2162 2172 */ 2163 2173 int smb2_tree_disconnect(struct ksmbd_work *work) 2164 2174 { ··· 2190 2200 goto err_out; 2191 2201 } 2192 2202 2193 - WARN_ON_ONCE(atomic_dec_and_test(&tcon->refcount)); 2194 2203 tcon->t_state = TREE_DISCONNECTED; 2195 2204 write_unlock(&sess->tree_conns_lock); 2196 2205 ··· 2198 2209 rsp->hdr.Status = STATUS_NETWORK_NAME_DELETED; 2199 2210 goto err_out; 2200 2211 } 2201 - 2202 - work->tcon = NULL; 2203 2212 2204 2213 rsp->StructureSize = cpu_to_le16(4); 2205 2214 err = ksmbd_iov_pin_rsp(work, rsp, ··· 2219 2232 * smb2_session_logoff() - handler for session log off request 2220 2233 * @work: smb work containing request buffer 2221 2234 * 2222 - * Return: 0 2235 + * Return: 0 on success, otherwise error 2223 2236 */ 2224 2237 int smb2_session_logoff(struct ksmbd_work *work) 2225 2238 { ··· 2713 2726 switch (dh_idx) { 2714 2727 case DURABLE_RECONN_V2: 2715 2728 { 2716 - struct create_durable_reconn_v2_req *recon_v2; 2729 + struct create_durable_handle_reconnect_v2 *recon_v2; 2717 2730 2718 2731 if (dh_info->type == DURABLE_RECONN || 2719 2732 dh_info->type == DURABLE_REQ_V2) { ··· 2723 2736 2724 2737 if (le16_to_cpu(context->DataOffset) + 2725 2738 le32_to_cpu(context->DataLength) < 2726 - sizeof(struct create_durable_reconn_v2_req)) { 2739 + sizeof(struct create_durable_handle_reconnect_v2)) { 2727 2740 err = -EINVAL; 2728 2741 goto out; 2729 2742 } 2730 2743 2731 - recon_v2 = (struct create_durable_reconn_v2_req *)context; 2732 - persistent_id = recon_v2->Fid.PersistentFileId; 2744 + recon_v2 = (struct create_durable_handle_reconnect_v2 *)context; 2745 + persistent_id = recon_v2->dcontext.Fid.PersistentFileId; 2733 2746 dh_info->fp = ksmbd_lookup_durable_fd(persistent_id); 2734 2747 if (!dh_info->fp) { 2735 2748 ksmbd_debug(SMB, "Failed to get durable handle state\n"); ··· 2737 2750 goto out; 2738 2751 } 2739 2752 2740 - if (memcmp(dh_info->fp->create_guid, recon_v2->CreateGuid, 2753 + if (memcmp(dh_info->fp->create_guid, recon_v2->dcontext.CreateGuid, 2741 2754 SMB2_CREATE_GUID_SIZE)) { 2742 2755 err = -EBADF; 2743 2756 ksmbd_put_durable_fd(dh_info->fp); ··· 2753 2766 } 2754 2767 case DURABLE_RECONN: 2755 2768 { 2756 - struct create_durable_reconn_req *recon; 2769 + create_durable_reconn_t *recon; 2757 2770 2758 2771 if (dh_info->type == DURABLE_RECONN_V2 || 2759 2772 dh_info->type == DURABLE_REQ_V2) { ··· 2763 2776 2764 2777 if (le16_to_cpu(context->DataOffset) + 2765 2778 le32_to_cpu(context->DataLength) < 2766 - sizeof(struct create_durable_reconn_req)) { 2779 + sizeof(create_durable_reconn_t)) { 2767 2780 err = -EINVAL; 2768 2781 goto out; 2769 2782 } 2770 2783 2771 - recon = (struct create_durable_reconn_req *)context; 2784 + recon = (create_durable_reconn_t *)context; 2772 2785 persistent_id = recon->Data.Fid.PersistentFileId; 2773 2786 dh_info->fp = ksmbd_lookup_durable_fd(persistent_id); 2774 2787 if (!dh_info->fp) { ··· 2803 2816 durable_v2_blob = 2804 2817 (struct create_durable_req_v2 *)context; 2805 2818 ksmbd_debug(SMB, "Request for durable v2 open\n"); 2806 - dh_info->fp = ksmbd_lookup_fd_cguid(durable_v2_blob->CreateGuid); 2819 + dh_info->fp = ksmbd_lookup_fd_cguid(durable_v2_blob->dcontext.CreateGuid); 2807 2820 if (dh_info->fp) { 2808 2821 if (!memcmp(conn->ClientGUID, dh_info->fp->client_guid, 2809 2822 SMB2_CLIENT_GUID_SIZE)) { ··· 2821 2834 if ((lc && (lc->req_state & SMB2_LEASE_HANDLE_CACHING_LE)) || 2822 2835 req_op_level == SMB2_OPLOCK_LEVEL_BATCH) { 2823 2836 dh_info->CreateGuid = 2824 - durable_v2_blob->CreateGuid; 2837 + durable_v2_blob->dcontext.CreateGuid; 2825 2838 dh_info->persistent = 2826 - le32_to_cpu(durable_v2_blob->Flags); 2839 + le32_to_cpu(durable_v2_blob->dcontext.Flags); 2827 2840 dh_info->timeout = 2828 - le32_to_cpu(durable_v2_blob->Timeout); 2841 + le32_to_cpu(durable_v2_blob->dcontext.Timeout); 2829 2842 dh_info->type = dh_idx; 2830 2843 } 2831 2844 break; ··· 3461 3474 share_ret = ksmbd_smb_check_shared_mode(fp->filp, fp); 3462 3475 if (!test_share_config_flag(work->tcon->share_conf, KSMBD_SHARE_FLAG_OPLOCKS) || 3463 3476 (req_op_level == SMB2_OPLOCK_LEVEL_LEASE && 3464 - !(conn->vals->capabilities & SMB2_GLOBAL_CAP_LEASING))) { 3477 + !(conn->vals->req_capabilities & SMB2_GLOBAL_CAP_LEASING))) { 3465 3478 if (share_ret < 0 && !S_ISDIR(file_inode(fp->filp)->i_mode)) { 3466 3479 rc = share_ret; 3467 3480 goto err_out1; ··· 3783 3796 { 3784 3797 switch (info_level) { 3785 3798 case FILE_FULL_DIRECTORY_INFORMATION: 3786 - return sizeof(struct file_full_directory_info); 3799 + return sizeof(FILE_FULL_DIRECTORY_INFO); 3787 3800 case FILE_BOTH_DIRECTORY_INFORMATION: 3788 - return sizeof(struct file_both_directory_info); 3801 + return sizeof(FILE_BOTH_DIRECTORY_INFO); 3789 3802 case FILE_DIRECTORY_INFORMATION: 3790 - return sizeof(struct file_directory_info); 3803 + return sizeof(FILE_DIRECTORY_INFO); 3791 3804 case FILE_NAMES_INFORMATION: 3792 3805 return sizeof(struct file_names_info); 3793 3806 case FILEID_FULL_DIRECTORY_INFORMATION: 3794 - return sizeof(struct file_id_full_dir_info); 3807 + return sizeof(FILE_ID_FULL_DIR_INFO); 3795 3808 case FILEID_BOTH_DIRECTORY_INFORMATION: 3796 3809 return sizeof(struct file_id_both_directory_info); 3797 3810 case SMB_FIND_FILE_POSIX_INFO: ··· 3806 3819 switch (info_level) { 3807 3820 case FILE_FULL_DIRECTORY_INFORMATION: 3808 3821 { 3809 - struct file_full_directory_info *ffdinfo; 3822 + FILE_FULL_DIRECTORY_INFO *ffdinfo; 3810 3823 3811 - ffdinfo = (struct file_full_directory_info *)d_info->rptr; 3824 + ffdinfo = (FILE_FULL_DIRECTORY_INFO *)d_info->rptr; 3812 3825 d_info->rptr += le32_to_cpu(ffdinfo->NextEntryOffset); 3813 3826 d_info->name = ffdinfo->FileName; 3814 3827 d_info->name_len = le32_to_cpu(ffdinfo->FileNameLength); ··· 3816 3829 } 3817 3830 case FILE_BOTH_DIRECTORY_INFORMATION: 3818 3831 { 3819 - struct file_both_directory_info *fbdinfo; 3832 + FILE_BOTH_DIRECTORY_INFO *fbdinfo; 3820 3833 3821 - fbdinfo = (struct file_both_directory_info *)d_info->rptr; 3834 + fbdinfo = (FILE_BOTH_DIRECTORY_INFO *)d_info->rptr; 3822 3835 d_info->rptr += le32_to_cpu(fbdinfo->NextEntryOffset); 3823 3836 d_info->name = fbdinfo->FileName; 3824 3837 d_info->name_len = le32_to_cpu(fbdinfo->FileNameLength); ··· 3826 3839 } 3827 3840 case FILE_DIRECTORY_INFORMATION: 3828 3841 { 3829 - struct file_directory_info *fdinfo; 3842 + FILE_DIRECTORY_INFO *fdinfo; 3830 3843 3831 - fdinfo = (struct file_directory_info *)d_info->rptr; 3844 + fdinfo = (FILE_DIRECTORY_INFO *)d_info->rptr; 3832 3845 d_info->rptr += le32_to_cpu(fdinfo->NextEntryOffset); 3833 3846 d_info->name = fdinfo->FileName; 3834 3847 d_info->name_len = le32_to_cpu(fdinfo->FileNameLength); ··· 3846 3859 } 3847 3860 case FILEID_FULL_DIRECTORY_INFORMATION: 3848 3861 { 3849 - struct file_id_full_dir_info *dinfo; 3862 + FILE_ID_FULL_DIR_INFO *dinfo; 3850 3863 3851 - dinfo = (struct file_id_full_dir_info *)d_info->rptr; 3864 + dinfo = (FILE_ID_FULL_DIR_INFO *)d_info->rptr; 3852 3865 d_info->rptr += le32_to_cpu(dinfo->NextEntryOffset); 3853 3866 d_info->name = dinfo->FileName; 3854 3867 d_info->name_len = le32_to_cpu(dinfo->FileNameLength); ··· 3931 3944 switch (info_level) { 3932 3945 case FILE_FULL_DIRECTORY_INFORMATION: 3933 3946 { 3934 - struct file_full_directory_info *ffdinfo; 3947 + FILE_FULL_DIRECTORY_INFO *ffdinfo; 3935 3948 3936 - ffdinfo = (struct file_full_directory_info *)kstat; 3949 + ffdinfo = (FILE_FULL_DIRECTORY_INFO *)kstat; 3937 3950 ffdinfo->FileNameLength = cpu_to_le32(conv_len); 3938 3951 ffdinfo->EaSize = 3939 3952 smb2_get_reparse_tag_special_file(ksmbd_kstat->kstat->mode); ··· 3947 3960 } 3948 3961 case FILE_BOTH_DIRECTORY_INFORMATION: 3949 3962 { 3950 - struct file_both_directory_info *fbdinfo; 3963 + FILE_BOTH_DIRECTORY_INFO *fbdinfo; 3951 3964 3952 - fbdinfo = (struct file_both_directory_info *)kstat; 3965 + fbdinfo = (FILE_BOTH_DIRECTORY_INFO *)kstat; 3953 3966 fbdinfo->FileNameLength = cpu_to_le32(conv_len); 3954 3967 fbdinfo->EaSize = 3955 3968 smb2_get_reparse_tag_special_file(ksmbd_kstat->kstat->mode); ··· 3965 3978 } 3966 3979 case FILE_DIRECTORY_INFORMATION: 3967 3980 { 3968 - struct file_directory_info *fdinfo; 3981 + FILE_DIRECTORY_INFO *fdinfo; 3969 3982 3970 - fdinfo = (struct file_directory_info *)kstat; 3983 + fdinfo = (FILE_DIRECTORY_INFO *)kstat; 3971 3984 fdinfo->FileNameLength = cpu_to_le32(conv_len); 3972 3985 if (d_info->hide_dot_file && d_info->name[0] == '.') 3973 3986 fdinfo->ExtFileAttributes |= FILE_ATTRIBUTE_HIDDEN_LE; ··· 3987 4000 } 3988 4001 case FILEID_FULL_DIRECTORY_INFORMATION: 3989 4002 { 3990 - struct file_id_full_dir_info *dinfo; 4003 + FILE_ID_FULL_DIR_INFO *dinfo; 3991 4004 3992 - dinfo = (struct file_id_full_dir_info *)kstat; 4005 + dinfo = (FILE_ID_FULL_DIR_INFO *)kstat; 3993 4006 dinfo->FileNameLength = cpu_to_le32(conv_len); 3994 4007 dinfo->EaSize = 3995 4008 smb2_get_reparse_tag_special_file(ksmbd_kstat->kstat->mode); ··· 4193 4206 switch (info_level) { 4194 4207 case FILE_FULL_DIRECTORY_INFORMATION: 4195 4208 { 4196 - struct file_full_directory_info *ffdinfo; 4209 + FILE_FULL_DIRECTORY_INFO *ffdinfo; 4197 4210 4198 - ffdinfo = (struct file_full_directory_info *)d_info->wptr; 4211 + ffdinfo = (FILE_FULL_DIRECTORY_INFO *)d_info->wptr; 4199 4212 memcpy(ffdinfo->FileName, d_info->name, d_info->name_len); 4200 4213 ffdinfo->FileName[d_info->name_len] = 0x00; 4201 4214 ffdinfo->FileNameLength = cpu_to_le32(d_info->name_len); ··· 4204 4217 } 4205 4218 case FILE_BOTH_DIRECTORY_INFORMATION: 4206 4219 { 4207 - struct file_both_directory_info *fbdinfo; 4220 + FILE_BOTH_DIRECTORY_INFO *fbdinfo; 4208 4221 4209 - fbdinfo = (struct file_both_directory_info *)d_info->wptr; 4222 + fbdinfo = (FILE_BOTH_DIRECTORY_INFO *)d_info->wptr; 4210 4223 memcpy(fbdinfo->FileName, d_info->name, d_info->name_len); 4211 4224 fbdinfo->FileName[d_info->name_len] = 0x00; 4212 4225 fbdinfo->FileNameLength = cpu_to_le32(d_info->name_len); ··· 4215 4228 } 4216 4229 case FILE_DIRECTORY_INFORMATION: 4217 4230 { 4218 - struct file_directory_info *fdinfo; 4231 + FILE_DIRECTORY_INFO *fdinfo; 4219 4232 4220 - fdinfo = (struct file_directory_info *)d_info->wptr; 4233 + fdinfo = (FILE_DIRECTORY_INFO *)d_info->wptr; 4221 4234 memcpy(fdinfo->FileName, d_info->name, d_info->name_len); 4222 4235 fdinfo->FileName[d_info->name_len] = 0x00; 4223 4236 fdinfo->FileNameLength = cpu_to_le32(d_info->name_len); ··· 4237 4250 } 4238 4251 case FILEID_FULL_DIRECTORY_INFORMATION: 4239 4252 { 4240 - struct file_id_full_dir_info *dinfo; 4253 + FILE_ID_FULL_DIR_INFO *dinfo; 4241 4254 4242 - dinfo = (struct file_id_full_dir_info *)d_info->wptr; 4255 + dinfo = (FILE_ID_FULL_DIR_INFO *)d_info->wptr; 4243 4256 memcpy(dinfo->FileName, d_info->name, d_info->name_len); 4244 4257 dinfo->FileName[d_info->name_len] = 0x00; 4245 4258 dinfo->FileNameLength = cpu_to_le32(d_info->name_len); ··· 4501 4514 goto err_out; 4502 4515 } else { 4503 4516 no_buf_len: 4504 - ((struct file_directory_info *) 4517 + ((FILE_DIRECTORY_INFO *) 4505 4518 ((char *)rsp->Buffer + d_info.last_entry_offset)) 4506 4519 ->NextEntryOffset = 0; 4507 4520 if (d_info.data_count >= d_info.last_entry_off_align) ··· 4547 4560 smb2_set_err_rsp(work); 4548 4561 ksmbd_fd_put(work, dir_fp); 4549 4562 ksmbd_revert_fsids(work); 4550 - return 0; 4563 + return rc; 4551 4564 } 4552 4565 4553 4566 /** ··· 5120 5133 static int get_file_network_open_info(struct smb2_query_info_rsp *rsp, 5121 5134 struct ksmbd_file *fp, void *rsp_org) 5122 5135 { 5123 - struct smb2_file_ntwrk_info *file_info; 5136 + struct smb2_file_network_open_info *file_info; 5124 5137 struct kstat stat; 5125 5138 u64 time; 5126 5139 int ret; ··· 5136 5149 if (ret) 5137 5150 return ret; 5138 5151 5139 - file_info = (struct smb2_file_ntwrk_info *)rsp->Buffer; 5152 + file_info = (struct smb2_file_network_open_info *)rsp->Buffer; 5140 5153 5141 5154 file_info->CreationTime = cpu_to_le64(fp->create_time); 5142 5155 time = ksmbd_UnixTimeToNT(stat.atime); ··· 5155 5168 } 5156 5169 file_info->Reserved = cpu_to_le32(0); 5157 5170 rsp->OutputBufferLength = 5158 - cpu_to_le32(sizeof(struct smb2_file_ntwrk_info)); 5171 + cpu_to_le32(sizeof(struct smb2_file_network_open_info)); 5159 5172 return 0; 5160 5173 } 5161 5174 ··· 5463 5476 switch (fsinfoclass) { 5464 5477 case FS_DEVICE_INFORMATION: 5465 5478 { 5466 - struct filesystem_device_info *info; 5479 + FILE_SYSTEM_DEVICE_INFO *info; 5467 5480 5468 - info = (struct filesystem_device_info *)rsp->Buffer; 5481 + info = (FILE_SYSTEM_DEVICE_INFO *)rsp->Buffer; 5469 5482 5470 5483 info->DeviceType = cpu_to_le32(FILE_DEVICE_DISK); 5471 5484 info->DeviceCharacteristics = ··· 5479 5492 } 5480 5493 case FS_ATTRIBUTE_INFORMATION: 5481 5494 { 5482 - struct filesystem_attribute_info *info; 5495 + FILE_SYSTEM_ATTRIBUTE_INFO *info; 5483 5496 size_t sz; 5484 5497 5485 - info = (struct filesystem_attribute_info *)rsp->Buffer; 5498 + info = (FILE_SYSTEM_ATTRIBUTE_INFO *)rsp->Buffer; 5486 5499 info->Attributes = cpu_to_le32(FILE_SUPPORTS_OBJECT_IDS | 5487 5500 FILE_PERSISTENT_ACLS | 5488 5501 FILE_UNICODE_ON_DISK | ··· 5501 5514 "NTFS", PATH_MAX, conn->local_nls, 0); 5502 5515 len = len * 2; 5503 5516 info->FileSystemNameLen = cpu_to_le32(len); 5504 - sz = sizeof(struct filesystem_attribute_info) + len; 5517 + sz = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO) + len; 5505 5518 rsp->OutputBufferLength = cpu_to_le32(sz); 5506 5519 break; 5507 5520 } ··· 5533 5546 } 5534 5547 case FS_SIZE_INFORMATION: 5535 5548 { 5536 - struct filesystem_info *info; 5549 + FILE_SYSTEM_SIZE_INFO *info; 5537 5550 5538 - info = (struct filesystem_info *)(rsp->Buffer); 5551 + info = (FILE_SYSTEM_SIZE_INFO *)(rsp->Buffer); 5539 5552 info->TotalAllocationUnits = cpu_to_le64(stfs.f_blocks); 5540 - info->FreeAllocationUnits = cpu_to_le64(stfs.f_bfree); 5553 + info->AvailableAllocationUnits = cpu_to_le64(stfs.f_bfree); 5541 5554 info->SectorsPerAllocationUnit = cpu_to_le32(1); 5542 5555 info->BytesPerSector = cpu_to_le32(stfs.f_bsize); 5543 5556 rsp->OutputBufferLength = cpu_to_le32(24); ··· 5620 5633 } 5621 5634 case FS_POSIX_INFORMATION: 5622 5635 { 5623 - struct filesystem_posix_info *info; 5636 + FILE_SYSTEM_POSIX_INFO *info; 5624 5637 5625 5638 if (!work->tcon->posix_extensions) { 5626 5639 pr_err("client doesn't negotiate with SMB3.1.1 POSIX Extensions\n"); 5627 5640 path_put(&path); 5628 5641 return -EOPNOTSUPP; 5629 5642 } else { 5630 - info = (struct filesystem_posix_info *)(rsp->Buffer); 5643 + info = (FILE_SYSTEM_POSIX_INFO *)(rsp->Buffer); 5631 5644 info->OptimalTransferSize = cpu_to_le32(stfs.f_bsize); 5632 5645 info->BlockSize = cpu_to_le32(stfs.f_bsize); 5633 5646 info->TotalBlocks = cpu_to_le64(stfs.f_blocks); ··· 5831 5844 * smb2_close() - handler for smb2 close file command 5832 5845 * @work: smb work containing close request buffer 5833 5846 * 5834 - * Return: 0 5847 + * Return: 0 on success, otherwise error 5835 5848 */ 5836 5849 int smb2_close(struct ksmbd_work *work) 5837 5850 { ··· 5956 5969 * smb2_echo() - handler for smb2 echo(ping) command 5957 5970 * @work: smb work containing echo request buffer 5958 5971 * 5959 - * Return: 0 5972 + * Return: 0 on success, otherwise error 5960 5973 */ 5961 5974 int smb2_echo(struct ksmbd_work *work) 5962 5975 { ··· 6383 6396 * @share: ksmbd_share_config pointer 6384 6397 * 6385 6398 * Return: 0 on success, otherwise error 6386 - * TODO: need to implement an error handling for STATUS_INFO_LENGTH_MISMATCH 6387 6399 */ 6388 6400 static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp, 6389 6401 struct smb2_set_info_req *req, ··· 6395 6409 case FILE_BASIC_INFORMATION: 6396 6410 { 6397 6411 if (buf_len < sizeof(struct smb2_file_basic_info)) 6398 - return -EINVAL; 6412 + return -EMSGSIZE; 6399 6413 6400 6414 return set_file_basic_info(fp, (struct smb2_file_basic_info *)buffer, share); 6401 6415 } 6402 6416 case FILE_ALLOCATION_INFORMATION: 6403 6417 { 6404 6418 if (buf_len < sizeof(struct smb2_file_alloc_info)) 6405 - return -EINVAL; 6419 + return -EMSGSIZE; 6406 6420 6407 6421 return set_file_allocation_info(work, fp, 6408 6422 (struct smb2_file_alloc_info *)buffer); ··· 6410 6424 case FILE_END_OF_FILE_INFORMATION: 6411 6425 { 6412 6426 if (buf_len < sizeof(struct smb2_file_eof_info)) 6413 - return -EINVAL; 6427 + return -EMSGSIZE; 6414 6428 6415 6429 return set_end_of_file_info(work, fp, 6416 6430 (struct smb2_file_eof_info *)buffer); ··· 6418 6432 case FILE_RENAME_INFORMATION: 6419 6433 { 6420 6434 if (buf_len < sizeof(struct smb2_file_rename_info)) 6421 - return -EINVAL; 6435 + return -EMSGSIZE; 6422 6436 6423 6437 return set_rename_info(work, fp, 6424 6438 (struct smb2_file_rename_info *)buffer, ··· 6427 6441 case FILE_LINK_INFORMATION: 6428 6442 { 6429 6443 if (buf_len < sizeof(struct smb2_file_link_info)) 6430 - return -EINVAL; 6444 + return -EMSGSIZE; 6431 6445 6432 6446 return smb2_create_link(work, work->tcon->share_conf, 6433 6447 (struct smb2_file_link_info *)buffer, ··· 6437 6451 case FILE_DISPOSITION_INFORMATION: 6438 6452 { 6439 6453 if (buf_len < sizeof(struct smb2_file_disposition_info)) 6440 - return -EINVAL; 6454 + return -EMSGSIZE; 6441 6455 6442 6456 return set_file_disposition_info(fp, 6443 6457 (struct smb2_file_disposition_info *)buffer); ··· 6451 6465 } 6452 6466 6453 6467 if (buf_len < sizeof(struct smb2_ea_info)) 6454 - return -EINVAL; 6468 + return -EMSGSIZE; 6455 6469 6456 6470 return smb2_set_ea((struct smb2_ea_info *)buffer, 6457 6471 buf_len, &fp->filp->f_path, true); ··· 6459 6473 case FILE_POSITION_INFORMATION: 6460 6474 { 6461 6475 if (buf_len < sizeof(struct smb2_file_pos_info)) 6462 - return -EINVAL; 6476 + return -EMSGSIZE; 6463 6477 6464 6478 return set_file_position_info(fp, (struct smb2_file_pos_info *)buffer); 6465 6479 } 6466 6480 case FILE_MODE_INFORMATION: 6467 6481 { 6468 6482 if (buf_len < sizeof(struct smb2_file_mode_info)) 6469 - return -EINVAL; 6483 + return -EMSGSIZE; 6470 6484 6471 6485 return set_file_mode_info(fp, (struct smb2_file_mode_info *)buffer); 6472 6486 } ··· 6573 6587 rsp->hdr.Status = STATUS_ACCESS_DENIED; 6574 6588 else if (rc == -EINVAL) 6575 6589 rsp->hdr.Status = STATUS_INVALID_PARAMETER; 6590 + else if (rc == -EMSGSIZE) 6591 + rsp->hdr.Status = STATUS_INFO_LENGTH_MISMATCH; 6576 6592 else if (rc == -ESHARE) 6577 6593 rsp->hdr.Status = STATUS_SHARING_VIOLATION; 6578 6594 else if (rc == -ENOENT) ··· 6830 6842 rsp->hdr.Status = STATUS_END_OF_FILE; 6831 6843 smb2_set_err_rsp(work); 6832 6844 ksmbd_fd_put(work, fp); 6833 - return 0; 6845 + return -ENODATA; 6834 6846 } 6835 6847 6836 6848 ksmbd_debug(SMB, "nbytes %zu, offset %lld mincount %zu\n", ··· 7752 7764 } 7753 7765 7754 7766 src_fp = ksmbd_lookup_foreign_fd(work, 7755 - le64_to_cpu(ci_req->ResumeKey[0])); 7767 + le64_to_cpu(ci_req->SourceKeyU64[0])); 7756 7768 dst_fp = ksmbd_lookup_fd_slow(work, volatile_id, persistent_id); 7757 7769 ret = -EINVAL; 7758 7770 if (!src_fp || 7759 - src_fp->persistent_id != le64_to_cpu(ci_req->ResumeKey[1])) { 7771 + src_fp->persistent_id != le64_to_cpu(ci_req->SourceKeyU64[1])) { 7760 7772 rsp->hdr.Status = STATUS_OBJECT_NAME_NOT_FOUND; 7761 7773 goto out; 7762 7774 } ··· 7864 7876 7865 7877 nii_rsp->Capability = 0; 7866 7878 if (netdev->real_num_tx_queues > 1) 7867 - nii_rsp->Capability |= cpu_to_le32(RSS_CAPABLE); 7879 + nii_rsp->Capability |= RSS_CAPABLE; 7868 7880 if (ksmbd_rdma_capable_netdev(netdev)) 7869 - nii_rsp->Capability |= cpu_to_le32(RDMA_CAPABLE); 7881 + nii_rsp->Capability |= RDMA_CAPABLE; 7870 7882 7871 7883 nii_rsp->Next = cpu_to_le32(152); 7872 7884 nii_rsp->Reserved = 0; ··· 7892 7904 if (!ipv4_set) { 7893 7905 struct in_device *idev; 7894 7906 7895 - sockaddr_storage->Family = cpu_to_le16(INTERNETWORK); 7907 + sockaddr_storage->Family = INTERNETWORK; 7896 7908 sockaddr_storage->addr4.Port = 0; 7897 7909 7898 7910 idev = __in_dev_get_rtnl(netdev); 7899 7911 if (!idev) 7900 7912 continue; 7901 - sockaddr_storage->addr4.IPv4address = 7913 + sockaddr_storage->addr4.IPv4Address = 7902 7914 idev_ipv4_address(idev); 7903 7915 nbytes += sizeof(struct network_interface_info_ioctl_rsp); 7904 7916 ipv4_set = true; ··· 7906 7918 } else { 7907 7919 struct inet6_dev *idev6; 7908 7920 struct inet6_ifaddr *ifa; 7909 - __u8 *ipv6_addr = sockaddr_storage->addr6.IPv6address; 7921 + __u8 *ipv6_addr = sockaddr_storage->addr6.IPv6Address; 7910 7922 7911 - sockaddr_storage->Family = cpu_to_le16(INTERNETWORKV6); 7923 + sockaddr_storage->Family = INTERNETWORKV6; 7912 7924 sockaddr_storage->addr6.Port = 0; 7913 7925 sockaddr_storage->addr6.FlowInfo = 0; 7914 7926 ··· 7972 7984 goto err_out; 7973 7985 } 7974 7986 7975 - neg_rsp->Capabilities = cpu_to_le32(conn->vals->capabilities); 7987 + neg_rsp->Capabilities = cpu_to_le32(conn->vals->req_capabilities); 7976 7988 memset(neg_rsp->Guid, 0, SMB2_CLIENT_GUID_SIZE); 7977 7989 neg_rsp->SecurityMode = cpu_to_le16(conn->srv_sec_mode); 7978 7990 neg_rsp->Dialect = cpu_to_le16(conn->dialect); ··· 8110 8122 return -ENOENT; 8111 8123 8112 8124 memset(key_rsp, 0, sizeof(*key_rsp)); 8113 - key_rsp->ResumeKey[0] = req->VolatileFileId; 8114 - key_rsp->ResumeKey[1] = req->PersistentFileId; 8125 + key_rsp->ResumeKeyU64[0] = req->VolatileFileId; 8126 + key_rsp->ResumeKeyU64[1] = req->PersistentFileId; 8115 8127 ksmbd_fd_put(work, fp); 8116 8128 8117 8129 return 0; ··· 8152 8164 id = req->VolatileFileId; 8153 8165 8154 8166 if (req->Flags != cpu_to_le32(SMB2_0_IOCTL_IS_FSCTL)) { 8155 - rsp->hdr.Status = STATUS_NOT_SUPPORTED; 8167 + ret = -EOPNOTSUPP; 8156 8168 goto out; 8157 8169 } 8158 8170 ··· 8172 8184 case FSCTL_DFS_GET_REFERRALS: 8173 8185 case FSCTL_DFS_GET_REFERRALS_EX: 8174 8186 /* Not support DFS yet */ 8187 + ret = -EOPNOTSUPP; 8175 8188 rsp->hdr.Status = STATUS_FS_DRIVER_REQUIRED; 8176 - goto out; 8189 + goto out2; 8177 8190 case FSCTL_CREATE_OR_GET_OBJECT_ID: 8178 8191 { 8179 8192 struct file_object_buf_type1_ioctl_rsp *obj_buf; ··· 8464 8475 rsp->hdr.Status = STATUS_BUFFER_TOO_SMALL; 8465 8476 else if (ret < 0 || rsp->hdr.Status == 0) 8466 8477 rsp->hdr.Status = STATUS_INVALID_PARAMETER; 8478 + 8479 + out2: 8467 8480 smb2_set_err_rsp(work); 8468 - return 0; 8481 + return ret; 8469 8482 } 8470 8483 8471 8484 /** ··· 8746 8755 * smb2_oplock_break() - dispatcher for smb2.0 and 2.1 oplock/lease break 8747 8756 * @work: smb work containing oplock/lease break command buffer 8748 8757 * 8749 - * Return: 0 8758 + * Return: 0 on success, otherwise error 8750 8759 */ 8751 8760 int smb2_oplock_break(struct ksmbd_work *work) 8752 8761 { ··· 8769 8778 le16_to_cpu(req->StructureSize)); 8770 8779 rsp->hdr.Status = STATUS_INVALID_PARAMETER; 8771 8780 smb2_set_err_rsp(work); 8781 + return -EINVAL; 8772 8782 } 8773 8783 8774 8784 return 0; ··· 8779 8787 * smb2_notify() - handler for smb2 notify request 8780 8788 * @work: smb work containing notify command buffer 8781 8789 * 8782 - * Return: 0 8790 + * Return: 0 on success, otherwise error 8783 8791 */ 8784 8792 int smb2_notify(struct ksmbd_work *work) 8785 8793 { ··· 8793 8801 if (work->next_smb2_rcv_hdr_off && req->hdr.NextCommand) { 8794 8802 rsp->hdr.Status = STATUS_INTERNAL_ERROR; 8795 8803 smb2_set_err_rsp(work); 8796 - return 0; 8804 + return -EIO; 8797 8805 } 8798 8806 8799 8807 smb2_set_err_rsp(work); 8800 8808 rsp->hdr.Status = STATUS_NOT_IMPLEMENTED; 8801 - return 0; 8809 + return -EOPNOTSUPP; 8802 8810 } 8803 8811 8804 8812 /** ··· 8853 8861 iov[0].iov_base = (char *)&hdr->ProtocolId; 8854 8862 iov[0].iov_len = len; 8855 8863 8856 - if (ksmbd_sign_smb2_pdu(work->conn, work->sess->sess_key, iov, 1, 8857 - signature)) 8858 - return 0; 8864 + ksmbd_sign_smb2_pdu(work->conn, work->sess->sess_key, iov, 1, 8865 + signature); 8859 8866 8860 8867 if (memcmp(signature, signature_req, SMB2_SIGNATURE_SIZE)) { 8861 8868 pr_err("bad smb2 signature\n"); ··· 8887 8896 iov = &work->iov[work->iov_idx]; 8888 8897 } 8889 8898 8890 - if (!ksmbd_sign_smb2_pdu(work->conn, work->sess->sess_key, iov, n_vec, 8891 - signature)) 8892 - memcpy(hdr->Signature, signature, SMB2_SIGNATURE_SIZE); 8899 + ksmbd_sign_smb2_pdu(work->conn, work->sess->sess_key, iov, n_vec, 8900 + signature); 8901 + memcpy(hdr->Signature, signature, SMB2_SIGNATURE_SIZE); 8893 8902 } 8894 8903 8895 8904 /**
-107
fs/smb/server/smb2pdu.h
··· 66 66 /* Apple Defined Contexts */ 67 67 #define SMB2_CREATE_AAPL "AAPL" 68 68 69 - struct create_durable_req_v2 { 70 - struct create_context_hdr ccontext; 71 - __u8 Name[8]; 72 - __le32 Timeout; 73 - __le32 Flags; 74 - __u8 Reserved[8]; 75 - __u8 CreateGuid[16]; 76 - } __packed; 77 - 78 69 #define DURABLE_HANDLE_MAX_TIMEOUT 300000 79 - 80 - struct create_durable_reconn_req { 81 - struct create_context_hdr ccontext; 82 - __u8 Name[8]; 83 - union { 84 - __u8 Reserved[16]; 85 - struct { 86 - __u64 PersistentFileId; 87 - __u64 VolatileFileId; 88 - } Fid; 89 - } Data; 90 - } __packed; 91 - 92 - struct create_durable_reconn_v2_req { 93 - struct create_context_hdr ccontext; 94 - __u8 Name[8]; 95 - struct { 96 - __u64 PersistentFileId; 97 - __u64 VolatileFileId; 98 - } Fid; 99 - __u8 CreateGuid[16]; 100 - __le32 Flags; 101 - } __packed; 102 70 103 71 struct create_alloc_size_req { 104 72 struct create_context_hdr ccontext; ··· 83 115 } Data; 84 116 } __packed; 85 117 86 - /* See MS-SMB2 2.2.13.2.11 */ 87 - /* Flags */ 88 - #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 89 - struct create_durable_v2_rsp { 90 - struct create_context_hdr ccontext; 91 - __u8 Name[8]; 92 - __le32 Timeout; 93 - __le32 Flags; 94 - } __packed; 95 - 96 118 /* equivalent of the contents of SMB3.1.1 POSIX open context response */ 97 119 struct create_posix_rsp { 98 120 struct create_context_hdr ccontext; ··· 96 138 97 139 #define SMB2_0_IOCTL_IS_FSCTL 0x00000001 98 140 99 - struct smb_sockaddr_in { 100 - __be16 Port; 101 - __be32 IPv4address; 102 - __u8 Reserved[8]; 103 - } __packed; 104 - 105 - struct smb_sockaddr_in6 { 106 - __be16 Port; 107 - __be32 FlowInfo; 108 - __u8 IPv6address[16]; 109 - __be32 ScopeId; 110 - } __packed; 111 - 112 - #define INTERNETWORK 0x0002 113 - #define INTERNETWORKV6 0x0017 114 - 115 141 struct sockaddr_storage_rsp { 116 142 __le16 Family; 117 143 union { ··· 104 162 }; 105 163 } __packed; 106 164 107 - #define RSS_CAPABLE 0x00000001 108 - #define RDMA_CAPABLE 0x00000002 109 - 110 - struct network_interface_info_ioctl_rsp { 111 - __le32 Next; /* next interface. zero if this is last one */ 112 - __le32 IfIndex; 113 - __le32 Capability; /* RSS or RDMA Capable */ 114 - __le32 Reserved; 115 - __le64 LinkSpeed; 116 - char SockAddr_Storage[128]; 117 - } __packed; 118 - 119 165 struct file_object_buf_type1_ioctl_rsp { 120 166 __u8 ObjectId[16]; 121 167 __u8 BirthVolumeId[16]; 122 168 __u8 BirthObjectId[16]; 123 169 __u8 DomainId[16]; 124 - } __packed; 125 - 126 - struct resume_key_ioctl_rsp { 127 - __u64 ResumeKey[3]; 128 - __le32 ContextLength; 129 - __u8 Context[4]; /* ignored, Windows sets to 4 bytes of zero */ 130 - } __packed; 131 - 132 - struct srv_copychunk { 133 - __le64 SourceOffset; 134 - __le64 TargetOffset; 135 - __le32 Length; 136 - __le32 Reserved; 137 - } __packed; 138 - 139 - struct copychunk_ioctl_req { 140 - __le64 ResumeKey[3]; 141 - __le32 ChunkCount; 142 - __le32 Reserved; 143 - struct srv_copychunk Chunks[] __counted_by_le(ChunkCount); 144 - } __packed; 145 - 146 - struct copychunk_ioctl_rsp { 147 - __le32 ChunksWritten; 148 - __le32 ChunkBytesWritten; 149 - __le32 TotalBytesWritten; 150 170 } __packed; 151 171 152 172 struct file_sparse { ··· 203 299 __le64 StreamSize; 204 300 __le64 StreamAllocationSize; 205 301 char StreamName[]; 206 - } __packed; 207 - 208 - struct smb2_file_ntwrk_info { 209 - __le64 CreationTime; 210 - __le64 LastAccessTime; 211 - __le64 LastWriteTime; 212 - __le64 ChangeTime; 213 - __le64 AllocationSize; 214 - __le64 EndOfFile; 215 - __le32 Attributes; 216 - __le32 Reserved; 217 302 } __packed; 218 303 219 304 struct smb2_file_standard_info {
+11 -265
fs/smb/server/smb_common.h
··· 10 10 11 11 #include "glob.h" 12 12 #include "nterr.h" 13 - #include "../common/cifsglob.h" 13 + #include "../common/smbglob.h" 14 14 #include "../common/smb2pdu.h" 15 + #include "../common/fscc.h" 15 16 #include "smb2pdu.h" 16 17 17 18 /* ksmbd's Specific ERRNO */ ··· 30 29 31 30 #define SMB_ECHO_INTERVAL (60 * HZ) 32 31 33 - #define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */ 34 - 35 32 #define MAX_STREAM_PROT_LEN 0x00FFFFFF 36 33 37 34 /* Responses when opening a file. */ ··· 38 39 #define F_CREATED 2 39 40 #define F_OVERWRITTEN 3 40 41 41 - /* 42 - * File Attribute flags 43 - */ 44 - #define ATTR_POSIX_SEMANTICS 0x01000000 45 - #define ATTR_BACKUP_SEMANTICS 0x02000000 46 - #define ATTR_DELETE_ON_CLOSE 0x04000000 47 - #define ATTR_SEQUENTIAL_SCAN 0x08000000 48 - #define ATTR_RANDOM_ACCESS 0x10000000 49 - #define ATTR_NO_BUFFERING 0x20000000 50 - #define ATTR_WRITE_THROUGH 0x80000000 51 - 52 - /* List of FileSystemAttributes - see 2.5.1 of MS-FSCC */ 53 - #define FILE_SUPPORTS_SPARSE_VDL 0x10000000 /* faster nonsparse extend */ 54 - #define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000 /* allow ioctl dup extents */ 55 - #define FILE_SUPPORT_INTEGRITY_STREAMS 0x04000000 56 - #define FILE_SUPPORTS_USN_JOURNAL 0x02000000 57 - #define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000 58 - #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000 59 - #define FILE_SUPPORTS_HARD_LINKS 0x00400000 60 - #define FILE_SUPPORTS_TRANSACTIONS 0x00200000 61 - #define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000 62 - #define FILE_READ_ONLY_VOLUME 0x00080000 63 - #define FILE_NAMED_STREAMS 0x00040000 64 - #define FILE_SUPPORTS_ENCRYPTION 0x00020000 65 - #define FILE_SUPPORTS_OBJECT_IDS 0x00010000 66 - #define FILE_VOLUME_IS_COMPRESSED 0x00008000 67 - #define FILE_SUPPORTS_POSIX_UNLINK_RENAME 0x00000400 68 - #define FILE_RETURNS_CLEANUP_RESULT_INFO 0x00000200 69 - #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100 70 - #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080 71 - #define FILE_SUPPORTS_SPARSE_FILES 0x00000040 72 - #define FILE_VOLUME_QUOTAS 0x00000020 73 - #define FILE_FILE_COMPRESSION 0x00000010 74 - #define FILE_PERSISTENT_ACLS 0x00000008 75 - #define FILE_UNICODE_ON_DISK 0x00000004 76 - #define FILE_CASE_PRESERVED_NAMES 0x00000002 77 - #define FILE_CASE_SENSITIVE_SEARCH 0x00000001 78 - 79 - #define FILE_READ_DATA 0x00000001 /* Data can be read from the file */ 80 - #define FILE_WRITE_DATA 0x00000002 /* Data can be written to the file */ 81 - #define FILE_APPEND_DATA 0x00000004 /* Data can be appended to the file */ 82 - #define FILE_READ_EA 0x00000008 /* Extended attributes associated */ 83 - /* with the file can be read */ 84 - #define FILE_WRITE_EA 0x00000010 /* Extended attributes associated */ 85 - /* with the file can be written */ 86 - #define FILE_EXECUTE 0x00000020 /*Data can be read into memory from */ 87 - /* the file using system paging I/O */ 88 - #define FILE_DELETE_CHILD 0x00000040 89 - #define FILE_READ_ATTRIBUTES 0x00000080 /* Attributes associated with the */ 90 - /* file can be read */ 91 - #define FILE_WRITE_ATTRIBUTES 0x00000100 /* Attributes associated with the */ 92 - /* file can be written */ 93 - #define DELETE 0x00010000 /* The file can be deleted */ 94 - #define READ_CONTROL 0x00020000 /* The access control list and */ 95 - /* ownership associated with the */ 96 - /* file can be read */ 97 - #define WRITE_DAC 0x00040000 /* The access control list and */ 98 - /* ownership associated with the */ 99 - /* file can be written. */ 100 - #define WRITE_OWNER 0x00080000 /* Ownership information associated */ 101 - /* with the file can be written */ 102 - #define SYNCHRONIZE 0x00100000 /* The file handle can waited on to */ 103 - /* synchronize with the completion */ 104 - /* of an input/output request */ 105 - #define GENERIC_ALL 0x10000000 106 - #define GENERIC_EXECUTE 0x20000000 107 - #define GENERIC_WRITE 0x40000000 108 - #define GENERIC_READ 0x80000000 109 - /* In summary - Relevant file */ 110 - /* access flags from CIFS are */ 111 - /* file_read_data, file_write_data */ 112 - /* file_execute, file_read_attributes*/ 113 - /* write_dac, and delete. */ 114 - 42 + /* Combinations of file access permission bits */ 115 43 #define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \ 116 44 | FILE_READ_ATTRIBUTES \ 117 45 | DELETE | READ_CONTROL | WRITE_DAC \ ··· 49 123 | FILE_WRITE_ATTRIBUTES \ 50 124 | DELETE | READ_CONTROL | WRITE_DAC \ 51 125 | WRITE_OWNER | SYNCHRONIZE) 52 - #define SET_FILE_EXEC_RIGHTS (FILE_READ_EA | FILE_WRITE_EA | FILE_EXECUTE \ 53 - | FILE_READ_ATTRIBUTES \ 54 - | FILE_WRITE_ATTRIBUTES \ 55 - | DELETE | READ_CONTROL | WRITE_DAC \ 56 - | WRITE_OWNER | SYNCHRONIZE) 57 - 58 - #define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \ 59 - | READ_CONTROL | SYNCHRONIZE) 60 126 61 127 /* generic flags for file open */ 62 128 #define GENERIC_READ_FLAGS (READ_CONTROL | FILE_READ_DATA | \ ··· 69 151 FILE_EXECUTE | FILE_DELETE_CHILD | \ 70 152 FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES) 71 153 72 - #define SMB1_PROTO_NUMBER cpu_to_le32(0x424d53ff) 73 - #define SMB_COM_NEGOTIATE 0x72 74 - #define SMB1_CLIENT_GUID_SIZE (16) 154 + #define SMB_COM_NEGOTIATE 0x72 /* See MS-CIFS 2.2.2.1 */ 75 155 156 + /* See MS-CIFS 2.2.3.1 */ 76 157 #define SMBFLG_RESPONSE 0x80 /* this PDU is a response from server */ 77 158 159 + /* 160 + * See MS-CIFS 2.2.3.1 161 + * MS-SMB 2.2.3.1 162 + */ 78 163 #define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40) 79 164 #define SMBFLG2_EXT_SEC cpu_to_le16(0x800) 80 165 #define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000) 81 166 #define SMBFLG2_UNICODE cpu_to_le16(0x8000) 82 167 83 - struct smb_hdr { 84 - __be32 smb_buf_length; 85 - __u8 Protocol[4]; 86 - __u8 Command; 87 - union { 88 - struct { 89 - __u8 ErrorClass; 90 - __u8 Reserved; 91 - __le16 Error; 92 - } __packed DosError; 93 - __le32 CifsError; 94 - } __packed Status; 95 - __u8 Flags; 96 - __le16 Flags2; /* note: le */ 97 - __le16 PidHigh; 98 - union { 99 - struct { 100 - __le32 SequenceNumber; /* le */ 101 - __u32 Reserved; /* zero */ 102 - } __packed Sequence; 103 - __u8 SecuritySignature[8]; /* le */ 104 - } __packed Signature; 105 - __u8 pad[2]; 106 - __le16 Tid; 107 - __le16 Pid; 108 - __le16 Uid; 109 - __le16 Mid; 110 - __u8 WordCount; 111 - } __packed; 112 - 113 - struct smb_negotiate_req { 114 - struct smb_hdr hdr; /* wct = 0 */ 115 - __le16 ByteCount; 116 - unsigned char DialectsArray[]; 117 - } __packed; 118 - 168 + /* See MS-CIFS 2.2.4.52.2 */ 119 169 struct smb_negotiate_rsp { 120 170 struct smb_hdr hdr; /* wct = 17 */ 121 171 __le16 DialectIndex; /* 0xFFFF = no dialect acceptable */ 122 172 __le16 ByteCount; 123 173 } __packed; 124 - 125 - struct filesystem_attribute_info { 126 - __le32 Attributes; 127 - __le32 MaxPathNameComponentLength; 128 - __le32 FileSystemNameLen; 129 - __le16 FileSystemName[]; /* do not have to save this - get subset? */ 130 - } __packed; 131 - 132 - struct filesystem_device_info { 133 - __le32 DeviceType; 134 - __le32 DeviceCharacteristics; 135 - } __packed; /* device info level 0x104 */ 136 174 137 175 struct filesystem_vol_info { 138 176 __le64 VolumeCreationTime; ··· 97 223 __le16 Reserved; 98 224 __le16 VolumeLabel[]; 99 225 } __packed; 100 - 101 - struct filesystem_info { 102 - __le64 TotalAllocationUnits; 103 - __le64 FreeAllocationUnits; 104 - __le32 SectorsPerAllocationUnit; 105 - __le32 BytesPerSector; 106 - } __packed; /* size info, level 0x103 */ 107 226 108 227 #define EXTENDED_INFO_MAGIC 0x43667364 /* Cfsd */ 109 228 #define STRING_LENGTH 28 ··· 114 247 struct fs_extended_info extended_info; 115 248 } __packed; 116 249 117 - struct file_directory_info { 118 - __le32 NextEntryOffset; 119 - __u32 FileIndex; 120 - __le64 CreationTime; 121 - __le64 LastAccessTime; 122 - __le64 LastWriteTime; 123 - __le64 ChangeTime; 124 - __le64 EndOfFile; 125 - __le64 AllocationSize; 126 - __le32 ExtFileAttributes; 127 - __le32 FileNameLength; 128 - char FileName[]; 129 - } __packed; /* level 0x101 FF resp data */ 130 - 131 250 struct file_names_info { 132 251 __le32 NextEntryOffset; 133 252 __u32 FileIndex; 134 253 __le32 FileNameLength; 135 254 char FileName[]; 136 255 } __packed; /* level 0xc FF resp data */ 137 - 138 - struct file_full_directory_info { 139 - __le32 NextEntryOffset; 140 - __u32 FileIndex; 141 - __le64 CreationTime; 142 - __le64 LastAccessTime; 143 - __le64 LastWriteTime; 144 - __le64 ChangeTime; 145 - __le64 EndOfFile; 146 - __le64 AllocationSize; 147 - __le32 ExtFileAttributes; 148 - __le32 FileNameLength; 149 - __le32 EaSize; 150 - char FileName[]; 151 - } __packed; /* level 0x102 FF resp */ 152 - 153 - struct file_both_directory_info { 154 - __le32 NextEntryOffset; 155 - __u32 FileIndex; 156 - __le64 CreationTime; 157 - __le64 LastAccessTime; 158 - __le64 LastWriteTime; 159 - __le64 ChangeTime; 160 - __le64 EndOfFile; 161 - __le64 AllocationSize; 162 - __le32 ExtFileAttributes; 163 - __le32 FileNameLength; 164 - __le32 EaSize; /* length of the xattrs */ 165 - __u8 ShortNameLength; 166 - __u8 Reserved; 167 - __u8 ShortName[24]; 168 - char FileName[]; 169 - } __packed; /* level 0x104 FFrsp data */ 170 256 171 257 struct file_id_both_directory_info { 172 258 __le32 NextEntryOffset; ··· 141 321 char FileName[]; 142 322 } __packed; 143 323 144 - struct file_id_full_dir_info { 145 - __le32 NextEntryOffset; 146 - __u32 FileIndex; 147 - __le64 CreationTime; 148 - __le64 LastAccessTime; 149 - __le64 LastWriteTime; 150 - __le64 ChangeTime; 151 - __le64 EndOfFile; 152 - __le64 AllocationSize; 153 - __le32 ExtFileAttributes; 154 - __le32 FileNameLength; 155 - __le32 EaSize; /* EA size */ 156 - __le32 Reserved; 157 - __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/ 158 - char FileName[]; 159 - } __packed; /* level 0x105 FF rsp data */ 160 - 161 - struct smb_version_values { 162 - char *version_string; 163 - __u16 protocol_id; 164 - __le16 lock_cmd; 165 - __u32 capabilities; 166 - __u32 max_read_size; 167 - __u32 max_write_size; 168 - __u32 max_trans_size; 169 - __u32 max_credits; 170 - __u32 large_lock_type; 171 - __u32 exclusive_lock_type; 172 - __u32 shared_lock_type; 173 - __u32 unlock_lock_type; 174 - size_t header_size; 175 - size_t max_header_size; 176 - size_t read_rsp_size; 177 - unsigned int cap_unix; 178 - unsigned int cap_nt_find; 179 - unsigned int cap_large_files; 180 - __u16 signing_enabled; 181 - __u16 signing_required; 182 - size_t create_lease_size; 183 - size_t create_durable_size; 184 - size_t create_durable_v2_size; 185 - size_t create_mxac_size; 186 - size_t create_disk_id_size; 187 - size_t create_posix_size; 188 - }; 189 - 190 - struct filesystem_posix_info { 191 - /* For undefined recommended transfer size return -1 in that field */ 192 - __le32 OptimalTransferSize; /* bsize on some os, iosize on other os */ 193 - __le32 BlockSize; 194 - /* The next three fields are in terms of the block size. 195 - * (above). If block size is unknown, 4096 would be a 196 - * reasonable block size for a server to report. 197 - * Note that returning the blocks/blocksavail removes need 198 - * to make a second call (to QFSInfo level 0x103 to get this info. 199 - * UserBlockAvail is typically less than or equal to BlocksAvail, 200 - * if no distinction is made return the same value in each 201 - */ 202 - __le64 TotalBlocks; 203 - __le64 BlocksAvail; /* bfree */ 204 - __le64 UserBlocksAvail; /* bavail */ 205 - /* For undefined Node fields or FSID return -1 */ 206 - __le64 TotalFileNodes; 207 - __le64 FreeFileNodes; 208 - __le64 FileSysIdentifier; /* fsid */ 209 - /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */ 210 - /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */ 211 - } __packed; 212 - 213 324 struct smb_version_ops { 214 325 u16 (*get_cmd_val)(struct ksmbd_work *swork); 215 326 int (*init_rsp_hdr)(struct ksmbd_work *swork); ··· 153 402 int (*check_sign_req)(struct ksmbd_work *work); 154 403 void (*set_sign_rsp)(struct ksmbd_work *work); 155 404 int (*generate_signingkey)(struct ksmbd_session *sess, struct ksmbd_conn *conn); 156 - int (*generate_encryptionkey)(struct ksmbd_conn *conn, struct ksmbd_session *sess); 405 + void (*generate_encryptionkey)(struct ksmbd_conn *conn, struct ksmbd_session *sess); 157 406 bool (*is_transform_hdr)(void *buf); 158 407 int (*decrypt_req)(struct ksmbd_work *work); 159 408 int (*encrypt_resp)(struct ksmbd_work *work); ··· 203 452 unsigned int ksmbd_server_side_copy_max_total_size(void); 204 453 bool is_asterisk(char *p); 205 454 __le32 smb_map_generic_desired_access(__le32 daccess); 206 - 207 - static inline unsigned int get_rfc1002_len(void *buf) 208 - { 209 - return be32_to_cpu(*((__be32 *)buf)) & 0xffffff; 210 - } 211 455 #endif /* __SMB_COMMON_H__ */
+5 -2
fs/smb/server/transport_ipc.c
··· 553 553 up_write(&ipc_msg_table_lock); 554 554 555 555 ret = ipc_msg_send(msg); 556 - if (ret) 556 + if (ret) { 557 + down_write(&ipc_msg_table_lock); 557 558 goto out; 559 + } 558 560 559 561 ret = wait_event_interruptible_timeout(entry.wait, 560 562 entry.response != NULL, 561 563 IPC_WAIT_TIMEOUT); 564 + 565 + down_write(&ipc_msg_table_lock); 562 566 if (entry.response) { 563 567 ret = ipc_validate_msg(&entry); 564 568 if (ret) { ··· 571 567 } 572 568 } 573 569 out: 574 - down_write(&ipc_msg_table_lock); 575 570 hash_del(&entry.ipc_table_hlist); 576 571 up_write(&ipc_msg_table_lock); 577 572 return entry.response;
+32 -8
fs/smb/server/transport_rdma.c
··· 19 19 #include <rdma/rdma_cm.h> 20 20 #include <rdma/rw.h> 21 21 22 + #define __SMBDIRECT_SOCKET_DISCONNECT(__sc) smb_direct_disconnect_rdma_connection(__sc) 23 + 22 24 #include "glob.h" 23 25 #include "connection.h" 24 26 #include "smb_common.h" ··· 233 231 struct smbdirect_socket *sc = 234 232 container_of(work, struct smbdirect_socket, disconnect_work); 235 233 234 + if (sc->first_error == 0) 235 + sc->first_error = -ECONNABORTED; 236 + 236 237 /* 237 238 * make sure this and other work is not queued again 238 239 * but here we don't block and avoid ··· 245 240 disable_work(&sc->recv_io.posted.refill_work); 246 241 disable_delayed_work(&sc->idle.timer_work); 247 242 disable_work(&sc->idle.immediate_work); 248 - 249 - if (sc->first_error == 0) 250 - sc->first_error = -ECONNABORTED; 251 243 252 244 switch (sc->status) { 253 245 case SMBDIRECT_SOCKET_NEGOTIATE_NEEDED: ··· 289 287 static void 290 288 smb_direct_disconnect_rdma_connection(struct smbdirect_socket *sc) 291 289 { 290 + if (sc->first_error == 0) 291 + sc->first_error = -ECONNABORTED; 292 + 292 293 /* 293 294 * make sure other work (than disconnect_work) is 294 295 * not queued again but here we don't block and avoid ··· 300 295 disable_work(&sc->recv_io.posted.refill_work); 301 296 disable_work(&sc->idle.immediate_work); 302 297 disable_delayed_work(&sc->idle.timer_work); 303 - 304 - if (sc->first_error == 0) 305 - sc->first_error = -ECONNABORTED; 306 298 307 299 switch (sc->status) { 308 300 case SMBDIRECT_SOCKET_RESOLVE_ADDR_FAILED: ··· 641 639 return; 642 640 } 643 641 sc->recv_io.reassembly.full_packet_received = true; 644 - WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_NEGOTIATE_NEEDED); 642 + /* 643 + * Some drivers (at least mlx5_ib) might post a 644 + * recv completion before RDMA_CM_EVENT_ESTABLISHED, 645 + * we need to adjust our expectation in that case. 646 + */ 647 + if (!sc->first_error && sc->status == SMBDIRECT_SOCKET_RDMA_CONNECT_RUNNING) 648 + sc->status = SMBDIRECT_SOCKET_NEGOTIATE_NEEDED; 649 + if (SMBDIRECT_CHECK_STATUS_WARN(sc, SMBDIRECT_SOCKET_NEGOTIATE_NEEDED)) { 650 + put_recvmsg(sc, recvmsg); 651 + smb_direct_disconnect_rdma_connection(sc); 652 + return; 653 + } 645 654 sc->status = SMBDIRECT_SOCKET_NEGOTIATE_RUNNING; 646 655 enqueue_reassembly(sc, recvmsg, 0); 647 656 wake_up(&sc->status_wait); ··· 1738 1725 1739 1726 switch (event->event) { 1740 1727 case RDMA_CM_EVENT_ESTABLISHED: { 1741 - WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RDMA_CONNECT_RUNNING); 1728 + /* 1729 + * Some drivers (at least mlx5_ib) might post a 1730 + * recv completion before RDMA_CM_EVENT_ESTABLISHED, 1731 + * we need to adjust our expectation in that case. 1732 + * 1733 + * As we already started the negotiation, we just 1734 + * ignore RDMA_CM_EVENT_ESTABLISHED here. 1735 + */ 1736 + if (!sc->first_error && sc->status > SMBDIRECT_SOCKET_RDMA_CONNECT_RUNNING) 1737 + break; 1738 + if (SMBDIRECT_CHECK_STATUS_DISCONNECT(sc, SMBDIRECT_SOCKET_RDMA_CONNECT_RUNNING)) 1739 + break; 1742 1740 sc->status = SMBDIRECT_SOCKET_NEGOTIATE_NEEDED; 1743 1741 wake_up(&sc->status_wait); 1744 1742 break;
+6 -35
fs/smb/server/transport_tcp.c
··· 22 22 struct socket *ksmbd_socket; 23 23 struct list_head entry; 24 24 char *name; 25 - struct mutex sock_release_lock; 26 25 int state; 27 26 }; 28 27 ··· 53 54 static inline void ksmbd_tcp_reuseaddr(struct socket *sock) 54 55 { 55 56 sock_set_reuseaddr(sock->sk); 56 - } 57 - 58 - static inline void ksmbd_tcp_rcv_timeout(struct socket *sock, s64 secs) 59 - { 60 - if (secs && secs < MAX_SCHEDULE_TIMEOUT / HZ - 1) 61 - WRITE_ONCE(sock->sk->sk_rcvtimeo, secs * HZ); 62 - else 63 - WRITE_ONCE(sock->sk->sk_rcvtimeo, MAX_SCHEDULE_TIMEOUT); 64 - } 65 - 66 - static inline void ksmbd_tcp_snd_timeout(struct socket *sock, s64 secs) 67 - { 68 - sock_set_sndtimeo(sock->sk, secs); 69 57 } 70 58 71 59 static struct tcp_transport *alloc_transport(struct socket *client_sk) ··· 222 236 unsigned int max_ip_conns; 223 237 224 238 while (!kthread_should_stop()) { 225 - mutex_lock(&iface->sock_release_lock); 226 239 if (!iface->ksmbd_socket) { 227 - mutex_unlock(&iface->sock_release_lock); 228 240 break; 229 241 } 230 - ret = kernel_accept(iface->ksmbd_socket, &client_sk, 231 - SOCK_NONBLOCK); 232 - mutex_unlock(&iface->sock_release_lock); 233 - if (ret) { 234 - if (ret == -EAGAIN) 235 - /* check for new connections every 100 msecs */ 236 - schedule_timeout_interruptible(HZ / 10); 242 + ret = kernel_accept(iface->ksmbd_socket, &client_sk, 0); 243 + if (ret == -EINVAL) 244 + break; 245 + if (ret) 237 246 continue; 238 - } 239 247 240 248 if (!server_conf.max_ip_connections) 241 249 goto skip_max_ip_conns_limit; ··· 438 458 if (!ksmbd_socket) 439 459 return; 440 460 441 - /* set zero to timeout */ 442 - ksmbd_tcp_rcv_timeout(ksmbd_socket, 0); 443 - ksmbd_tcp_snd_timeout(ksmbd_socket, 0); 444 - 445 461 ret = kernel_sock_shutdown(ksmbd_socket, SHUT_RDWR); 446 462 if (ret) 447 463 pr_err("Failed to shutdown socket: %d\n", ret); ··· 508 532 goto out_error; 509 533 } 510 534 511 - ksmbd_socket->sk->sk_rcvtimeo = KSMBD_TCP_RECV_TIMEOUT; 512 - ksmbd_socket->sk->sk_sndtimeo = KSMBD_TCP_SEND_TIMEOUT; 513 - 514 535 ret = kernel_listen(ksmbd_socket, KSMBD_SOCKET_BACKLOG); 515 536 if (ret) { 516 537 pr_err("Port listen() error: %d\n", ret); ··· 577 604 if (iface && iface->state == IFACE_STATE_CONFIGURED) { 578 605 ksmbd_debug(CONN, "netdev-down event: netdev(%s) is going down\n", 579 606 iface->name); 607 + kernel_sock_shutdown(iface->ksmbd_socket, SHUT_RDWR); 580 608 tcp_stop_kthread(iface->ksmbd_kthread); 581 609 iface->ksmbd_kthread = NULL; 582 - mutex_lock(&iface->sock_release_lock); 583 - tcp_destroy_socket(iface->ksmbd_socket); 610 + sock_release(iface->ksmbd_socket); 584 611 iface->ksmbd_socket = NULL; 585 - mutex_unlock(&iface->sock_release_lock); 586 612 587 613 iface->state = IFACE_STATE_DOWN; 588 614 break; ··· 644 672 iface->name = ifname; 645 673 iface->state = IFACE_STATE_DOWN; 646 674 list_add(&iface->entry, &iface_list); 647 - mutex_init(&iface->sock_release_lock); 648 675 return iface; 649 676 } 650 677
+5 -2
fs/smb/server/vfs.c
··· 303 303 struct file_lock_context *ctx = locks_inode_context(file_inode(filp)); 304 304 int error = 0; 305 305 306 + if (start == end) 307 + return 0; 308 + 306 309 if (!ctx || list_empty_careful(&ctx->flc_posix)) 307 310 return 0; 308 311 ··· 770 767 if (size < inode->i_size) { 771 768 err = check_lock_range(filp, size, 772 769 inode->i_size - 1, WRITE); 773 - } else { 770 + } else if (size > inode->i_size) { 774 771 err = check_lock_range(filp, inode->i_size, 775 772 size - 1, WRITE); 776 773 } ··· 1594 1591 */ 1595 1592 void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat) 1596 1593 { 1597 - struct file_directory_info *info = (struct file_directory_info *)(*p); 1594 + FILE_DIRECTORY_INFO *info = (FILE_DIRECTORY_INFO *)(*p); 1598 1595 struct kstat *kstat = ksmbd_kstat->kstat; 1599 1596 u64 time; 1600 1597
+62 -26
fs/smb/server/vfs_cache.c
··· 112 112 113 113 read_lock(&inode_hash_lock); 114 114 ci = __ksmbd_inode_lookup(dentry); 115 - if (ci) { 116 - ret = KSMBD_INODE_STATUS_OK; 117 - if (ci->m_flags & (S_DEL_PENDING | S_DEL_ON_CLS)) 118 - ret = KSMBD_INODE_STATUS_PENDING_DELETE; 119 - atomic_dec(&ci->m_count); 120 - } 121 115 read_unlock(&inode_hash_lock); 116 + if (!ci) 117 + return ret; 118 + 119 + down_read(&ci->m_lock); 120 + if (ci->m_flags & (S_DEL_PENDING | S_DEL_ON_CLS)) 121 + ret = KSMBD_INODE_STATUS_PENDING_DELETE; 122 + else 123 + ret = KSMBD_INODE_STATUS_OK; 124 + up_read(&ci->m_lock); 125 + 126 + atomic_dec(&ci->m_count); 122 127 return ret; 123 128 } 124 129 125 130 bool ksmbd_inode_pending_delete(struct ksmbd_file *fp) 126 131 { 127 - return (fp->f_ci->m_flags & (S_DEL_PENDING | S_DEL_ON_CLS)); 132 + struct ksmbd_inode *ci = fp->f_ci; 133 + int ret; 134 + 135 + down_read(&ci->m_lock); 136 + ret = (ci->m_flags & (S_DEL_PENDING | S_DEL_ON_CLS)); 137 + up_read(&ci->m_lock); 138 + 139 + return ret; 128 140 } 129 141 130 142 void ksmbd_set_inode_pending_delete(struct ksmbd_file *fp) 131 143 { 132 - fp->f_ci->m_flags |= S_DEL_PENDING; 144 + struct ksmbd_inode *ci = fp->f_ci; 145 + 146 + down_write(&ci->m_lock); 147 + ci->m_flags |= S_DEL_PENDING; 148 + up_write(&ci->m_lock); 133 149 } 134 150 135 151 void ksmbd_clear_inode_pending_delete(struct ksmbd_file *fp) 136 152 { 137 - fp->f_ci->m_flags &= ~S_DEL_PENDING; 153 + struct ksmbd_inode *ci = fp->f_ci; 154 + 155 + down_write(&ci->m_lock); 156 + ci->m_flags &= ~S_DEL_PENDING; 157 + up_write(&ci->m_lock); 138 158 } 139 159 140 160 void ksmbd_fd_set_delete_on_close(struct ksmbd_file *fp, 141 161 int file_info) 142 162 { 143 - if (ksmbd_stream_fd(fp)) { 144 - fp->f_ci->m_flags |= S_DEL_ON_CLS_STREAM; 145 - return; 146 - } 163 + struct ksmbd_inode *ci = fp->f_ci; 147 164 148 - fp->f_ci->m_flags |= S_DEL_ON_CLS; 165 + down_write(&ci->m_lock); 166 + if (ksmbd_stream_fd(fp)) 167 + ci->m_flags |= S_DEL_ON_CLS_STREAM; 168 + else 169 + ci->m_flags |= S_DEL_ON_CLS; 170 + up_write(&ci->m_lock); 149 171 } 150 172 151 173 static void ksmbd_inode_hash(struct ksmbd_inode *ci) ··· 279 257 struct file *filp; 280 258 281 259 filp = fp->filp; 282 - if (ksmbd_stream_fd(fp) && (ci->m_flags & S_DEL_ON_CLS_STREAM)) { 283 - ci->m_flags &= ~S_DEL_ON_CLS_STREAM; 284 - err = ksmbd_vfs_remove_xattr(file_mnt_idmap(filp), 285 - &filp->f_path, 286 - fp->stream.name, 287 - true); 288 - if (err) 289 - pr_err("remove xattr failed : %s\n", 290 - fp->stream.name); 260 + 261 + if (ksmbd_stream_fd(fp)) { 262 + bool remove_stream_xattr = false; 263 + 264 + down_write(&ci->m_lock); 265 + if (ci->m_flags & S_DEL_ON_CLS_STREAM) { 266 + ci->m_flags &= ~S_DEL_ON_CLS_STREAM; 267 + remove_stream_xattr = true; 268 + } 269 + up_write(&ci->m_lock); 270 + 271 + if (remove_stream_xattr) { 272 + err = ksmbd_vfs_remove_xattr(file_mnt_idmap(filp), 273 + &filp->f_path, 274 + fp->stream.name, 275 + true); 276 + if (err) 277 + pr_err("remove xattr failed : %s\n", 278 + fp->stream.name); 279 + } 291 280 } 292 281 293 282 if (atomic_dec_and_test(&ci->m_count)) { 283 + bool do_unlink = false; 284 + 294 285 down_write(&ci->m_lock); 295 286 if (ci->m_flags & (S_DEL_ON_CLS | S_DEL_PENDING)) { 296 287 ci->m_flags &= ~(S_DEL_ON_CLS | S_DEL_PENDING); 297 - up_write(&ci->m_lock); 298 - ksmbd_vfs_unlink(filp); 299 - down_write(&ci->m_lock); 288 + do_unlink = true; 300 289 } 301 290 up_write(&ci->m_lock); 291 + 292 + if (do_unlink) 293 + ksmbd_vfs_unlink(filp); 302 294 303 295 ksmbd_inode_free(ci); 304 296 }