138c8a9a5SSteve French /* SPDX-License-Identifier: LGPL-2.1 */
238c8a9a5SSteve French /*
338c8a9a5SSteve French *
438c8a9a5SSteve French * Structure definitions for io control for cifs/smb3
538c8a9a5SSteve French *
638c8a9a5SSteve French * Copyright (c) 2015 Steve French <steve.french@primarydata.com>
738c8a9a5SSteve French *
838c8a9a5SSteve French */
938c8a9a5SSteve French
1038c8a9a5SSteve French struct smb_mnt_fs_info {
1138c8a9a5SSteve French __u32 version; /* 0001 */
1238c8a9a5SSteve French __u16 protocol_id;
1338c8a9a5SSteve French __u16 tcon_flags;
1438c8a9a5SSteve French __u32 vol_serial_number;
1538c8a9a5SSteve French __u32 vol_create_time;
1638c8a9a5SSteve French __u32 share_caps;
1738c8a9a5SSteve French __u32 share_flags;
1838c8a9a5SSteve French __u32 sector_flags;
1938c8a9a5SSteve French __u32 optimal_sector_size;
2038c8a9a5SSteve French __u32 max_bytes_chunk;
2138c8a9a5SSteve French __u32 fs_attributes;
2238c8a9a5SSteve French __u32 max_path_component;
2338c8a9a5SSteve French __u32 device_type;
2438c8a9a5SSteve French __u32 device_characteristics;
2538c8a9a5SSteve French __u32 maximal_access;
2638c8a9a5SSteve French __u64 cifs_posix_caps;
2738c8a9a5SSteve French } __packed;
2838c8a9a5SSteve French
29*67062c84SSteve French struct smb_mnt_tcon_info {
30*67062c84SSteve French __u32 tid;
31*67062c84SSteve French __u64 session_id;
32*67062c84SSteve French } __packed;
33*67062c84SSteve French
3438c8a9a5SSteve French struct smb_snapshot_array {
3538c8a9a5SSteve French __u32 number_of_snapshots;
3638c8a9a5SSteve French __u32 number_of_snapshots_returned;
3738c8a9a5SSteve French __u32 snapshot_array_size;
3838c8a9a5SSteve French /* snapshots[]; */
3938c8a9a5SSteve French } __packed;
4038c8a9a5SSteve French
4138c8a9a5SSteve French /* query_info flags */
4238c8a9a5SSteve French #define PASSTHRU_QUERY_INFO 0x00000000
4338c8a9a5SSteve French #define PASSTHRU_FSCTL 0x00000001
4438c8a9a5SSteve French #define PASSTHRU_SET_INFO 0x00000002
4538c8a9a5SSteve French struct smb_query_info {
4638c8a9a5SSteve French __u32 info_type;
4738c8a9a5SSteve French __u32 file_info_class;
4838c8a9a5SSteve French __u32 additional_information;
4938c8a9a5SSteve French __u32 flags;
5038c8a9a5SSteve French __u32 input_buffer_length;
5138c8a9a5SSteve French __u32 output_buffer_length;
5238c8a9a5SSteve French /* char buffer[]; */
5338c8a9a5SSteve French } __packed;
5438c8a9a5SSteve French
5538c8a9a5SSteve French /*
5638c8a9a5SSteve French * Dumping the commonly used 16 byte (e.g. CCM and GCM128) keys still supported
5738c8a9a5SSteve French * for backlevel compatibility, but is not sufficient for dumping the less
5838c8a9a5SSteve French * frequently used GCM256 (32 byte) keys (see the newer "CIFS_DUMP_FULL_KEY"
5938c8a9a5SSteve French * ioctl for dumping decryption info for GCM256 mounts)
6038c8a9a5SSteve French */
6138c8a9a5SSteve French struct smb3_key_debug_info {
6238c8a9a5SSteve French __u64 Suid;
6338c8a9a5SSteve French __u16 cipher_type;
6438c8a9a5SSteve French __u8 auth_key[16]; /* SMB2_NTLMV2_SESSKEY_SIZE */
6538c8a9a5SSteve French __u8 smb3encryptionkey[SMB3_SIGN_KEY_SIZE];
6638c8a9a5SSteve French __u8 smb3decryptionkey[SMB3_SIGN_KEY_SIZE];
6738c8a9a5SSteve French } __packed;
6838c8a9a5SSteve French
6938c8a9a5SSteve French /*
7038c8a9a5SSteve French * Dump variable-sized keys
7138c8a9a5SSteve French */
7238c8a9a5SSteve French struct smb3_full_key_debug_info {
7338c8a9a5SSteve French /* INPUT: size of userspace buffer */
7438c8a9a5SSteve French __u32 in_size;
7538c8a9a5SSteve French
7638c8a9a5SSteve French /*
7738c8a9a5SSteve French * INPUT: 0 for current user, otherwise session to dump
7838c8a9a5SSteve French * OUTPUT: session id that was dumped
7938c8a9a5SSteve French */
8038c8a9a5SSteve French __u64 session_id;
8138c8a9a5SSteve French __u16 cipher_type;
8238c8a9a5SSteve French __u8 session_key_length;
8338c8a9a5SSteve French __u8 server_in_key_length;
8438c8a9a5SSteve French __u8 server_out_key_length;
8538c8a9a5SSteve French __u8 data[];
8638c8a9a5SSteve French /*
8738c8a9a5SSteve French * return this struct with the keys appended at the end:
8838c8a9a5SSteve French * __u8 session_key[session_key_length];
8938c8a9a5SSteve French * __u8 server_in_key[server_in_key_length];
9038c8a9a5SSteve French * __u8 server_out_key[server_out_key_length];
9138c8a9a5SSteve French */
9238c8a9a5SSteve French } __packed;
9338c8a9a5SSteve French
9438c8a9a5SSteve French struct smb3_notify {
9538c8a9a5SSteve French __u32 completion_filter;
9638c8a9a5SSteve French bool watch_tree;
9738c8a9a5SSteve French } __packed;
9838c8a9a5SSteve French
9938c8a9a5SSteve French struct smb3_notify_info {
10038c8a9a5SSteve French __u32 completion_filter;
10138c8a9a5SSteve French bool watch_tree;
10238c8a9a5SSteve French __u32 data_len; /* size of notify data below */
10338c8a9a5SSteve French __u8 notify_data[];
10438c8a9a5SSteve French } __packed;
10538c8a9a5SSteve French
10638c8a9a5SSteve French #define CIFS_IOCTL_MAGIC 0xCF
10738c8a9a5SSteve French #define CIFS_IOC_COPYCHUNK_FILE _IOW(CIFS_IOCTL_MAGIC, 3, int)
10838c8a9a5SSteve French #define CIFS_IOC_SET_INTEGRITY _IO(CIFS_IOCTL_MAGIC, 4)
10938c8a9a5SSteve French #define CIFS_IOC_GET_MNT_INFO _IOR(CIFS_IOCTL_MAGIC, 5, struct smb_mnt_fs_info)
11038c8a9a5SSteve French #define CIFS_ENUMERATE_SNAPSHOTS _IOR(CIFS_IOCTL_MAGIC, 6, struct smb_snapshot_array)
11138c8a9a5SSteve French #define CIFS_QUERY_INFO _IOWR(CIFS_IOCTL_MAGIC, 7, struct smb_query_info)
11238c8a9a5SSteve French #define CIFS_DUMP_KEY _IOWR(CIFS_IOCTL_MAGIC, 8, struct smb3_key_debug_info)
11338c8a9a5SSteve French #define CIFS_IOC_NOTIFY _IOW(CIFS_IOCTL_MAGIC, 9, struct smb3_notify)
11438c8a9a5SSteve French #define CIFS_DUMP_FULL_KEY _IOWR(CIFS_IOCTL_MAGIC, 10, struct smb3_full_key_debug_info)
11538c8a9a5SSteve French #define CIFS_IOC_NOTIFY_INFO _IOWR(CIFS_IOCTL_MAGIC, 11, struct smb3_notify_info)
116*67062c84SSteve French #define CIFS_IOC_GET_TCON_INFO _IOR(CIFS_IOCTL_MAGIC, 12, struct smb_mnt_tcon_info)
11738c8a9a5SSteve French #define CIFS_IOC_SHUTDOWN _IOR('X', 125, __u32)
11838c8a9a5SSteve French
11938c8a9a5SSteve French /*
12038c8a9a5SSteve French * Flags for going down operation
12138c8a9a5SSteve French */
12238c8a9a5SSteve French #define CIFS_GOING_FLAGS_DEFAULT 0x0 /* going down */
12338c8a9a5SSteve French #define CIFS_GOING_FLAGS_LOGFLUSH 0x1 /* flush log but not data */
12438c8a9a5SSteve French #define CIFS_GOING_FLAGS_NOLOGFLUSH 0x2 /* don't flush log nor data */
12538c8a9a5SSteve French
cifs_forced_shutdown(struct cifs_sb_info * sbi)12638c8a9a5SSteve French static inline bool cifs_forced_shutdown(struct cifs_sb_info *sbi)
12738c8a9a5SSteve French {
12838c8a9a5SSteve French if (CIFS_MOUNT_SHUTDOWN & sbi->mnt_cifs_flags)
12938c8a9a5SSteve French return true;
13038c8a9a5SSteve French else
13138c8a9a5SSteve French return false;
13238c8a9a5SSteve French }
133