All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: mctp: purge receive queues on sk destruction
@ 2023-01-26  6:45 Jeremy Kerr
  2023-01-26  9:26 ` Pavan Chebbi
  2023-01-28  8:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Jeremy Kerr @ 2023-01-26  6:45 UTC (permalink / raw)
  To: netdev
  Cc: Matt Johnston, Paolo Abeni, David S. Miller, Eric Dumazet,
	Jakub Kicinski

We may have pending skbs in the receive queue when the sk is being
destroyed; add a destructor to purge the queue.

MCTP doesn't use the error queue, so only the receive_queue is purged.

Fixes: 833ef3b91de6 ("mctp: Populate socket implementation")
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
---
 net/mctp/af_mctp.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/mctp/af_mctp.c b/net/mctp/af_mctp.c
index 45bbe3e54cc2..3150f3f0c872 100644
--- a/net/mctp/af_mctp.c
+++ b/net/mctp/af_mctp.c
@@ -587,6 +587,11 @@ static void mctp_sk_unhash(struct sock *sk)
 	del_timer_sync(&msk->key_expiry);
 }
 
+static void mctp_sk_destruct(struct sock *sk)
+{
+	skb_queue_purge(&sk->sk_receive_queue);
+}
+
 static struct proto mctp_proto = {
 	.name		= "MCTP",
 	.owner		= THIS_MODULE,
@@ -623,6 +628,7 @@ static int mctp_pf_create(struct net *net, struct socket *sock,
 		return -ENOMEM;
 
 	sock_init_data(sock, sk);
+	sk->sk_destruct = mctp_sk_destruct;
 
 	rc = 0;
 	if (sk->sk_prot->init)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: mctp: purge receive queues on sk destruction
  2023-01-26  6:45 [PATCH net] net: mctp: purge receive queues on sk destruction Jeremy Kerr
@ 2023-01-26  9:26 ` Pavan Chebbi
  2023-01-28  8:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Pavan Chebbi @ 2023-01-26  9:26 UTC (permalink / raw)
  To: Jeremy Kerr
  Cc: netdev, Matt Johnston, Paolo Abeni, David S. Miller,
	Eric Dumazet, Jakub Kicinski

[-- Attachment #1: Type: text/plain, Size: 1312 bytes --]

On Thu, Jan 26, 2023 at 12:16 PM Jeremy Kerr <jk@codeconstruct.com.au> wrote:
>
> We may have pending skbs in the receive queue when the sk is being
> destroyed; add a destructor to purge the queue.
>
> MCTP doesn't use the error queue, so only the receive_queue is purged.
>
> Fixes: 833ef3b91de6 ("mctp: Populate socket implementation")
> Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
> ---
>  net/mctp/af_mctp.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/net/mctp/af_mctp.c b/net/mctp/af_mctp.c
> index 45bbe3e54cc2..3150f3f0c872 100644
> --- a/net/mctp/af_mctp.c
> +++ b/net/mctp/af_mctp.c
> @@ -587,6 +587,11 @@ static void mctp_sk_unhash(struct sock *sk)
>         del_timer_sync(&msk->key_expiry);
>  }
>
> +static void mctp_sk_destruct(struct sock *sk)
> +{
> +       skb_queue_purge(&sk->sk_receive_queue);
> +}
> +
>  static struct proto mctp_proto = {
>         .name           = "MCTP",
>         .owner          = THIS_MODULE,
> @@ -623,6 +628,7 @@ static int mctp_pf_create(struct net *net, struct socket *sock,
>                 return -ENOMEM;
>
>         sock_init_data(sock, sk);
> +       sk->sk_destruct = mctp_sk_destruct;
>
>         rc = 0;
>         if (sk->sk_prot->init)
> --
> 2.35.1
>
Looks good to me.
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: mctp: purge receive queues on sk destruction
  2023-01-26  6:45 [PATCH net] net: mctp: purge receive queues on sk destruction Jeremy Kerr
  2023-01-26  9:26 ` Pavan Chebbi
@ 2023-01-28  8:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-01-28  8:40 UTC (permalink / raw)
  To: Jeremy Kerr; +Cc: netdev, matt, pabeni, davem, edumazet, kuba

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 26 Jan 2023 14:45:51 +0800 you wrote:
> We may have pending skbs in the receive queue when the sk is being
> destroyed; add a destructor to purge the queue.
> 
> MCTP doesn't use the error queue, so only the receive_queue is purged.
> 
> Fixes: 833ef3b91de6 ("mctp: Populate socket implementation")
> Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
> 
> [...]

Here is the summary with links:
  - [net] net: mctp: purge receive queues on sk destruction
    https://git.kernel.org/netdev/net/c/60bd1d9008a5

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] 3+ messages in thread

end of thread, other threads:[~2023-01-28  8:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-26  6:45 [PATCH net] net: mctp: purge receive queues on sk destruction Jeremy Kerr
2023-01-26  9:26 ` Pavan Chebbi
2023-01-28  8:40 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.