From patchwork Mon Oct 24 11:30:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8488 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp403734wru; Mon, 24 Oct 2022 04:53:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4jrW0tHBUvov/Ly4qxqaZNSVASUBW7Uw58PUVhDjmO2SIAGTF7dsA2SA1OBwQ/OUPtui+K X-Received: by 2002:a17:90a:c24a:b0:213:13aa:3e2a with SMTP id d10-20020a17090ac24a00b0021313aa3e2amr4910345pjx.107.1666612390241; Mon, 24 Oct 2022 04:53:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666612390; cv=none; d=google.com; s=arc-20160816; b=DPgtfVEfCq8TYpi5+ngff7Ej6N7pxDCJGJQO9U8ZBzzikWrkgvx8hbd7K0ckp4BOem BXLfM6GD5eq9DsW6AtiRNklB6m3qs574cIyKRb+IH+to3j/sQJII2J/OTXMVcx/fIJQq C8R5wKNm7i3VzuVuUHfBrHjmeXKKo/J5h0KhWIEnsCTpuVlfyNgKR8ndw2yG305FJBTc /1wcBPDeKfSk+iksOxLyGyENxg8kzWIQka6GAI4ad9b56uG06t3ceQgppOF8Rz8lYbms hK00y2PxT8rVzWj/BjdzLXmDkdrhA+abEfNvBHE8utFhHW5nG+Jl458DN8ModPHC9fBc kQEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6xjdksYVDOjZQMooDGWN07YoZT6IvePNB7jNY1ttePQ=; b=nOzpOIdehLa40I3W1TRlthqglmz1Esh4DLlsx9GFqiYUym2IIqTEJ4PsV1103FSyd4 85EDP04mnFU6lIzKgcpUwo3EdM+kJHs5KZ0C/T4e4z55ams5TcqfRo3Svx4qzc0CslQO aLPIeMPrudNu2P/Djl9fg3zC6uhoh3ktuz0eYxeljJX6kjD4c/Uzn0nFDZvrPO9aDdjG LPYRk60445T/lgot0iW71kQo+xNNR/0dgxnXwUn8LBs/olEg8MjP1LnvohrONq2B18T/ Vyoq/yQfq/mOfFitfyVf1bVdVEX+oFyuhTTkVqRZRbs7ex7E34TByRcU30/MqVdJzHWd /YLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NbwJnMEh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mw10-20020a17090b4d0a00b00212e8cd5603si9001564pjb.114.2022.10.24.04.52.57; Mon, 24 Oct 2022 04:53:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NbwJnMEh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232046AbiJXLw3 (ORCPT + 99 others); Mon, 24 Oct 2022 07:52:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231958AbiJXLvW (ORCPT ); Mon, 24 Oct 2022 07:51:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20AA895AD; Mon, 24 Oct 2022 04:44:31 -0700 (PDT) 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 69F4561299; Mon, 24 Oct 2022 11:41:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8056AC433C1; Mon, 24 Oct 2022 11:41:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666611694; bh=3+L8y4kFkn5/a3qQItXo/7vXBpgyjQqn0qkPphBHUe4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NbwJnMEhbNFGV1bSbKSfnku34oFyuNPXA0Fd6zPGwREhMhIFCQ45UlqaErJ4V3OvQ Z4Kw8al+r8I5zVZIbX+ZRaBc0rVTGWNnfkl3x4dtXt1rXHIDn7Xxuohz9pMkiwFnkd QNQjIoTAUoGzV3Fg6UGvEsgECvxfAd8SB/jnFdcg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , Hillf Danton , Tetsuo Handa , "David S. Miller" , Sasha Levin Subject: [PATCH 4.9 075/159] net: rds: dont hold sock lock when cancelling work from rds_tcp_reset_callbacks() Date: Mon, 24 Oct 2022 13:30:29 +0200 Message-Id: <20221024112952.179418878@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112949.358278806@linuxfoundation.org> References: <20221024112949.358278806@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747569753715379579?= X-GMAIL-MSGID: =?utf-8?q?1747569753715379579?= From: Tetsuo Handa [ Upstream commit a91b750fd6629354460282bbf5146c01b05c4859 ] syzbot is reporting lockdep warning at rds_tcp_reset_callbacks() [1], for commit ac3615e7f3cffe2a ("RDS: TCP: Reduce code duplication in rds_tcp_reset_callbacks()") added cancel_delayed_work_sync() into a section protected by lock_sock() without realizing that rds_send_xmit() might call lock_sock(). We don't need to protect cancel_delayed_work_sync() using lock_sock(), for even if rds_{send,recv}_worker() re-queued this work while __flush_work() from cancel_delayed_work_sync() was waiting for this work to complete, retried rds_{send,recv}_worker() is no-op due to the absence of RDS_CONN_UP bit. Link: https://syzkaller.appspot.com/bug?extid=78c55c7bc6f66e53dce2 [1] Reported-by: syzbot Co-developed-by: Hillf Danton Signed-off-by: Hillf Danton Signed-off-by: Tetsuo Handa Tested-by: syzbot Fixes: ac3615e7f3cffe2a ("RDS: TCP: Reduce code duplication in rds_tcp_reset_callbacks()") Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/rds/tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/rds/tcp.c b/net/rds/tcp.c index 192f932bce0d..d7c9576a1148 100644 --- a/net/rds/tcp.c +++ b/net/rds/tcp.c @@ -165,10 +165,10 @@ void rds_tcp_reset_callbacks(struct socket *sock, */ atomic_set(&cp->cp_state, RDS_CONN_RESETTING); wait_event(cp->cp_waitq, !test_bit(RDS_IN_XMIT, &cp->cp_flags)); - lock_sock(osock->sk); /* reset receive side state for rds_tcp_data_recv() for osock */ cancel_delayed_work_sync(&cp->cp_send_w); cancel_delayed_work_sync(&cp->cp_recv_w); + lock_sock(osock->sk); if (tc->t_tinc) { rds_inc_put(&tc->t_tinc->ti_inc); tc->t_tinc = NULL;