From patchwork Mon Oct 24 11:29:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8908 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp434143wru; Mon, 24 Oct 2022 05:51:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4QGRXE1/lcb3CaCZh1/ma5S2wxOeTiihfYBAA+nV64X4b4PXGs0APtnedon78JyaD0tgVB X-Received: by 2002:a05:6402:84d:b0:454:f41d:6ccf with SMTP id b13-20020a056402084d00b00454f41d6ccfmr30454731edz.129.1666615890568; Mon, 24 Oct 2022 05:51:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615890; cv=none; d=google.com; s=arc-20160816; b=YTYf+sT7zu5uX/9K/D8lA9ia1IYMCDVE0+B6vfAlKmGbFju0fyjjObxGbyGIEqxvum 1t0npiLnN7vo98iw6/TM4BkZ+hBQ2ESVpWnz+F9vgCMORQb8hDx5J9m6n4MG2oKumpTQ os9y41YRU9w0HPK7a7IY7vUFbUUrjxwYkK9WVvXM0ihqmuLL098h32VEkb3mNLQokVRg kUIof1RxhEFRSXpec7pua7cLpcu98PagJ/D5MwJ3jJ7EVGOwUX1APB6ovyW7ZWoEDq2D vWveakpG9fSMlzf5wccLd1qBE24/K719c2ko2WSp1ZH9DmMF9dxnJtAljDDa9KXelYVm DTnw== 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=+ynPjui00aO/pf2P/NxkrTUfNFOdf1IEh1/gZVcJh0I=; b=YNMgjLCc1x9oPBSF5OIABVoitvBHtZxvN1XpRH/hf1fz6mGs+2l5nMa7l54+4I66PC BxUg7mxpbMKdFA3MHlSUrMPdkzF2OKzl1IstAlQbJcidcI+KSJwsF+SV+IGkkNUWqgW9 Lx+uVDAwLDal6/DGddcH/dxWwCVjbwjUOVkjaODoOdbFhEURndLqtaRdidHrwBA7nhOd gCAYhyEOAqmSSRCjQCHZqYXja4slqSFohf+HuQazh/+iIL2zIIJq64r3Fg3YM2+9mICD hIJ2j1+BDEwGNMH/6W2ARfeTVs8Jt8YoFAcRyCHkO96olbu+t6+x9hMCQMNi6UTf6UWB lsbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NPT7XOp5; 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 ji19-20020a170907981300b007823d2b20fdsi28156780ejc.219.2022.10.24.05.50.59; Mon, 24 Oct 2022 05:51:30 -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=NPT7XOp5; 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 S234166AbiJXMtv (ORCPT + 99 others); Mon, 24 Oct 2022 08:49:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234524AbiJXMpB (ORCPT ); Mon, 24 Oct 2022 08:45:01 -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 2F3E11CFD3; Mon, 24 Oct 2022 05:09:35 -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 987EB612BB; Mon, 24 Oct 2022 12:08:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A75BEC433C1; Mon, 24 Oct 2022 12:08:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613298; bh=Nlr3whkKSXmBdqljoxTbdkcPVBXygdd7SJC2WUfTS7M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NPT7XOp5Kx0FCjiLeTtF4grtwhlZrNeULLDXK+3KexK7VL4XB46ASekto2jvRQ4Hu /ptMeCOp1LyIch7Ok4nRrddaabgt9QoxJ3+9BRsq3uV1t0GE7QqkPwEUwGqTFlz4Xe VZitWP/vs8ed5qRJUNvXy8vwkwG3ktBmFtrac3IA= 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 5.4 083/255] net: rds: dont hold sock lock when cancelling work from rds_tcp_reset_callbacks() Date: Mon, 24 Oct 2022 13:29:53 +0200 Message-Id: <20221024113005.267727463@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@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?1747573424222492612?= X-GMAIL-MSGID: =?utf-8?q?1747573424222492612?= 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 d55d81b01d37..bfb8d4d6a994 100644 --- a/net/rds/tcp.c +++ b/net/rds/tcp.c @@ -176,10 +176,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;