ksmbd: Prevent integer overflow in calculation of deadtime
Subsystems (3)
PATCH 1/1 ksmbd: Prevent integer overflow in calculation of deadtime
The user can set any value for 'deadtime'. This affects the arithmetic expression 'req->deadtime * SMB_ECHO_INTERVAL', which is subject to overflow. The added check makes the server behavior more predictable.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes 0626e6641f6b ("cifsd: add server handler for central processing and tranport layers")
Signed-off-by Denis Arefev <[email protected]>
--- fs/smb/server/transport_ipc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/smb/server/transport_ipc.c +6 -1
@@ -310,7 +310,11 @@ static int ipc_server_config_on_startup(struct ksmbd_startup_request *req) server_conf.signing = req->signing; server_conf.tcp_port = req->tcp_port; server_conf.ipc_timeout = req->ipc_timeout *HZ ; - server_conf.deadtime = req->deadtime *SMB_ECHO_INTERVAL ; +if (check_mul_overflow (req->deadtime,SMB_ECHO_INTERVAL , + &server_conf.deadtime)) { + ret = -EINVAL ; + goto out; + } server_conf.share_fake_fscaps = req->share_fake_fscaps;ksmbd_init_domain (req->sub_auth);
@@ -337,6 +341,7 @@ static int ipc_server_config_on_startup(struct ksmbd_startup_request *req) server_conf.bind_interfaces_only = req->bind_interfaces_only; ret |=ksmbd_tcp_set_interfaces (KSMBD_STARTUP_CONFIG_INTERFACES (req), req->ifc_list_sz); +out:if (ret) { pr_err("Server configuration error: %s %s %s\n", req->netbios_name, req->server_string,
Signature · 1 line
2.43.0
Quoted 10 lines · Denis Arefev
The user can set any value for 'deadtime'. This affects the arithmetic expression '
req->deadtime*SMB_ECHO_INTERVAL', which is subject to overflow. The added check makes the server behavior more predictable.Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes 0626e6641f6b ("cifsd: add server handler for central processing and tranport layers")Signed-off-by Denis Arefev <[email protected]>
Applied it to #ksmbd-for-next-next.
Thanks!