From patchwork Mon Oct 24 11:28: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: 9936 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp599469wru; Mon, 24 Oct 2022 11:45:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5SqVpdWqGQ5mjUSOdVHxZzzFZk4eRmFfkQ1y4TclqlzzYVh9KC7TTe0sx+zB3nbbbnyCu8 X-Received: by 2002:a17:90b:264e:b0:212:d06f:35ad with SMTP id pa14-20020a17090b264e00b00212d06f35admr21203592pjb.2.1666637154955; Mon, 24 Oct 2022 11:45:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666637154; cv=none; d=google.com; s=arc-20160816; b=EpxagShEOSbDvPWaw30Sen2iXaU9js1gAg4eU1UVPcJdO0AbT2yhGP2np5Sh+wOxcr 6RemJJpvltnMttRKhYeOEXIRiaRGYwMuH+ZINjqGkO5SBPj1TSUmlyRrw1VJzW9uE1qR XEglFa0FHIdVBrJKGY88F4BDgN2juC0jsfwXcdFKgFFxnyv57IabIIdD7EDyXkGbf7vr hqA7BiTAHpdVZQ5Ct6Ldmdbu7nZsMAmQXRza6mxHhP930vnw1rwVe1MOt4WaDItVuDjv JrAwGbKbSTpdKYeREbpnleplscJiRkatS8gdUXBOoHOURSb4t/r7Sjbldxsz0ErVW66B FlPw== 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=xgW/e4p+OXSBThFjvJkn33vQ0QGDMIfcyIz0b2IGvdw=; b=W6toBA07rn3Rfs7ahrpKJzHXwNWJJRJAZu8cuUqouLBn2d8Yl0u48eggFIzzsqByGp Bszmb8bUZhvPieXQZQJD7otD5L8R1QepPIgbhIo0ZjddlCV3i1FTXcXzWP5SxCW+lwje EtlC4eMYQqQO3vD5bDfCxXtDWUpkwx4xOKOKV34WBiXqwqGh7rpxYkO67r1sEGU7KC6G s6QQqyafkQWFDfmx9lJbNt4SjFuAdw3bxNhU78YPMnw10QQPto4wDItuqrSWvuy9iYzX cD89C74SJIcw8y6O+AfHt2U4lThU9T7+tjLVBw91M776IV6KxOTq81yvSDuPfXWkibJI TFJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OkAc5M48; 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 r36-20020a635d24000000b00455074c7901si340443pgb.36.2022.10.24.11.45.41; Mon, 24 Oct 2022 11:45:54 -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=OkAc5M48; 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 S232392AbiJXSo5 (ORCPT + 99 others); Mon, 24 Oct 2022 14:44:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232628AbiJXSoL (ORCPT ); Mon, 24 Oct 2022 14:44:11 -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 9D32612773; Mon, 24 Oct 2022 10:26:25 -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 09C8ECE13BE; Mon, 24 Oct 2022 12:21:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD360C433D6; Mon, 24 Oct 2022 12:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614111; bh=kv2aafQZWXxG9dFeHNnit7opfoXDwVGlj6UlCq69Ok8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OkAc5M48gTehdplOwUwLdXoprtGi/OalDqHDyZd1+zXQ8pTIkDHnRiNUh+M0+9o+Z gzDii+N8hlz0X685ofSBBtXHOuIV1pmbrYrpNW9eX7UDtJaeLZ1/iHL5YQu36gnxTi uoQW+fMxKQEPE1rVtFGQIgUrhSKfkP6MOJOte5gs= 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.10 136/390] net: rds: dont hold sock lock when cancelling work from rds_tcp_reset_callbacks() Date: Mon, 24 Oct 2022 13:28:53 +0200 Message-Id: <20221024113028.462605528@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@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?1747595721535872664?= X-GMAIL-MSGID: =?utf-8?q?1747595721535872664?= 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 5327d130c4b5..b560d06e6d96 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;