mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-31 06:14:39 +01:00
tls/device: Use splice_eof() to flush
Allow splice to end a TLS record after prematurely ending a splice/sendfile due to getting an EOF condition (->splice_read() returned 0) after splice had called TLS with a sendmsg() with MSG_MORE set when the user didn't set MSG_MORE. Suggested-by: Linus Torvalds <[email protected]> Link: https://lore.kernel.org/r/CAHk-=wh=V579PDYvkpnTobCLGczbgxpMgGmmhqiTyE34Cpi5Gg@mail.gmail.com/ Signed-off-by: David Howells <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> cc: Chuck Lever <[email protected]> cc: Boris Pismenny <[email protected]> cc: John Fastabend <[email protected]> cc: Jens Axboe <[email protected]> cc: Matthew Wilcox <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
This commit is contained in:
1 parent
df720d288d
commit
d4c1e80b0d
3 files changed
+26
No files matched your search
@@ -116,6 +116,7 @@ ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos,
|
||||
size_t len, unsigned int flags);
|
||||
|
||||
int tls_device_sendmsg(struct sock *sk, struct msghdr *msg, size_t size);
|
||||
void tls_device_splice_eof(struct socket *sock);
|
||||
int tls_device_sendpage(struct sock *sk, struct page *page,
|
||||
int offset, size_t size, int flags);
|
||||
int tls_tx_records(struct sock *sk, int flags);
|
||||
|
||||
@@ -590,6 +590,29 @@ out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
void tls_device_splice_eof(struct socket *sock)
|
||||
{
|
||||
struct sock *sk = sock->sk;
|
||||
struct tls_context *tls_ctx = tls_get_ctx(sk);
|
||||
union tls_iter_offset iter;
|
||||
struct iov_iter iov_iter = {};
|
||||
|
||||
if (!tls_is_partially_sent_record(tls_ctx))
|
||||
return;
|
||||
|
||||
mutex_lock(&tls_ctx->tx_lock);
|
||||
lock_sock(sk);
|
||||
|
||||
if (tls_is_partially_sent_record(tls_ctx)) {
|
||||
iov_iter_bvec(&iov_iter, ITER_SOURCE, NULL, 0, 0);
|
||||
iter.msg_iter = &iov_iter;
|
||||
tls_push_data(sk, iter, 0, 0, TLS_RECORD_TYPE_DATA, NULL);
|
||||
}
|
||||
|
||||
release_sock(sk);
|
||||
mutex_unlock(&tls_ctx->tx_lock);
|
||||
}
|
||||
|
||||
int tls_device_sendpage(struct sock *sk, struct page *page,
|
||||
int offset, size_t size, int flags)
|
||||
{
|
||||
|
||||
@@ -1044,10 +1044,12 @@ static void build_protos(struct proto prot[TLS_NUM_CONFIG][TLS_NUM_CONFIG],
|
||||
#ifdef CONFIG_TLS_DEVICE
|
||||
prot[TLS_HW][TLS_BASE] = prot[TLS_BASE][TLS_BASE];
|
||||
prot[TLS_HW][TLS_BASE].sendmsg = tls_device_sendmsg;
|
||||
prot[TLS_HW][TLS_BASE].splice_eof = tls_device_splice_eof;
|
||||
prot[TLS_HW][TLS_BASE].sendpage = tls_device_sendpage;
|
||||
|
||||
prot[TLS_HW][TLS_SW] = prot[TLS_BASE][TLS_SW];
|
||||
prot[TLS_HW][TLS_SW].sendmsg = tls_device_sendmsg;
|
||||
prot[TLS_HW][TLS_SW].splice_eof = tls_device_splice_eof;
|
||||
prot[TLS_HW][TLS_SW].sendpage = tls_device_sendpage;
|
||||
|
||||
prot[TLS_BASE][TLS_HW] = prot[TLS_BASE][TLS_SW];
|
||||
|
||||
Reference in new issue
Block a user