提交 3ba1c2d2 编写于 作者: J Jim Ma 提交者: Zheng Zengkai

tls splice: check SPLICE_F_NONBLOCK instead of MSG_DONTWAIT

stable inclusion
from stable-5.10.42
commit 60e2193a600a3abee933ba0267e30794fcd0f20e
bugzilla: 55093
CVE: NA

--------------------------------

[ Upstream commit 974271e5 ]

In tls_sw_splice_read, checkout MSG_* is inappropriate, should use
SPLICE_*, update tls_wait_data to accept nonblock arguments instead
of flags for recvmsg and splice.

Fixes: c46234eb ("tls: RX path for ktls")
Signed-off-by: NJim Ma <majinjing3@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 48f485eb
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <linux/sched/signal.h> #include <linux/sched/signal.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/splice.h>
#include <crypto/aead.h> #include <crypto/aead.h>
#include <net/strparser.h> #include <net/strparser.h>
...@@ -1282,7 +1283,7 @@ int tls_sw_sendpage(struct sock *sk, struct page *page, ...@@ -1282,7 +1283,7 @@ int tls_sw_sendpage(struct sock *sk, struct page *page,
} }
static struct sk_buff *tls_wait_data(struct sock *sk, struct sk_psock *psock, static struct sk_buff *tls_wait_data(struct sock *sk, struct sk_psock *psock,
int flags, long timeo, int *err) bool nonblock, long timeo, int *err)
{ {
struct tls_context *tls_ctx = tls_get_ctx(sk); struct tls_context *tls_ctx = tls_get_ctx(sk);
struct tls_sw_context_rx *ctx = tls_sw_ctx_rx(tls_ctx); struct tls_sw_context_rx *ctx = tls_sw_ctx_rx(tls_ctx);
...@@ -1307,7 +1308,7 @@ static struct sk_buff *tls_wait_data(struct sock *sk, struct sk_psock *psock, ...@@ -1307,7 +1308,7 @@ static struct sk_buff *tls_wait_data(struct sock *sk, struct sk_psock *psock,
if (sock_flag(sk, SOCK_DONE)) if (sock_flag(sk, SOCK_DONE))
return NULL; return NULL;
if ((flags & MSG_DONTWAIT) || !timeo) { if (nonblock || !timeo) {
*err = -EAGAIN; *err = -EAGAIN;
return NULL; return NULL;
} }
...@@ -1787,7 +1788,7 @@ int tls_sw_recvmsg(struct sock *sk, ...@@ -1787,7 +1788,7 @@ int tls_sw_recvmsg(struct sock *sk,
bool async_capable; bool async_capable;
bool async = false; bool async = false;
skb = tls_wait_data(sk, psock, flags, timeo, &err); skb = tls_wait_data(sk, psock, flags & MSG_DONTWAIT, timeo, &err);
if (!skb) { if (!skb) {
if (psock) { if (psock) {
int ret = __tcp_bpf_recvmsg(sk, psock, int ret = __tcp_bpf_recvmsg(sk, psock,
...@@ -1991,9 +1992,9 @@ ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos, ...@@ -1991,9 +1992,9 @@ ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos,
lock_sock(sk); lock_sock(sk);
timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); timeo = sock_rcvtimeo(sk, flags & SPLICE_F_NONBLOCK);
skb = tls_wait_data(sk, NULL, flags, timeo, &err); skb = tls_wait_data(sk, NULL, flags & SPLICE_F_NONBLOCK, timeo, &err);
if (!skb) if (!skb)
goto splice_read_end; goto splice_read_end;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册