mirror of
https://github.com/torvalds/linux.git
synced 2026-10-28 17:55:02 +01:00
macOS clients (Finder, and specifically Time Machine's backupd) send an "AAPL" SMB2 create context on CREATE to negotiate AAPL-specific server capabilities (server_caps/vol_caps/model string). Without a response to this context, macOS Time Machine over SMB does not work at all. Add the AAPL create context structs (create_aapl_rsp, aapl_server_query_req) and create_aapl_rsp_buf(), which builds the kAAPL_SERVER_QUERY response mirroring the layout observed from macOS's own smbd, including the model string workaround: omitting the model string when the client requested it causes smbfs.kext to enter a broken disconnect path requiring a full macOS reboot to recover from. Command codes and bitmap values reuse the existing SMB2_CRTCTX_AAPL_* constants in fs/smb/common/smb2pdu.h. Wire format confirmed against AAPL's published public client kernel source (public client behavior reference) -- every field here and every SMB2_CRTCTX_AAPL_* constant matches exactly. Hook the request parsing and response into smb2_open()'s existing create-context handling, following the same DataOffset+DataLength bounds-checking convention already used by every other context parser in this file. The AAPL model string is configurable via the existing netlink startup path (server_conf.aapl_model, default "Xserve"). This is scoped to shares with the new KSMBD_SHARE_FLAG_TIME_MACHINE flag only, not enabled globally -- AAPL's AAPL extension is undocumented, so containing its blast radius to shares that explicitly opt in limits risk to ordinary SMB shares. conn->aapl_readdir_attr is set here when the client also advertises READDIR_ATTR support, but the actual inline-FinderInfo wire format (the feature that flag gates) is not implemented yet -- follow-up commit. Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Gael Blivet <gael.blivet@gmail.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
78 lines
1.7 KiB
C
78 lines
1.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* Copyright (C) 2018 Samsung Electronics Co., Ltd.
|
|
*/
|
|
|
|
#ifndef __SERVER_H__
|
|
#define __SERVER_H__
|
|
|
|
#include "smbacl.h"
|
|
|
|
/*
|
|
* Server state type
|
|
*/
|
|
enum {
|
|
SERVER_STATE_STARTING_UP,
|
|
SERVER_STATE_RUNNING,
|
|
SERVER_STATE_RESETTING,
|
|
SERVER_STATE_SHUTTING_DOWN,
|
|
};
|
|
|
|
/*
|
|
* Server global config string index
|
|
*/
|
|
enum {
|
|
SERVER_CONF_NETBIOS_NAME,
|
|
SERVER_CONF_SERVER_STRING,
|
|
SERVER_CONF_WORK_GROUP,
|
|
};
|
|
|
|
struct ksmbd_server_config {
|
|
unsigned int flags;
|
|
unsigned int state;
|
|
short signing;
|
|
short enforced_signing;
|
|
short min_protocol;
|
|
short max_protocol;
|
|
unsigned short tcp_port;
|
|
unsigned short ipc_timeout;
|
|
unsigned long ipc_last_active;
|
|
unsigned long deadtime;
|
|
unsigned int share_fake_fscaps;
|
|
struct smb_sid domain_sid;
|
|
unsigned int auth_mechs;
|
|
unsigned int max_connections;
|
|
unsigned int max_inflight_req;
|
|
unsigned int max_ip_connections;
|
|
|
|
char *conf[SERVER_CONF_WORK_GROUP + 1];
|
|
struct task_struct *dh_task;
|
|
bool bind_interfaces_only;
|
|
/* AAPL model string for Finder icon, e.g. "Xserve" */
|
|
char aapl_model[32];
|
|
};
|
|
|
|
extern struct ksmbd_server_config server_conf;
|
|
|
|
int ksmbd_set_netbios_name(char *v);
|
|
int ksmbd_set_server_string(char *v);
|
|
int ksmbd_set_work_group(char *v);
|
|
|
|
char *ksmbd_netbios_name(void);
|
|
char *ksmbd_server_string(void);
|
|
char *ksmbd_work_group(void);
|
|
|
|
static inline int ksmbd_server_running(void)
|
|
{
|
|
return READ_ONCE(server_conf.state) == SERVER_STATE_RUNNING;
|
|
}
|
|
|
|
static inline int ksmbd_server_configurable(void)
|
|
{
|
|
return READ_ONCE(server_conf.state) < SERVER_STATE_RESETTING;
|
|
}
|
|
|
|
int server_queue_ctrl_init_work(void);
|
|
int server_queue_ctrl_reset_work(void);
|
|
#endif /* __SERVER_H__ */
|