#include <linux/inetdevice.h>
#include <net/addrconf.h>
#include <linux/syscalls.h>
#include <linux/namei.h>
#include <linux/statfs.h>
#include <linux/ethtool.h>
#include <linux/falloc.h>
#include <linux/mount.h>
#include <linux/filelock.h>
#include "glob.h"
#include "smbfsctl.h"
#include "oplock.h"
#include "smbacl.h"
#include "auth.h"
#include "asn1.h"
#include "connection.h"
#include "transport_ipc.h"
#include "transport_rdma.h"
#include "vfs.h"
#include "vfs_cache.h"
#include "misc.h"
#include "server.h"
#include "smb_common.h"
#include "../common/smb2status.h"
#include "ksmbd_work.h"
#include "mgmt/user_config.h"
#include "mgmt/share_config.h"
#include "mgmt/tree_connect.h"
#include "mgmt/user_session.h"
#include "mgmt/ksmbd_ida.h"
#include "ndr.h"
static void __wbuf(struct ksmbd_work *work, void **req, void **rsp)
{ … }
#define WORK_BUFFERS(w, rq, rs) …
static inline bool check_session_id(struct ksmbd_conn *conn, u64 id)
{ … }
struct channel *lookup_chann_list(struct ksmbd_session *sess, struct ksmbd_conn *conn)
{ … }
int smb2_get_ksmbd_tcon(struct ksmbd_work *work)
{ … }
void smb2_set_err_rsp(struct ksmbd_work *work)
{ … }
bool is_smb2_neg_cmd(struct ksmbd_work *work)
{ … }
bool is_smb2_rsp(struct ksmbd_work *work)
{ … }
u16 get_smb2_cmd_val(struct ksmbd_work *work)
{ … }
void set_smb2_rsp_status(struct ksmbd_work *work, __le32 err)
{ … }
int init_smb2_neg_rsp(struct ksmbd_work *work)
{ … }
int smb2_set_rsp_credits(struct ksmbd_work *work)
{ … }
static void init_chained_smb2_rsp(struct ksmbd_work *work)
{ … }
bool is_chained_smb2_message(struct ksmbd_work *work)
{ … }
int init_smb2_rsp_hdr(struct ksmbd_work *work)
{ … }
int smb2_allocate_rsp_buf(struct ksmbd_work *work)
{ … }
int smb2_check_user_session(struct ksmbd_work *work)
{ … }
static char *
smb2_get_name(const char *src, const int maxlen, struct nls_table *local_nls)
{ … }
int setup_async_work(struct ksmbd_work *work, void (*fn)(void **), void **arg)
{ … }
void release_async_work(struct ksmbd_work *work)
{ … }
void smb2_send_interim_resp(struct ksmbd_work *work, __le32 status)
{ … }
static __le32 smb2_get_reparse_tag_special_file(umode_t mode)
{ … }
static int smb2_get_dos_mode(struct kstat *stat, int attribute)
{ … }
static void build_preauth_ctxt(struct smb2_preauth_neg_context *pneg_ctxt,
__le16 hash_id)
{ … }
static void build_encrypt_ctxt(struct smb2_encryption_neg_context *pneg_ctxt,
__le16 cipher_type)
{ … }
static void build_sign_cap_ctxt(struct smb2_signing_capabilities *pneg_ctxt,
__le16 sign_algo)
{ … }
static void build_posix_ctxt(struct smb2_posix_neg_context *pneg_ctxt)
{ … }
static unsigned int assemble_neg_contexts(struct ksmbd_conn *conn,
struct smb2_negotiate_rsp *rsp)
{ … }
static __le32 decode_preauth_ctxt(struct ksmbd_conn *conn,
struct smb2_preauth_neg_context *pneg_ctxt,
int ctxt_len)
{ … }
static void decode_encrypt_ctxt(struct ksmbd_conn *conn,
struct smb2_encryption_neg_context *pneg_ctxt,
int ctxt_len)
{ … }
bool smb3_encryption_negotiated(struct ksmbd_conn *conn)
{ … }
static void decode_compress_ctxt(struct ksmbd_conn *conn,
struct smb2_compression_capabilities_context *pneg_ctxt)
{ … }
static void decode_sign_cap_ctxt(struct ksmbd_conn *conn,
struct smb2_signing_capabilities *pneg_ctxt,
int ctxt_len)
{ … }
static __le32 deassemble_neg_contexts(struct ksmbd_conn *conn,
struct smb2_negotiate_req *req,
unsigned int len_of_smb)
{ … }
int smb2_handle_negotiate(struct ksmbd_work *work)
{ … }
static int alloc_preauth_hash(struct ksmbd_session *sess,
struct ksmbd_conn *conn)
{ … }
static int generate_preauth_hash(struct ksmbd_work *work)
{ … }
static int decode_negotiation_token(struct ksmbd_conn *conn,
struct negotiate_message *negblob,
size_t sz)
{ … }
static int ntlm_negotiate(struct ksmbd_work *work,
struct negotiate_message *negblob,
size_t negblob_len, struct smb2_sess_setup_rsp *rsp)
{ … }
static struct authenticate_message *user_authblob(struct ksmbd_conn *conn,
struct smb2_sess_setup_req *req)
{ … }
static struct ksmbd_user *session_user(struct ksmbd_conn *conn,
struct smb2_sess_setup_req *req)
{ … }
static int ntlm_authenticate(struct ksmbd_work *work,
struct smb2_sess_setup_req *req,
struct smb2_sess_setup_rsp *rsp)
{ … }
#ifdef CONFIG_SMB_SERVER_KERBEROS5
static int krb5_authenticate(struct ksmbd_work *work,
struct smb2_sess_setup_req *req,
struct smb2_sess_setup_rsp *rsp)
{ … }
#else
static int krb5_authenticate(struct ksmbd_work *work,
struct smb2_sess_setup_req *req,
struct smb2_sess_setup_rsp *rsp)
{
return -EOPNOTSUPP;
}
#endif
int smb2_sess_setup(struct ksmbd_work *work)
{ … }
int smb2_tree_connect(struct ksmbd_work *work)
{ … }
static int smb2_create_open_flags(bool file_present, __le32 access,
__le32 disposition,
int *may_flags,
__le32 coptions,
umode_t mode)
{ … }
int smb2_tree_disconnect(struct ksmbd_work *work)
{ … }
int smb2_session_logoff(struct ksmbd_work *work)
{ … }
static noinline int create_smb2_pipe(struct ksmbd_work *work)
{ … }
static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
const struct path *path, bool get_write)
{ … }
static noinline int smb2_set_stream_name_xattr(const struct path *path,
struct ksmbd_file *fp,
char *stream_name, int s_type)
{ … }
static int smb2_remove_smb_xattrs(const struct path *path)
{ … }
static int smb2_create_truncate(const struct path *path)
{ … }
static void smb2_new_xattrs(struct ksmbd_tree_connect *tcon, const struct path *path,
struct ksmbd_file *fp)
{ … }
static void smb2_update_xattrs(struct ksmbd_tree_connect *tcon,
const struct path *path, struct ksmbd_file *fp)
{ … }
static int smb2_creat(struct ksmbd_work *work, struct path *parent_path,
struct path *path, char *name, int open_flags,
umode_t posix_mode, bool is_dir)
{ … }
static int smb2_create_sd_buffer(struct ksmbd_work *work,
struct smb2_create_req *req,
const struct path *path)
{ … }
static void ksmbd_acls_fattr(struct smb_fattr *fattr,
struct mnt_idmap *idmap,
struct inode *inode)
{ … }
enum { … };
struct durable_info { … };
static int parse_durable_handle_context(struct ksmbd_work *work,
struct smb2_create_req *req,
struct lease_ctx_info *lc,
struct durable_info *dh_info)
{ … }
int smb2_open(struct ksmbd_work *work)
{ … }
static int readdir_info_level_struct_sz(int info_level)
{ … }
static int dentry_name(struct ksmbd_dir_info *d_info, int info_level)
{ … }
static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level,
struct ksmbd_dir_info *d_info,
struct ksmbd_kstat *ksmbd_kstat)
{ … }
struct smb2_query_dir_private { … };
static void lock_dir(struct ksmbd_file *dir_fp)
{ … }
static void unlock_dir(struct ksmbd_file *dir_fp)
{ … }
static int process_query_dir_entries(struct smb2_query_dir_private *priv)
{ … }
static int reserve_populate_dentry(struct ksmbd_dir_info *d_info,
int info_level)
{ … }
static bool __query_dir(struct dir_context *ctx, const char *name, int namlen,
loff_t offset, u64 ino, unsigned int d_type)
{ … }
static int verify_info_level(int info_level)
{ … }
static int smb2_resp_buf_len(struct ksmbd_work *work, unsigned short hdr2_len)
{ … }
static int smb2_calc_max_out_buf_len(struct ksmbd_work *work,
unsigned short hdr2_len,
unsigned int out_buf_len)
{ … }
int smb2_query_dir(struct ksmbd_work *work)
{ … }
static int buffer_check_err(int reqOutputBufferLength,
struct smb2_query_info_rsp *rsp,
void *rsp_org)
{ … }
static void get_standard_info_pipe(struct smb2_query_info_rsp *rsp,
void *rsp_org)
{ … }
static void get_internal_info_pipe(struct smb2_query_info_rsp *rsp, u64 num,
void *rsp_org)
{ … }
static int smb2_get_info_file_pipe(struct ksmbd_session *sess,
struct smb2_query_info_req *req,
struct smb2_query_info_rsp *rsp,
void *rsp_org)
{ … }
static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,
struct smb2_query_info_req *req,
struct smb2_query_info_rsp *rsp, void *rsp_org)
{ … }
static void get_file_access_info(struct smb2_query_info_rsp *rsp,
struct ksmbd_file *fp, void *rsp_org)
{ … }
static int get_file_basic_info(struct smb2_query_info_rsp *rsp,
struct ksmbd_file *fp, void *rsp_org)
{ … }
static int get_file_standard_info(struct smb2_query_info_rsp *rsp,
struct ksmbd_file *fp, void *rsp_org)
{ … }
static void get_file_alignment_info(struct smb2_query_info_rsp *rsp,
void *rsp_org)
{ … }
static int get_file_all_info(struct ksmbd_work *work,
struct smb2_query_info_rsp *rsp,
struct ksmbd_file *fp,
void *rsp_org)
{ … }
static void get_file_alternate_info(struct ksmbd_work *work,
struct smb2_query_info_rsp *rsp,
struct ksmbd_file *fp,
void *rsp_org)
{ … }
static int get_file_stream_info(struct ksmbd_work *work,
struct smb2_query_info_rsp *rsp,
struct ksmbd_file *fp,
void *rsp_org)
{ … }
static int get_file_internal_info(struct smb2_query_info_rsp *rsp,
struct ksmbd_file *fp, void *rsp_org)
{ … }
static int get_file_network_open_info(struct smb2_query_info_rsp *rsp,
struct ksmbd_file *fp, void *rsp_org)
{ … }
static void get_file_ea_info(struct smb2_query_info_rsp *rsp, void *rsp_org)
{ … }
static void get_file_position_info(struct smb2_query_info_rsp *rsp,
struct ksmbd_file *fp, void *rsp_org)
{ … }
static void get_file_mode_info(struct smb2_query_info_rsp *rsp,
struct ksmbd_file *fp, void *rsp_org)
{ … }
static int get_file_compression_info(struct smb2_query_info_rsp *rsp,
struct ksmbd_file *fp, void *rsp_org)
{ … }
static int get_file_attribute_tag_info(struct smb2_query_info_rsp *rsp,
struct ksmbd_file *fp, void *rsp_org)
{ … }
static int find_file_posix_info(struct smb2_query_info_rsp *rsp,
struct ksmbd_file *fp, void *rsp_org)
{ … }
static int smb2_get_info_file(struct ksmbd_work *work,
struct smb2_query_info_req *req,
struct smb2_query_info_rsp *rsp)
{ … }
static int smb2_get_info_filesystem(struct ksmbd_work *work,
struct smb2_query_info_req *req,
struct smb2_query_info_rsp *rsp)
{ … }
static int smb2_get_info_sec(struct ksmbd_work *work,
struct smb2_query_info_req *req,
struct smb2_query_info_rsp *rsp)
{ … }
int smb2_query_info(struct ksmbd_work *work)
{ … }
static noinline int smb2_close_pipe(struct ksmbd_work *work)
{ … }
int smb2_close(struct ksmbd_work *work)
{ … }
int smb2_echo(struct ksmbd_work *work)
{ … }
static int smb2_rename(struct ksmbd_work *work,
struct ksmbd_file *fp,
struct smb2_file_rename_info *file_info,
struct nls_table *local_nls)
{ … }
static int smb2_create_link(struct ksmbd_work *work,
struct ksmbd_share_config *share,
struct smb2_file_link_info *file_info,
unsigned int buf_len, struct file *filp,
struct nls_table *local_nls)
{ … }
static int set_file_basic_info(struct ksmbd_file *fp,
struct smb2_file_basic_info *file_info,
struct ksmbd_share_config *share)
{ … }
static int set_file_allocation_info(struct ksmbd_work *work,
struct ksmbd_file *fp,
struct smb2_file_alloc_info *file_alloc_info)
{ … }
static int set_end_of_file_info(struct ksmbd_work *work, struct ksmbd_file *fp,
struct smb2_file_eof_info *file_eof_info)
{ … }
static int set_rename_info(struct ksmbd_work *work, struct ksmbd_file *fp,
struct smb2_file_rename_info *rename_info,
unsigned int buf_len)
{ … }
static int set_file_disposition_info(struct ksmbd_file *fp,
struct smb2_file_disposition_info *file_info)
{ … }
static int set_file_position_info(struct ksmbd_file *fp,
struct smb2_file_pos_info *file_info)
{ … }
static int set_file_mode_info(struct ksmbd_file *fp,
struct smb2_file_mode_info *file_info)
{ … }
static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,
struct smb2_set_info_req *req,
struct ksmbd_share_config *share)
{ … }
static int smb2_set_info_sec(struct ksmbd_file *fp, int addition_info,
char *buffer, int buf_len)
{ … }
int smb2_set_info(struct ksmbd_work *work)
{ … }
static noinline int smb2_read_pipe(struct ksmbd_work *work)
{ … }
static int smb2_set_remote_key_for_rdma(struct ksmbd_work *work,
struct smb2_buffer_desc_v1 *desc,
__le32 Channel,
__le16 ChannelInfoLength)
{ … }
static ssize_t smb2_read_rdma_channel(struct ksmbd_work *work,
struct smb2_read_req *req, void *data_buf,
size_t length)
{ … }
int smb2_read(struct ksmbd_work *work)
{ … }
static noinline int smb2_write_pipe(struct ksmbd_work *work)
{ … }
static ssize_t smb2_write_rdma_channel(struct ksmbd_work *work,
struct smb2_write_req *req,
struct ksmbd_file *fp,
loff_t offset, size_t length, bool sync)
{ … }
int smb2_write(struct ksmbd_work *work)
{ … }
int smb2_flush(struct ksmbd_work *work)
{ … }
int smb2_cancel(struct ksmbd_work *work)
{ … }
struct file_lock *smb_flock_init(struct file *f)
{ … }
static int smb2_set_flock_flags(struct file_lock *flock, int flags)
{ … }
static struct ksmbd_lock *smb2_lock_init(struct file_lock *flock,
unsigned int cmd, int flags,
struct list_head *lock_list)
{ … }
static void smb2_remove_blocked_lock(void **argv)
{ … }
static inline bool lock_defer_pending(struct file_lock *fl)
{ … }
int smb2_lock(struct ksmbd_work *work)
{ … }
static int fsctl_copychunk(struct ksmbd_work *work,
struct copychunk_ioctl_req *ci_req,
unsigned int cnt_code,
unsigned int input_count,
unsigned long long volatile_id,
unsigned long long persistent_id,
struct smb2_ioctl_rsp *rsp)
{ … }
static __be32 idev_ipv4_address(struct in_device *idev)
{ … }
static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,
struct smb2_ioctl_rsp *rsp,
unsigned int out_buf_len)
{ … }
static int fsctl_validate_negotiate_info(struct ksmbd_conn *conn,
struct validate_negotiate_info_req *neg_req,
struct validate_negotiate_info_rsp *neg_rsp,
unsigned int in_buf_len)
{ … }
static int fsctl_query_allocated_ranges(struct ksmbd_work *work, u64 id,
struct file_allocated_range_buffer *qar_req,
struct file_allocated_range_buffer *qar_rsp,
unsigned int in_count, unsigned int *out_count)
{ … }
static int fsctl_pipe_transceive(struct ksmbd_work *work, u64 id,
unsigned int out_buf_len,
struct smb2_ioctl_req *req,
struct smb2_ioctl_rsp *rsp)
{ … }
static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,
struct file_sparse *sparse)
{ … }
static int fsctl_request_resume_key(struct ksmbd_work *work,
struct smb2_ioctl_req *req,
struct resume_key_ioctl_rsp *key_rsp)
{ … }
int smb2_ioctl(struct ksmbd_work *work)
{ … }
static void smb20_oplock_break_ack(struct ksmbd_work *work)
{ … }
static int check_lease_state(struct lease *lease, __le32 req_state)
{ … }
static void smb21_lease_break_ack(struct ksmbd_work *work)
{ … }
int smb2_oplock_break(struct ksmbd_work *work)
{ … }
int smb2_notify(struct ksmbd_work *work)
{ … }
bool smb2_is_sign_req(struct ksmbd_work *work, unsigned int command)
{ … }
int smb2_check_sign_req(struct ksmbd_work *work)
{ … }
void smb2_set_sign_rsp(struct ksmbd_work *work)
{ … }
int smb3_check_sign_req(struct ksmbd_work *work)
{ … }
void smb3_set_sign_rsp(struct ksmbd_work *work)
{ … }
void smb3_preauth_hash_rsp(struct ksmbd_work *work)
{ … }
static void fill_transform_hdr(void *tr_buf, char *old_buf, __le16 cipher_type)
{ … }
int smb3_encrypt_resp(struct ksmbd_work *work)
{ … }
bool smb3_is_transform_hdr(void *buf)
{ … }
int smb3_decrypt_req(struct ksmbd_work *work)
{ … }
bool smb3_11_final_sess_setup_resp(struct ksmbd_work *work)
{ … }