Received: by 10.213.65.68 with SMTP id h4csp2120158imn; Sun, 8 Apr 2018 20:12:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+IHB+LmUUDwszuIKBlNhDAfxlC81BU7pDEriJJTa0MECW7N26vMmOCMMDkdQOb47Z3SH56 X-Received: by 10.98.210.7 with SMTP id c7mr27480578pfg.92.1523243528271; Sun, 08 Apr 2018 20:12:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243528; cv=none; d=google.com; s=arc-20160816; b=HEM7MIfArWDPr5GRyHx2seZ1DQ0h4jtFNtA2vSDLsdqDlx+HJNpFmwOyKOmh6sTt65 nhGtvfrC2IiwXxKC6KgxARhJkUu3BDQRS4ga6y95AoZb/zNXy2qXaLLu+ZVf8NgDiknP NrpYuCjqcyDOIuQNEh0Ykf4zydx/NWliLU/U3YPSyAmrMRX38ftmImRKZxEBeI7F9KqJ jTaJ+FvQKwvumucbHZmi4YYpheQSy0kGdOTj8TDTdsZskbSPVWQZKAeoxUe5xyswkC27 K518L5gBtc83LACqVmD7WLCE/m6aFhi08nJPM6GjPWdbQ0dIaNZ/1B3fkC5Pxt5YsvFv ZKPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=KV8lIiqYhT8YCDqR0QwBz5jhMQ/H5xOlCbVkpznJBFI=; b=sfCaVasMmeAVtqoNactm+cCPLhO1jjwVHSBvunEbvbhRz2T5Beu65/4/Qo9+fV1ODQ 68B+RGzEWkhs2HCTeg7jWkMUzwihtt8bVig/9gfOF6rUzpxmqEvonjbOAp682zV6Tp2c JHh+h4GBqjyC6bvUXL8NcrCFthdSkpGygA3R0578ab1w47uUfpNKPBpBlIZNpDpjHQYW ISykxncocyVf9XDbB93MpI1az/OUfRemxp/09QY/BFRPi6/bNmKbH03+3bow0uVmkR2T kHSGqzpmFWxmb9I848GHNlSc/Rf6BDWh8YwSJsyntv7nUbYLlGpc3sQV16dn5yZLv6or OWAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=RNcjcwq3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p20-v6si13889151plo.284.2018.04.08.20.11.31; Sun, 08 Apr 2018 20:12:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=RNcjcwq3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755870AbeDICmT (ORCPT + 99 others); Sun, 8 Apr 2018 22:42:19 -0400 Received: from mail-by2nam03on0126.outbound.protection.outlook.com ([104.47.42.126]:2432 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755428AbeDIA0z (ORCPT ); Sun, 8 Apr 2018 20:26:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=KV8lIiqYhT8YCDqR0QwBz5jhMQ/H5xOlCbVkpznJBFI=; b=RNcjcwq3mn9P6FnMYTC4xs3ymcephfXjG2XWIgD79G1cwm2RlfVCMrv7ox0B6mWwgMm1meYTNXuQUOMWc88UiLoX7m17NEB8dkoBGQzggdQwj89N0onn8yFIE2mCDVsUWDRRFbsk3EMV7JK0VcvWMu4mjwWrf2kCAW94zATmWP8= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0885.namprd21.prod.outlook.com (52.132.132.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:26:46 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:26:46 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Xin Long , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 028/293] sctp: fix recursive locking warning in sctp_do_peeloff Thread-Topic: [PATCH AUTOSEL for 4.9 028/293] sctp: fix recursive locking warning in sctp_do_peeloff Thread-Index: AQHTz5jxpaYe6gjSe0mhk2C0RI1dBw== Date: Mon, 9 Apr 2018 00:23:12 +0000 Message-ID: <20180409002239.163177-28-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0885;7:wADFzuj1vxsofUaCFESqzN5sRSuq10kAZOVjjmHWOSMhsx9gv8UP4DPtIDKioU2nXPWwwm38jxQq96TE49KYd9m7NsV3sXb7oEgosTadd8dFwElX1O/sD8f51ERltYrafJY5npCNWFAUH4556iOztKsmB77bwNXzk//rEug6/YyROGHD2S+CjluEMcWaNFfn/YuiiET3JQQbsmS1+wZU0fT0ZK0bWOFTd1EujXyACDTcQ/j68AFzOcfoxqtMB0Ew;20:HXOlld4c55SpltS0zPAEypc1vZFA55qiToXqQntGEbx7yiPP1eCZaUFnf5CmsyVhq0K59t+DwmuZNk+eewYYcLgVtp7LiONG6Mb/EQoQ1gEwM5xW/2E12SZP1Qe0uCGEjO6eJKpLKMvCXE2a479OgNdcauwjT3IIEuIMsyjZOBA= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 4637d861-8bd9-444b-9d08-08d59db09400 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0885; x-ms-traffictypediagnostic: DM5PR2101MB0885: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(85827821059158)(211936372134217)(153496737603132); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0885;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0885; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39860400002)(366004)(346002)(376002)(396003)(39380400002)(189003)(199004)(2906002)(68736007)(22452003)(316002)(6512007)(5660300001)(6666003)(54906003)(110136005)(486006)(6486002)(102836004)(36756003)(14454004)(99286004)(86612001)(105586002)(72206003)(106356001)(2900100001)(1076002)(97736004)(10090500001)(3280700002)(5250100002)(6436002)(3660700001)(6116002)(575784001)(3846002)(305945005)(86362001)(59450400001)(66066001)(39060400002)(10290500003)(186003)(81166006)(8936002)(478600001)(476003)(25786009)(81156014)(8676002)(4326008)(7736002)(2501003)(107886003)(6506007)(2616005)(26005)(76176011)(446003)(53936002)(11346002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0885;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Rj7OFScT3YAdsw1jUhUkAYuhn9oaaAhzqar7gKPybBLvXGhvQMCPIZVfrdzcoWvyzlL77CW40SOqU7QBBWt6zuNBRHvE4vd72F7gnmNwEiR5R4Txmi9v8g3H3k2bsBpf1KX5CKxqyM9LIPtrMCgEB+dGG7tsg6t2h9OcVdmiGmIeQIQ1nt96nsWOUAnw/eXjqWiQUW93wNk1WDvi4Btkga4sdp4S8Rgw5InM8mLFdZg48q7Nze6wnHqq1BNpRPCqhKWoTsPSd0Sk0edL3R97UDwNQwJ6Qfp3n62ogaI7UkG54pxxJWvO5Urm32Oh96S3aNJoYLD4uZD1aXZbakqKJwRPps4tSKY2JIUPm/id0nB/kaSYH9YrWfh+rysPJE+PcIdtUBkP9gJ6iwukM33aExy+OBWdT6L1gTS4ZfzR7Fw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4637d861-8bd9-444b-9d08-08d59db09400 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:23:12.2373 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0885 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xin Long [ Upstream commit 6dfe4b97e08ec3d1a593fdaca099f0ef0a3a19e6 ] Dmitry got the following recursive locking report while running syzkaller fuzzer, the Call Trace: __dump_stack lib/dump_stack.c:16 [inline] dump_stack+0x2ee/0x3ef lib/dump_stack.c:52 print_deadlock_bug kernel/locking/lockdep.c:1729 [inline] check_deadlock kernel/locking/lockdep.c:1773 [inline] validate_chain kernel/locking/lockdep.c:2251 [inline] __lock_acquire+0xef2/0x3430 kernel/locking/lockdep.c:3340 lock_acquire+0x2a1/0x630 kernel/locking/lockdep.c:3755 lock_sock_nested+0xcb/0x120 net/core/sock.c:2536 lock_sock include/net/sock.h:1460 [inline] sctp_close+0xcd/0x9d0 net/sctp/socket.c:1497 inet_release+0xed/0x1c0 net/ipv4/af_inet.c:425 inet6_release+0x50/0x70 net/ipv6/af_inet6.c:432 sock_release+0x8d/0x1e0 net/socket.c:597 __sock_create+0x38b/0x870 net/socket.c:1226 sock_create+0x7f/0xa0 net/socket.c:1237 sctp_do_peeloff+0x1a2/0x440 net/sctp/socket.c:4879 sctp_getsockopt_peeloff net/sctp/socket.c:4914 [inline] sctp_getsockopt+0x111a/0x67e0 net/sctp/socket.c:6628 sock_common_getsockopt+0x95/0xd0 net/core/sock.c:2690 SYSC_getsockopt net/socket.c:1817 [inline] SyS_getsockopt+0x240/0x380 net/socket.c:1799 entry_SYSCALL_64_fastpath+0x1f/0xc2 This warning is caused by the lock held by sctp_getsockopt() is on one socket, while the other lock that sctp_close() is getting later is on the newly created (which failed) socket during peeloff operation. This patch is to avoid this warning by use lock_sock with subclass SINGLE_DEPTH_NESTING as Wang Cong and Marcelo's suggestion. Reported-by: Dmitry Vyukov Suggested-by: Marcelo Ricardo Leitner Suggested-by: Cong Wang Signed-off-by: Xin Long Acked-by: Marcelo Ricardo Leitner Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/sctp/socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 8cdd6bbe2efa..172465b7c0f4 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -1519,7 +1519,7 @@ static void sctp_close(struct sock *sk, long timeout) =20 pr_debug("%s: sk:%p, timeout:%ld\n", __func__, sk, timeout); =20 - lock_sock(sk); + lock_sock_nested(sk, SINGLE_DEPTH_NESTING); sk->sk_shutdown =3D SHUTDOWN_MASK; sk->sk_state =3D SCTP_SS_CLOSING; =20 @@ -1569,7 +1569,7 @@ static void sctp_close(struct sock *sk, long timeout) * held and that should be grabbed before socket lock. */ spin_lock_bh(&net->sctp.addr_wq_lock); - bh_lock_sock(sk); + bh_lock_sock_nested(sk); =20 /* Hold the sock, since sk_common_release() will put sock_put() * and we have just a little more cleanup. --=20 2.15.1