Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6737796rwi; Mon, 24 Oct 2022 05:36:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7D+C8QNg47ggOVRavoAaCf+sB12dZG4oHS2rFH8U8WwLpskuldoPZdYxZ7SIFGYIuS9JUX X-Received: by 2002:a17:902:900a:b0:178:77c7:aa28 with SMTP id a10-20020a170902900a00b0017877c7aa28mr32779832plp.3.1666614998457; Mon, 24 Oct 2022 05:36:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666614998; cv=none; d=google.com; s=arc-20160816; b=vtejhGAV3dXkeenl9OfAzgYTXfHUCQMNqQx/SMKBam4DaIwi/g3nlunj2NdmDydrBs HckodWlI4raTFQrSDJDiGaY1/0qThlRjBdp9JjhVvBNmEX7eIBYPXfRJe6NlyleS9ix/ KA0PLkZRd7IdTLMDFcy1Z6Zjto1OiuswtP0SFZDCAMoqG1NFB07Ut3WX5BIQC1aoWfku gzmXkVooXHUu7HrriD/q4yaj5FmUjcVc2GmBA76H9pg7iCPTg9YRtriHFoODiSG7ITIQ G+A4/iiWKLDqWFYXePy7Q1/gfc1Nu9y76DRc7qBhs6msfjOIE5w8pW842CdodY4Zkg3V iLYA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f7-20020a056a0022c700b00537e88da121si37131777pfj.35.2022.10.24.05.36.26; Mon, 24 Oct 2022 05:36:38 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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; -- 2.35.1