Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] tls connect/read/write function wrappers unexpectedly set the file descriptor to non-blocking mode. #1257

Open
xbasel opened this issue Nov 4, 2024 · 1 comment

Comments

@xbasel
Copy link
Member

xbasel commented Nov 4, 2024

tls.c syscall read/write/connect wrappers set the file descriptor to non-blocking mode. These functions should only perform the operation without altering the file descriptor's configuration.

An example where this bug impacted Valkey:
https://github.com/valkey-io/valkey/pull/837/commits

Steps to reproduce the behavior and/or a minimal code sample.

@xbasel
Copy link
Member Author

xbasel commented Nov 4, 2024

Code example:

static ssize_t connTLSSyncWrite(connection *conn_, char *ptr, ssize_t size, long long timeout) {
    tls_connection *conn = (tls_connection *)conn_;

    setBlockingTimeout(conn, timeout);
    SSL_clear_mode(conn->ssl, SSL_MODE_ENABLE_PARTIAL_WRITE);
    ERR_clear_error();
    int ret = SSL_write(conn->ssl, ptr, size);
    ret = updateStateAfterSSLIO(conn, ret, 0);
    SSL_set_mode(conn->ssl, SSL_MODE_ENABLE_PARTIAL_WRITE);
    unsetBlockingTimeout(conn); // <--- setting to non-blocking

    return ret;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant