Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1928144lqp; Sat, 23 Mar 2024 15:47:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXIDmr0DBEsvNaBT63rGVbEvGgneRcCjYtVJhW92yv+jzf947MT0BaET2v7Lwy8XYNPB7YDhbDEeNhNYCDioIq8cxa5qCq7eyJxmTm3bQ== X-Google-Smtp-Source: AGHT+IG1m8r716TdDtj/WkgldCj3pflWRtcJqMN4qFQRBzSjZ3iiH0T++mZOXHJ7/R6fCBu++4+l X-Received: by 2002:a17:906:2b4a:b0:a44:c1bf:a801 with SMTP id b10-20020a1709062b4a00b00a44c1bfa801mr2340674ejg.17.1711234076667; Sat, 23 Mar 2024 15:47:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711234076; cv=pass; d=google.com; s=arc-20160816; b=eExCZTokPzfLVNHfzIP9rjMaIL3hu7i62tGONxjbROekp24XsGtWoEQIXwD/b/rK2F /c3GA6lenjDqe1wCfU9Kbuw6UjEpaPt2gbH0gX3LiF2GULH+7Ecw8gktnKSY90mHMiu1 qZXEGClkJfDX77ZvX2m7L5NI6J1zYHfyUr6N265NweS2YSKxcfgIFGZnIQoe3sxzlcPh slSiAeGSpednujGVLew/mtOfq3VbOceNRZhEhR0Mfp1Jzuc0zAEhL+K8xpiosCilDDvD UvMlphYKyrQoMy1cVNvuSaamTsCDC3tR2+mZiT713jCUAWQWreTVdbiwBeGzYtdS5/Of sTVA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=wTRwSGhDl3amZ4F3iODbRx6ZyNQiB9TLLV+C9CHSRYA=; fh=eMThGCtFv9vFDrF1mdjhXXNwvtiSOPjYZayEOl6xCGA=; b=MB42SypykIaD2OQp58Gc+pn9DrAxBffWcFuWsPS7A9xEt/F3A/L5kNakRQmwDA93vY jFEx1+LvNyA4cuRKV1iyPByZ8i+umk01EsL0GHZdZOc0xHZIu17T8RkK+hhcBpnZxPCT 85UyRq/bSVuIa3WC+3onTH0LzIiTppW6GfEaVHQAWH9Uv80ZwoW8UTTvUxxl1RLimnKG v1hx9WlOqsAHv/PrSbKqw2qCr7xeTd7p9xPzW5p5pL3eH8NpJ58RZb+bx86p6UL4mPuD 1MTCSNDEYQWY+ftjTFKhvS++3gxkoHI3GszEIM9h5qIPN6PDlGBwbf+y3S5EMVm+rf8L f7bw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-112510-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112510-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id sa10-20020a1709076d0a00b00a4740568628si1086130ejc.224.2024.03.23.15.47.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Mar 2024 15:47:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112510-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-112510-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112510-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 638001F2139A for ; Sat, 23 Mar 2024 22:47:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 68D145B683; Sat, 23 Mar 2024 22:47:27 +0000 (UTC) Received: from mail114-241.sinamail.sina.com.cn (mail114-241.sinamail.sina.com.cn [218.30.114.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03B115CB5 for ; Sat, 23 Mar 2024 22:47:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.114.241 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711234046; cv=none; b=k+IATebPfq6VhbvL/0lavoQpR+Hq9xK72WCRpnDXeB8pO8CRY2Vj/HKRutY3Ljj0YXJU0BUMGPXVCwk8u9jIHbfXvwilHC2yVel3FeDgBO1iTI2/mDXqVqlhxf2yyvRo4WeQpgFrbIqNnbOUEMDC1K60xe5i38Z/kqWqP2OoBJ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711234046; c=relaxed/simple; bh=qmpifuZ9FetFF2yzVcFaw9ODKGMn6JCSt0z3HlZrlVU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uU80Tx/LVAEp3GpONzfZyvMBk+vKgQppaL7SkWoVO6Tberof3RZQok3n8R7FJvUvGhjcxb8Gy/j1q9ILLDvcESaov1ChaIFGi9NKgXqBjKkP6222c4+jCTdulf7HerZ0hM9MoR9rgDP6gC4EQkXxqJKgbsQK/D9uno4wrsiLEHw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; arc=none smtp.client-ip=218.30.114.241 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([113.118.64.171]) by sina.com (172.16.235.24) with ESMTP id 65FF5BEB000006B9; Sat, 24 Mar 2024 06:47:09 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 0786845089258 X-SMAIL-UIID: 5FC8FF47085C4E5C9330908AEF772146-20240324-064710-1 From: Hillf Danton To: syzbot Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [batman?] [bpf?] possible deadlock in lock_timer_base Date: Sun, 24 Mar 2024 06:46:57 +0800 Message-Id: <20240323224657.2722-1-hdanton@sina.com> In-Reply-To: <000000000000901b1c0614010091@google.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit #syz test https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git ea80e3ed09ab --- x/net/core/sock_map.c +++ y/net/core/sock_map.c @@ -932,11 +932,12 @@ static long sock_hash_delete_elem(struct struct bpf_shtab_bucket *bucket; struct bpf_shtab_elem *elem; int ret = -ENOENT; + unsigned long flags; hash = sock_hash_bucket_hash(key, key_size); bucket = sock_hash_select_bucket(htab, hash); - spin_lock_bh(&bucket->lock); + spin_lock_irqsave(&bucket->lock, flags); elem = sock_hash_lookup_elem_raw(&bucket->head, hash, key, key_size); if (elem) { hlist_del_rcu(&elem->node); @@ -944,7 +945,7 @@ static long sock_hash_delete_elem(struct sock_hash_free_elem(htab, elem); ret = 0; } - spin_unlock_bh(&bucket->lock); + spin_unlock_irqrestore(&bucket->lock, flags); return ret; } @@ -1143,6 +1144,8 @@ static void sock_hash_free(struct bpf_ma */ synchronize_rcu(); for (i = 0; i < htab->buckets_num; i++) { + unsigned long flags; + bucket = sock_hash_select_bucket(htab, i); /* We are racing with sock_hash_delete_from_link to @@ -1151,11 +1154,11 @@ static void sock_hash_free(struct bpf_ma * exists, psock exists and holds a ref to socket. That * lets us to grab a socket ref too. */ - spin_lock_bh(&bucket->lock); + spin_lock_irqsave(&bucket->lock, flags); hlist_for_each_entry(elem, &bucket->head, node) sock_hold(elem->sk); hlist_move_list(&bucket->head, &unlink_list); - spin_unlock_bh(&bucket->lock); + spin_unlock_irqrestore(&bucket->lock, flags); /* Process removed entries out of atomic context to * block for socket lock before deleting the psock's --