From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 575DBC636D6 for ; Fri, 3 Feb 2023 10:25:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233467AbjBCKZT (ORCPT ); Fri, 3 Feb 2023 05:25:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233486AbjBCKZJ (ORCPT ); Fri, 3 Feb 2023 05:25:09 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CE5F5CFF6 for ; Fri, 3 Feb 2023 02:24:49 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E5D0661E53 for ; Fri, 3 Feb 2023 10:24:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1839C433D2; Fri, 3 Feb 2023 10:24:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675419876; bh=2EkidmGYR9Fi14vrQ/xIDvANimnqugpun2Vo+Jh5rfs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BsFEG5ab/nAdTlBKZFAd0B2mhBbCv62JNKwS1QnEpjX40QH4l2OVeMhh5GFhnz2Ps wvmU+QaZP/l26o/rlVmZzDhr3SDVwzgo2jVMDVBWXejMNCaM8vnolP+UaPwjUr9IP+ htIiZSXUiA+2vJD7hGtoJtOEClABvX1jmRJ21vUY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jeremy Kerr , Pavan Chebbi , Jakub Kicinski Subject: [PATCH 5.15 20/20] net: mctp: purge receive queues on sk destruction Date: Fri, 3 Feb 2023 11:13:47 +0100 Message-Id: <20230203101008.845565463@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230203101007.985835823@linuxfoundation.org> References: <20230203101007.985835823@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jeremy Kerr commit 60bd1d9008a50cc78c4033a16a6f5d78210d481c upstream. 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 Reviewed-by: Pavan Chebbi Link: https://lore.kernel.org/r/20230126064551.464468-1-jk@codeconstruct.com.au Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/mctp/af_mctp.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/net/mctp/af_mctp.c +++ b/net/mctp/af_mctp.c @@ -294,6 +294,11 @@ static void mctp_sk_unhash(struct sock * synchronize_rcu(); } +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, @@ -330,6 +335,7 @@ static int mctp_pf_create(struct net *ne return -ENOMEM; sock_init_data(sock, sk); + sk->sk_destruct = mctp_sk_destruct; rc = 0; if (sk->sk_prot->init)