diff options
author | 2021-10-13 17:28:31 +0900 | |
---|---|---|
committer | 2021-10-20 00:07:10 -0500 | |
commit | 621be84a9d1fbf0097fd058e249ec5cc4f35f3c5 (patch) | |
tree | e6d922ce3d5262c34c781768ee51588ce4c80e2e /fs/ksmbd/smb2pdu.c | |
parent | ksmbd: validate OutputBufferLength of QUERY_DIR, QUERY_INFO, IOCTL requests (diff) | |
download | linux-621be84a9d1fbf0097fd058e249ec5cc4f35f3c5.tar.gz linux-621be84a9d1fbf0097fd058e249ec5cc4f35f3c5.tar.bz2 linux-621be84a9d1fbf0097fd058e249ec5cc4f35f3c5.zip |
ksmbd: throttle session setup failures to avoid dictionary attacks
To avoid dictionary attacks (repeated session setups rapidly sent) to
connect to server, ksmbd make a delay of a 5 seconds on session setup
failure to make it harder to send enough random connection requests
to break into a server if a user insert the wrong password 10 times
in a row.
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/ksmbd/smb2pdu.c')
-rw-r--r-- | fs/ksmbd/smb2pdu.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c index e0f3a44e1599..cf7db5f71f9b 100644 --- a/fs/ksmbd/smb2pdu.c +++ b/fs/ksmbd/smb2pdu.c @@ -1779,9 +1779,30 @@ out_err: conn->mechToken = NULL; } - if (rc < 0 && sess) { - ksmbd_session_destroy(sess); - work->sess = NULL; + if (rc < 0) { + /* + * SecurityBufferOffset should be set to zero + * in session setup error response. + */ + rsp->SecurityBufferOffset = 0; + + if (sess) { + bool try_delay = false; + + /* + * To avoid dictionary attacks (repeated session setups rapidly sent) to + * connect to server, ksmbd make a delay of a 5 seconds on session setup + * failure to make it harder to send enough random connection requests + * to break into a server. + */ + if (sess->user && sess->user->flags & KSMBD_USER_FLAG_DELAY_SESSION) + try_delay = true; + + ksmbd_session_destroy(sess); + work->sess = NULL; + if (try_delay) + ssleep(5); + } } return rc; |