From patchwork Wed Oct 19 08:27:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5063 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp248412wrs; Wed, 19 Oct 2022 03:43:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ZN+TYRUotGneI+tyBShFKSB0ywqmuePEizzmO9uyJzDhmixXATbdUIR+YaBdPuM0M3fXG X-Received: by 2002:a63:90ca:0:b0:458:f28d:917e with SMTP id a193-20020a6390ca000000b00458f28d917emr6736875pge.201.1666176206223; Wed, 19 Oct 2022 03:43:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666176206; cv=none; d=google.com; s=arc-20160816; b=JinBvP2NoD5Hiz3qXCDN6qLDU4fRGNMNpi6EXeBeOdezOMu4z2TlyYHOGsF6aDQF0q xnADdHD29ty/gLvpgKJwZ5qIKrgV708+rzrpaqsp1H+YgCGU0+x7MEf6ye5bWGwh9UkY VCwKDqwfK2S09zj/ZlK6wOtUBBeIfnvcEc3vAniYphaW7kyLLXX22DOx131mvxQpIlms 4+O6bZ5dyKnxUubHnLYbkwkvIj7mxvnwqbxS0xc3dXVJirWt0PvFVYp95WzTQ5jl+T3F EtPiiaRW6IRRUGZZJM9i1JP10WYzOkViDkYq3VrWBPTDlrSOVYcR2wRiks75hXd51Wlm DL/A== 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=x49Iyp1n8uAaMK7VPCIDJHRf1Fld/cAWjRw6nf6Gsl4=; b=YIpBRAamq54iCLIk+2gxeqJzTfBJiBOXruo6dOrsoNV4Nel59V4KbpQGJEpa4Y/xqC 0FAHnkveFT8kGpjzNA4Mb2GtErIufuOeRXe+oJQcBUTZdF5iqZn7VXtksoep+PSUblqk FFlNTqD0fF6jrOJz7UendMXhoM4afxrmfqhm39gsxVqznysI3LWgITABsSj6eFlIkfAn yOrYELX/16JTb67/oknHxtpkuTICSjUNN4YSkkkswAAsQU7mqPvsYbxQGlXQiKxpPPvF qQIcMRBiSLVq98z52M1ZC0REpG2DNRUkECf8qdrhbZVRiywNoZC0XAj1sRlmEN9BSeVS /U5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MQ6FJZq6; 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 b5-20020a170902d50500b0017841dd2ee6si21110092plg.170.2022.10.19.03.43.13; Wed, 19 Oct 2022 03:43:26 -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=MQ6FJZq6; 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 S232466AbiJSKmt (ORCPT + 99 others); Wed, 19 Oct 2022 06:42:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232445AbiJSKl6 (ORCPT ); Wed, 19 Oct 2022 06:41:58 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C11DE60490; Wed, 19 Oct 2022 03:19:55 -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 ams.source.kernel.org (Postfix) with ESMTPS id ECD5FB823B1; Wed, 19 Oct 2022 08:53:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60244C433D6; Wed, 19 Oct 2022 08:53:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169600; bh=epD93SGW1hEwjy9oseb8+CuhtM2ecZygpN9U7N9We9Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MQ6FJZq65dO3dLkDvTp9Nzn23H2sZThRxxa1ibLXvQZeNAThM3yHdheo6P5R/NfXy Qb76JqYU9H64UHUxLmrmUt3W51p61epE26/V/7KHARL4LPMVmKomNR6+S3/VCrbZzC cQaLcLsAqj2f1ow7ZPPg8l6TRPhzRwJeIa95RRFI= 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 6.0 336/862] net: rds: dont hold sock lock when cancelling work from rds_tcp_reset_callbacks() Date: Wed, 19 Oct 2022 10:27:03 +0200 Message-Id: <20221019083304.902949554@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747112381495470939?= X-GMAIL-MSGID: =?utf-8?q?1747112381495470939?= 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 73ee2771093d..d0ff413f697c 100644 --- a/net/rds/tcp.c +++ b/net/rds/tcp.c @@ -166,10 +166,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;