Skip to content

Commit 974271e

Browse files
jim3madavem330
authored andcommitted
tls splice: check SPLICE_F_NONBLOCK instead of MSG_DONTWAIT
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: c46234e ("tls: RX path for ktls") Signed-off-by: Jim Ma <majinjing3@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7501689 commit 974271e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

net/tls/tls_sw.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
#include <linux/sched/signal.h>
3939
#include <linux/module.h>
40+
#include <linux/splice.h>
4041
#include <crypto/aead.h>
4142

4243
#include <net/strparser.h>
@@ -1281,7 +1282,7 @@ int tls_sw_sendpage(struct sock *sk, struct page *page,
12811282
}
12821283

12831284
static struct sk_buff *tls_wait_data(struct sock *sk, struct sk_psock *psock,
1284-
int flags, long timeo, int *err)
1285+
bool nonblock, long timeo, int *err)
12851286
{
12861287
struct tls_context *tls_ctx = tls_get_ctx(sk);
12871288
struct tls_sw_context_rx *ctx = tls_sw_ctx_rx(tls_ctx);
@@ -1306,7 +1307,7 @@ static struct sk_buff *tls_wait_data(struct sock *sk, struct sk_psock *psock,
13061307
if (sock_flag(sk, SOCK_DONE))
13071308
return NULL;
13081309

1309-
if ((flags & MSG_DONTWAIT) || !timeo) {
1310+
if (nonblock || !timeo) {
13101311
*err = -EAGAIN;
13111312
return NULL;
13121313
}
@@ -1786,7 +1787,7 @@ int tls_sw_recvmsg(struct sock *sk,
17861787
bool async_capable;
17871788
bool async = false;
17881789

1789-
skb = tls_wait_data(sk, psock, flags, timeo, &err);
1790+
skb = tls_wait_data(sk, psock, flags & MSG_DONTWAIT, timeo, &err);
17901791
if (!skb) {
17911792
if (psock) {
17921793
int ret = sk_msg_recvmsg(sk, psock, msg, len,
@@ -1990,9 +1991,9 @@ ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos,
19901991

19911992
lock_sock(sk);
19921993

1993-
timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
1994+
timeo = sock_rcvtimeo(sk, flags & SPLICE_F_NONBLOCK);
19941995

1995-
skb = tls_wait_data(sk, NULL, flags, timeo, &err);
1996+
skb = tls_wait_data(sk, NULL, flags & SPLICE_F_NONBLOCK, timeo, &err);
19961997
if (!skb)
19971998
goto splice_read_end;
19981999

0 commit comments

Comments
 (0)