Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions include/ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@
struct ksmbd_ipc_msg {
unsigned int type;
unsigned int sz;
unsigned char ____payload[0];
unsigned char payload[];
};

#define KSMBD_IPC_MSG_PAYLOAD(m) \
(void *)(((struct ksmbd_ipc_msg *)(m))->____payload)

struct ksmbd_ipc_msg *ipc_msg_alloc(size_t sz);
void ipc_msg_free(struct ksmbd_ipc_msg *msg);

Expand Down
2 changes: 1 addition & 1 deletion include/management/user.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct ksmbd_logout_request;

int usm_handle_login_request(struct ksmbd_login_request *req,
struct ksmbd_login_response *resp);
int usm_handle_logout_request(struct ksmbd_logout_request *req);
int usm_handle_logout_request(void *data);
int usm_handle_login_request_ext(struct ksmbd_login_request *req,
struct ksmbd_login_response_ext *resp);

Expand Down
10 changes: 4 additions & 6 deletions mountd/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static struct nl_sock *sk;
struct ksmbd_ipc_msg *ipc_msg_alloc(size_t sz)
{
struct ksmbd_ipc_msg *msg;
size_t msg_sz = sz + sizeof(struct ksmbd_ipc_msg) + 1;
size_t msg_sz = sz + sizeof(struct ksmbd_ipc_msg);

if (msg_sz > KSMBD_IPC_MAX_MESSAGE_SIZE) {
pr_err("IPC message is too large: %zu\n", msg_sz);
Expand Down Expand Up @@ -58,9 +58,7 @@ static int generic_event(int type, void *payload, size_t sz)
event->type = type;
event->sz = sz;

memcpy(KSMBD_IPC_MSG_PAYLOAD(event),
payload,
sz);
memcpy(event->payload, payload, sz);
wp_ipc_msg_push(event);
return 0;
}
Expand Down Expand Up @@ -132,7 +130,7 @@ static int ipc_ksmbd_starting_up(void)
if (!msg)
return -ENOMEM;

ev = KSMBD_IPC_MSG_PAYLOAD(msg);
ev = (struct ksmbd_startup_request *)msg->payload;
msg->type = KSMBD_EVENT_STARTING_UP;

ev->flags = global_conf.flags;
Expand Down Expand Up @@ -441,7 +439,7 @@ int ipc_msg_send(struct ksmbd_ipc_msg *msg)
}

/* Use msg->type as attribute TYPE */
ret = nla_put(nlmsg, msg->type, msg->sz, KSMBD_IPC_MSG_PAYLOAD(msg));
ret = nla_put(nlmsg, msg->type, msg->sz, msg->payload);
if (ret) {
pr_err("nla_put() has failed, aborting IPC send()\n");
goto out_error;
Expand Down
30 changes: 15 additions & 15 deletions mountd/worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ static int login_request(struct ksmbd_ipc_msg *msg)
if (!resp_msg)
goto out;

req = KSMBD_IPC_MSG_PAYLOAD(msg);
resp = KSMBD_IPC_MSG_PAYLOAD(resp_msg);
req = (struct ksmbd_login_request *)msg->payload;
resp = (struct ksmbd_login_response *)resp_msg->payload;

resp->status = KSMBD_USER_FLAG_INVALID;
if (VALID_IPC_MSG(msg, struct ksmbd_login_request))
Expand Down Expand Up @@ -83,14 +83,14 @@ static int login_request_ext(struct ksmbd_ipc_msg *msg)
struct ksmbd_ipc_msg *resp_msg;
int payload_sz;

req = KSMBD_IPC_MSG_PAYLOAD(msg);
req = (struct ksmbd_login_request *)msg->payload;

payload_sz = login_response_payload_sz(req->account);
resp_msg = ipc_msg_alloc(sizeof(*resp) + payload_sz);
if (!resp_msg)
goto out;

resp = KSMBD_IPC_MSG_PAYLOAD(resp_msg);
resp = (struct ksmbd_login_response_ext *)resp_msg->payload;

if (VALID_IPC_MSG(msg, struct ksmbd_login_request))
usm_handle_login_request_ext(req, resp);
Expand All @@ -113,12 +113,12 @@ static int spnego_authen_request(struct ksmbd_ipc_msg *msg)
struct ksmbd_login_request login_req;
int retval = 0;

req = KSMBD_IPC_MSG_PAYLOAD(msg);
req = (struct ksmbd_spnego_authen_request *)msg->payload;
resp_msg = ipc_msg_alloc(sizeof(*resp));
if (!resp_msg)
return -ENOMEM;
resp_msg->type = KSMBD_EVENT_SPNEGO_AUTHEN_RESPONSE;
resp = KSMBD_IPC_MSG_PAYLOAD(resp_msg);
resp = (struct ksmbd_spnego_authen_response *)resp_msg->payload;
resp->handle = req->handle;
resp->login_response.status = KSMBD_USER_FLAG_INVALID;

Expand All @@ -142,7 +142,7 @@ static int spnego_authen_request(struct ksmbd_ipc_msg *msg)
}

resp_msg->type = KSMBD_EVENT_SPNEGO_AUTHEN_RESPONSE;
resp = KSMBD_IPC_MSG_PAYLOAD(resp_msg);
resp = (struct ksmbd_spnego_authen_response *)resp_msg->payload;
resp->handle = req->handle;
resp->login_response.status = KSMBD_USER_FLAG_INVALID;

Expand Down Expand Up @@ -183,8 +183,8 @@ static int tree_connect_request(struct ksmbd_ipc_msg *msg)
if (!resp_msg)
goto out;

req = KSMBD_IPC_MSG_PAYLOAD(msg);
resp = KSMBD_IPC_MSG_PAYLOAD(resp_msg);
req = (struct ksmbd_tree_connect_request *)msg->payload;
resp = (struct ksmbd_tree_connect_response *)resp_msg->payload;

resp->status = KSMBD_TREE_CONN_STATUS_ERROR;
resp->connection_flags = 0;
Expand All @@ -209,7 +209,7 @@ static int share_config_request(struct ksmbd_ipc_msg *msg)
struct ksmbd_ipc_msg *resp_msg;
int payload_sz = 0;

req = KSMBD_IPC_MSG_PAYLOAD(msg);
req = (struct ksmbd_share_config_request *)msg->payload;
if (VALID_IPC_MSG(msg, struct ksmbd_share_config_request)) {
share = shm_lookup_share(req->share_name);
if (share)
Expand All @@ -220,7 +220,7 @@ static int share_config_request(struct ksmbd_ipc_msg *msg)
if (!resp_msg)
goto out;

resp = KSMBD_IPC_MSG_PAYLOAD(resp_msg);
resp = (struct ksmbd_share_config_response *)resp_msg->payload;
resp->payload_sz = payload_sz;
shm_handle_share_config_request(share, resp);
resp_msg->type = KSMBD_EVENT_SHARE_CONFIG_RESPONSE;
Expand All @@ -240,7 +240,7 @@ static int tree_disconnect_request(struct ksmbd_ipc_msg *msg)
if (!VALID_IPC_MSG(msg, struct ksmbd_tree_disconnect_request))
return -EINVAL;

req = KSMBD_IPC_MSG_PAYLOAD(msg);
req = (struct ksmbd_tree_disconnect_request *)msg->payload;
tcm_handle_tree_disconnect(req->session_id, req->connect_id);

return 0;
Expand All @@ -251,7 +251,7 @@ static int logout_request(struct ksmbd_ipc_msg *msg)
if (!VALID_IPC_MSG(msg, struct ksmbd_logout_request))
return -EINVAL;

return usm_handle_logout_request(KSMBD_IPC_MSG_PAYLOAD(msg));
return usm_handle_logout_request(msg->payload);
}

static int heartbeat_request(struct ksmbd_ipc_msg *msg)
Expand All @@ -273,7 +273,7 @@ static int rpc_request(struct ksmbd_ipc_msg *msg)
if (msg->sz < sizeof(struct ksmbd_rpc_command))
goto out;

req = KSMBD_IPC_MSG_PAYLOAD(msg);
req = (struct ksmbd_rpc_command *)msg->payload;
if (req->flags & KSMBD_RPC_METHOD_RETURN)
resp_msg = ipc_msg_alloc(KSMBD_IPC_MAX_MESSAGE_SIZE -
sizeof(struct ksmbd_rpc_command));
Expand All @@ -282,7 +282,7 @@ static int rpc_request(struct ksmbd_ipc_msg *msg)
if (!resp_msg)
goto out;

resp = KSMBD_IPC_MSG_PAYLOAD(resp_msg);
resp = (struct ksmbd_rpc_command *)resp_msg->payload;

if ((req->flags & KSMBD_RPC_RAP_METHOD) == KSMBD_RPC_RAP_METHOD) {
pr_err("RAP command is not supported yet %x\n", req->flags);
Expand Down
3 changes: 2 additions & 1 deletion tools/management/user.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,9 @@ int usm_handle_login_request_ext(struct ksmbd_login_request *req,
return 0;
}

int usm_handle_logout_request(struct ksmbd_logout_request *req)
int usm_handle_logout_request(void *data)
{
struct ksmbd_logout_request *req = data;
struct ksmbd_user *user;

user = usm_lookup_user(req->account);
Expand Down