From patchwork Mon Oct 24 11:30:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10147 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp638540wru; Mon, 24 Oct 2022 13:27:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM74prmJMMXrFVcleUVfVaZuEasj99aYtB/c9z6ENwpMj/jMXqARYSIFrxP3wpuq84bZt/jK X-Received: by 2002:a17:907:a47:b0:79e:56dc:5373 with SMTP id be7-20020a1709070a4700b0079e56dc5373mr14746166ejc.148.1666643234393; Mon, 24 Oct 2022 13:27:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666643234; cv=none; d=google.com; s=arc-20160816; b=sNMi2/3jb9vQvZmxDYfcvdJelfQF1o8QTfCjaUc5qPptKbLjg98qQWVVa8Sny7orJP 3o5ohctEtz1jgI7WUvpocdv69HD7+oYb56rSKm1eIwMlT4xpvWYAhF9EernelYcqbApi wkT5UvUbNnEArWRsxLsxV6QmgzUArqolQWGoGAuhw10LV9eX7EBIqEe1Odx8S2Y+vlbn okW/pzqNv2bF5U81FZ7XNk2YnO1I7y4u1LTM844tHdoxICXwDiTHyNKK072WzmSPfLrJ 9fcV6QaEO0Q0xCAEIw/lZZXCngByG/XX0gAvUNpCRH4UzBAXwH/UBG/Xwy5cQEdURdbu yeVA== 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 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.26.48; Mon, 24 Oct 2022 13:27:14 -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 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?1747602096382573181?= X-GMAIL-MSGID: =?utf-8?q?1747602096382573181?= 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;