Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp866969rwi; Wed, 19 Oct 2022 04:05:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ALAO5jhHf9Lnp1XKZiGsR5OYC4TyY7QFAZkvWOjqLpP7G7y+9YN8IQFbye1yJRlS1AToS X-Received: by 2002:a05:6402:4446:b0:457:eebd:fe52 with SMTP id o6-20020a056402444600b00457eebdfe52mr6801808edb.234.1666177541482; Wed, 19 Oct 2022 04:05:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666177541; cv=none; d=google.com; s=arc-20160816; b=bG5AsV48hJJbagOJUD1CW4OiPn5Ne5pZD1FNOY3urSfdduiWFkzPGKScYeNY/vbMyg 4BZmumER5v9hIuSD9KFdrpFdTptx2TtnNbDmgpNm2dSWB1v8zgb4tGV5AlXIbQYUa11m 9MOFmF8qkWXZ5Chnsph5fDL6PYQ++KGjefqzZU3aRe4tB6cl8AIkRMRQAcmutpnCijT7 TEUGkIa222Xsrinu/CeHWFA9zwTYGnVtKSPvyod9mwB9x+wfXeD1kNnCi90qfP0/qGg/ v4cwmd9QeAKQJ+rGYlsOdrBs53u4hslAWLThV9RXb0pG8hE0X2JrpBH0oAF9k/sp2Mfi AhxA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y23-20020a1709064b1700b00781ef26422bsi12416825eju.363.2022.10.19.04.04.58; Wed, 19 Oct 2022 04:05:41 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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; -- 2.35.1