Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7356466rwi; Mon, 24 Oct 2022 13:28:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6o58MbShbgGo6ohdJmNxH3eWaw7nlTc0DOX6sepI430lqEAjMdDh3zxvuzFryacS0ZUsVk X-Received: by 2002:a17:907:ea7:b0:78f:4ae:965c with SMTP id ho39-20020a1709070ea700b0078f04ae965cmr29022402ejc.127.1666643284567; Mon, 24 Oct 2022 13:28:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666643284; cv=none; d=google.com; s=arc-20160816; b=FdDp+3N/Q9ff8lpr9RZKQq/V0uvjbxXYP64nHSQFxSxKCg6jejaR9UjUv5kYQ1IYzt u58asjyi/1FL5jOZTJfXQpFypMp2MnyxI0Bkpckq/pyY17NvhBYDcmWy4awTy+6486Xa kVoxv4v15LA+k+0VCy6rr7kRJADlbZ57wAi/pP4sQR+nC0BstNYwWepv1HDFU/ApqNqB NAB2RCQy/wSsOlf0JAnr337TWNUHVgLklVmkv3NuAkyBIfBfsH3a0sxNyJiNaj7pyIs7 /rw1vvCm7aR3AtouW8MR9rSOG+S1zaKM9uz7Cf68KchCijc2ZBUr9HeMhFuF0Pnvqvp/ SjSA== 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=lJBCCHlfmw0Tzu1mT1fvqlEYMGba/85H0JU+RoIphVI=; b=pkb0Nzo5Kq0bT/NbRv36tFD4IUKU9A2cVNADODtHcwfqcdRqGldXyEKlXsnjWceMpY X04qPPGNnjT4hU59cjHzO7HoVknPgtPynOzbGD0rgWWGgdD90ihO5lpkE2zCz2c7SXgr W84UEcHtiTNd51ljjZ03PJoaLO2qUCbtSPocaj9EBgNgJS1sXfm6sVwPXKLLqUfKKswW jcMLPsUhFXUMMtfzpKFwCTdNWwIxGYN8Exhc/dMGCSJnrmsnsJag3v7X9dvKtMSRus1R NnVe7OgTGVcTT8RhLtm3CBZGhV0NBEg4AlnbJkqH2Dr5Q8kKxMUVOK7NTl/VGuBKQWSD EXJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cuBqj0G2; 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 bf2-20020a0564021a4200b00459c2ac54e2si622776edb.255.2022.10.24.13.27.39; Mon, 24 Oct 2022 13:28:04 -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=cuBqj0G2; 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 S233812AbiJXUQD (ORCPT + 99 others); Mon, 24 Oct 2022 16:16:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233399AbiJXUO2 (ORCPT ); Mon, 24 Oct 2022 16:14:28 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70148EACB9; Mon, 24 Oct 2022 11:33:04 -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 sin.source.kernel.org (Postfix) with ESMTPS id 7C320CE1346; Mon, 24 Oct 2022 11:49:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5814BC433D6; Mon, 24 Oct 2022 11:49:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612173; bh=ksz5cn29JcW54iRPWf1XJ2b6P5WFBFylJ5K12NnaA9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cuBqj0G2CvBZRt00SeSicYs1PUYHRDqK53BxqrP6kjfQLgE03wlIHYCJ2nsLbyfDv lzzMwf+SdrhTZLQVo/OcePc8BIuAdUuMeCooBgD650r7pdVmlMp5S1EsaP0RBPmIi5 k2uGAnf9cZsGeAKjNh/ehCPgnKwUVd5KZXbbAqbI= 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.14 096/210] net: rds: dont hold sock lock when cancelling work from rds_tcp_reset_callbacks() Date: Mon, 24 Oct 2022 13:30:13 +0200 Message-Id: <20221024113000.140983339@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112956.797777597@linuxfoundation.org> References: <20221024112956.797777597@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 55bae71bf339..ae4901933e6d 100644 --- a/net/rds/tcp.c +++ b/net/rds/tcp.c @@ -162,10 +162,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