From patchwork Mon Oct 24 11:30:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8733 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp423856wru; Mon, 24 Oct 2022 05:26:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6r9GPSBdniMnzCOt9wkharJM50SoWbScLU1qYQD6hf9r47jJZfAOZQUgB972C+5SmmyBLd X-Received: by 2002:a17:902:b718:b0:17a:d64:de09 with SMTP id d24-20020a170902b71800b0017a0d64de09mr34118503pls.106.1666614360427; Mon, 24 Oct 2022 05:26:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666614360; cv=none; d=google.com; s=arc-20160816; b=D6p1MuGJt8WHKBzWXMgX1cXXMdkDTcurGc3wovSMqP3qqfkD0fRHQckZHvpFR1EAVz NINzVfGs7oUcKmBCkK+8dimi0yBdm+Jit19ZCf6yRX1qXvZz5vHEpTRDchI7h4mrZ2Co FmsM/Es7VbvyppCYRgPh+gR6kq/N/v3PKm5MekjtoJdKAN7MJ3xFiISfXG9oULM+1Qw+ lYzvaZhtxvyMroOZceBtNeTiLFCILJtMFfEehN2BGjxDwNAmo0cFQSx0UJUqYP+glVsi DFpkLNagN9NnZIDq6dzo+EcgSUmA8N/Bt+G5cP3VxLVtiD2LzVYPKWgraTx7jUWMnsk4 ri0Q== 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=t/iIHtrV2Jg2jqrfGzEYZXaab1jahY8/hi8MnxizqUQ=; b=cNQD+FSKKOVVNsQAZ9is26ZeNj0qv8qj8K0ZgAb29i7iccs6XjLrNUG0h9nCE+o7l6 cTAIQnyGlP2lxSPM5AsuF8jV0C6xyKhfZDob32IQwtGts4GTgQKl59w01Vo6mOR/Lnlh iQREmknMUfkaQNOdMK2NCS74fIkEJ/9UJvNRd60i6tEBbOmHeNPZB9ziwoiNyLhbHS9i 5+MoSHzh4qkaojLzYMkc32Qy7Iq/QeLBBQkRNiB3BkY7HoolzNG+IbTw4HAz5khoJdYa +hp0SckR3zr4tJGt2jxFeoGRXC48tup4E4h6puwDSEFCtrl2EBO85eBGp/Jya4jK7Hz3 f2hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=b2lvme8P; 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 q29-20020a635c1d000000b0045f83f1eb56si35996942pgb.234.2022.10.24.05.25.47; Mon, 24 Oct 2022 05:26:00 -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=b2lvme8P; 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 S233591AbiJXMZR (ORCPT + 99 others); Mon, 24 Oct 2022 08:25:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233543AbiJXMXp (ORCPT ); Mon, 24 Oct 2022 08:23:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F605275F3; Mon, 24 Oct 2022 04:59:54 -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 dfw.source.kernel.org (Postfix) with ESMTPS id EDEB461257; Mon, 24 Oct 2022 11:59:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C0C1C433D6; Mon, 24 Oct 2022 11:59:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612793; bh=7JSOKnN3EJHVsIrkcfYIdDr89HElem67G5x8SxQh7dA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b2lvme8Pg1gThCv+SinYO8YoZlHJ3qKuDzbjJVJKGxqwLBoiaJS5v8ZOq284ugXqf m1/vpHPFMl4z5NNh3z13pn3mZgBlYR/1FTK3/aDn56kXmrcz/qGBo8nKii9Pco1ucQ iEH3qwgNHKSfjJ2NmpDujjZ64mjXvpR2YBGoHpJk= 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.19 090/229] net: rds: dont hold sock lock when cancelling work from rds_tcp_reset_callbacks() Date: Mon, 24 Oct 2022 13:30:09 +0200 Message-Id: <20221024113001.961587129@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@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?1747571819220430775?= X-GMAIL-MSGID: =?utf-8?q?1747571819220430775?= 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 d4e6466d3989..645cbb17c13a 100644 --- a/net/rds/tcp.c +++ b/net/rds/tcp.c @@ -176,10 +176,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;