* [PATCH net] tcp_bpf: properly release resources on error paths
@ 2023-10-17 15:49 Paolo Abeni
2023-10-18 13:11 ` Jakub Sitnicki
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Paolo Abeni @ 2023-10-17 15:49 UTC (permalink / raw)
To: netdev
Cc: John Fastabend, Jakub Sitnicki, Eric Dumazet, David S. Miller,
David Ahern, Jakub Kicinski, bpf
In the blamed commit below, I completely forgot to release the acquired
resources before erroring out in the TCP BPF code, as reported by Dan.
Address the issues by replacing the bogus return with a jump to the
relevant cleanup code.
Fixes: 419ce133ab92 ("tcp: allow again tcp_disconnect() when threads are waiting")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
net/ipv4/tcp_bpf.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
index ba2e92188124..53b0d62fd2c2 100644
--- a/net/ipv4/tcp_bpf.c
+++ b/net/ipv4/tcp_bpf.c
@@ -307,8 +307,10 @@ static int tcp_bpf_recvmsg_parser(struct sock *sk,
}
data = tcp_msg_wait_data(sk, psock, timeo);
- if (data < 0)
- return data;
+ if (data < 0) {
+ copied = data;
+ goto unlock;
+ }
if (data && !sk_psock_queue_empty(psock))
goto msg_bytes_ready;
copied = -EAGAIN;
@@ -319,6 +321,8 @@ static int tcp_bpf_recvmsg_parser(struct sock *sk,
tcp_rcv_space_adjust(sk);
if (copied > 0)
__tcp_cleanup_rbuf(sk, copied);
+
+unlock:
release_sock(sk);
sk_psock_put(sk, psock);
return copied;
@@ -353,8 +357,10 @@ static int tcp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
data = tcp_msg_wait_data(sk, psock, timeo);
- if (data < 0)
- return data;
+ if (data < 0) {
+ ret = data;
+ goto unlock;
+ }
if (data) {
if (!sk_psock_queue_empty(psock))
goto msg_bytes_ready;
@@ -365,6 +371,8 @@ static int tcp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
copied = -EAGAIN;
}
ret = copied;
+
+unlock:
release_sock(sk);
sk_psock_put(sk, psock);
return ret;
--
2.41.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net] tcp_bpf: properly release resources on error paths
2023-10-17 15:49 [PATCH net] tcp_bpf: properly release resources on error paths Paolo Abeni
@ 2023-10-18 13:11 ` Jakub Sitnicki
2023-10-18 13:52 ` Eric Dumazet
2023-10-19 1:20 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: Jakub Sitnicki @ 2023-10-18 13:11 UTC (permalink / raw)
To: Paolo Abeni
Cc: netdev, John Fastabend, Eric Dumazet, David S. Miller,
David Ahern, Jakub Kicinski, bpf
On Tue, Oct 17, 2023 at 05:49 PM +02, Paolo Abeni wrote:
> In the blamed commit below, I completely forgot to release the acquired
> resources before erroring out in the TCP BPF code, as reported by Dan.
>
> Address the issues by replacing the bogus return with a jump to the
> relevant cleanup code.
>
> Fixes: 419ce133ab92 ("tcp: allow again tcp_disconnect() when threads are waiting")
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> ---
Acked-by: Jakub Sitnicki <jakub@cloudflare.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] tcp_bpf: properly release resources on error paths
2023-10-17 15:49 [PATCH net] tcp_bpf: properly release resources on error paths Paolo Abeni
2023-10-18 13:11 ` Jakub Sitnicki
@ 2023-10-18 13:52 ` Eric Dumazet
2023-10-18 19:18 ` John Fastabend
2023-10-19 1:20 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2023-10-18 13:52 UTC (permalink / raw)
To: Paolo Abeni
Cc: netdev, John Fastabend, Jakub Sitnicki, David S. Miller,
David Ahern, Jakub Kicinski, bpf
On Tue, Oct 17, 2023 at 5:50 PM Paolo Abeni <pabeni@redhat.com> wrote:
>
> In the blamed commit below, I completely forgot to release the acquired
> resources before erroring out in the TCP BPF code, as reported by Dan.
>
> Address the issues by replacing the bogus return with a jump to the
> relevant cleanup code.
>
> Fixes: 419ce133ab92 ("tcp: allow again tcp_disconnect() when threads are waiting")
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Right :)
Reviewed-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] tcp_bpf: properly release resources on error paths
2023-10-18 13:52 ` Eric Dumazet
@ 2023-10-18 19:18 ` John Fastabend
0 siblings, 0 replies; 5+ messages in thread
From: John Fastabend @ 2023-10-18 19:18 UTC (permalink / raw)
To: Eric Dumazet, Paolo Abeni
Cc: netdev, John Fastabend, Jakub Sitnicki, David S. Miller,
David Ahern, Jakub Kicinski, bpf
Eric Dumazet wrote:
> On Tue, Oct 17, 2023 at 5:50 PM Paolo Abeni <pabeni@redhat.com> wrote:
> >
> > In the blamed commit below, I completely forgot to release the acquired
> > resources before erroring out in the TCP BPF code, as reported by Dan.
> >
> > Address the issues by replacing the bogus return with a jump to the
> > relevant cleanup code.
> >
> > Fixes: 419ce133ab92 ("tcp: allow again tcp_disconnect() when threads are waiting")
> > Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> > Signed-off-by: Paolo Abeni <pabeni@redhat.com>
>
> Right :)
>
> Reviewed-by: Eric Dumazet <edumazet@google.com>
Thanks.
Reviewed-by: John Fastabend <john.fastabend@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] tcp_bpf: properly release resources on error paths
2023-10-17 15:49 [PATCH net] tcp_bpf: properly release resources on error paths Paolo Abeni
2023-10-18 13:11 ` Jakub Sitnicki
2023-10-18 13:52 ` Eric Dumazet
@ 2023-10-19 1:20 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-10-19 1:20 UTC (permalink / raw)
To: Paolo Abeni
Cc: netdev, john.fastabend, jakub, edumazet, davem, dsahern, kuba, bpf
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 17 Oct 2023 17:49:51 +0200 you wrote:
> In the blamed commit below, I completely forgot to release the acquired
> resources before erroring out in the TCP BPF code, as reported by Dan.
>
> Address the issues by replacing the bogus return with a jump to the
> relevant cleanup code.
>
> Fixes: 419ce133ab92 ("tcp: allow again tcp_disconnect() when threads are waiting")
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
>
> [...]
Here is the summary with links:
- [net] tcp_bpf: properly release resources on error paths
https://git.kernel.org/netdev/net/c/68b54aeff804
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-10-19 1:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-17 15:49 [PATCH net] tcp_bpf: properly release resources on error paths Paolo Abeni
2023-10-18 13:11 ` Jakub Sitnicki
2023-10-18 13:52 ` Eric Dumazet
2023-10-18 19:18 ` John Fastabend
2023-10-19 1:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).