From patchwork Mon Jul 19 14:53:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 480855 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B4B4C12002 for ; Mon, 19 Jul 2021 15:51:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 793596113B for ; Mon, 19 Jul 2021 15:51:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344544AbhGSPLC (ORCPT ); Mon, 19 Jul 2021 11:11:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:38958 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346052AbhGSPKA (ORCPT ); Mon, 19 Jul 2021 11:10:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9F0EF61221; Mon, 19 Jul 2021 15:50:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626709818; bh=WF0TpTCVtD/q8bjs/VLUNrGERQsRQGf0gDxkGI0J854=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EALweJnoTuoYJPHG0Ws2TjZX7RsRHoA/wNpu1nsTeeJJNzQdt0IyXsgcElXCTYBIv Po38tff61z2NvIdmNmphPpuy541tFg7TMmApGsiL8GlAmIizHy6l/0aXS6OZW8qJ3J JtNKAf8/bdSrCxXtejhYZa6aSgwWMuQ0MOgPvSMk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maurizio Lombardi , Sagi Grimberg , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.4 111/149] nvme-tcp: cant set sk_user_data without write_lock Date: Mon, 19 Jul 2021 16:53:39 +0200 Message-Id: <20210719144927.643964494@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144901.370365147@linuxfoundation.org> References: <20210719144901.370365147@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Maurizio Lombardi [ Upstream commit 0755d3be2d9bb6ea38598ccd30d6bbaa1a5c3a50 ] The sk_user_data pointer is supposed to be modified only while holding the write_lock "sk_callback_lock", otherwise we could race with other threads and crash the kernel. we can't take the write_lock in nvmet_tcp_state_change() because it would cause a deadlock, but the release_work queue will set the pointer to NULL later so we can simply remove the assignment. Fixes: b5332a9f3f3d ("nvmet-tcp: fix incorrect locking in state_change sk callback") Signed-off-by: Maurizio Lombardi Reviewed-by: Sagi Grimberg Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/target/tcp.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c index 9bfd92b6677b..2ae846297d7c 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -1412,7 +1412,6 @@ static void nvmet_tcp_state_change(struct sock *sk) case TCP_CLOSE_WAIT: case TCP_CLOSE: /* FALLTHRU */ - sk->sk_user_data = NULL; nvmet_tcp_schedule_release_queue(queue); break; default: