Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1302853lqz; Mon, 1 Apr 2024 01:36:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWLZdmxw8k1VLGvOhhavW3AKxbi9YaRKbUFnJsQ4SJ7tADpcJS2GaSp7DlN6WLvszqB6qM06ETPi3DiHQLFrVdoMKPVU+AkIcF1ztj+TQ== X-Google-Smtp-Source: AGHT+IHYsWtdNXAShuHpylrNt16yuK5gKMtKFEqlQkbC+R/mpAZ+SIwlnaphEGkA5kqp6YkQFXV6 X-Received: by 2002:a17:90a:8c4:b0:2a1:f4ca:dfaa with SMTP id 4-20020a17090a08c400b002a1f4cadfaamr13413987pjn.13.1711960591041; Mon, 01 Apr 2024 01:36:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711960591; cv=pass; d=google.com; s=arc-20160816; b=YnHcOXfOrqJbBb0QFxeC3Vytb6uj+1ABZXDab0FhOTYbMENBc1ndPQsbMAPvIJT8rI WSTvUQQffceDy1p+QpG9W8EU4CPLQfJV0ZylAcUOzhglCgD8lcIhflUGyXjCjs8spBtI EW/v5rERqDi0wpPOSyyHSoBLyOzGJLJStbvfrsBnbTB3DMMdxKFo+JaO+pAA+JNMMi2t UM4ULqiSkTwHU6ZF8W5TT9TZPD2jziUv772ojFCycChC7EHzI6adGaW1KepjAVAxfDP2 VoJAjnlBvPJgJBmdf/FSS2upy2ZmmLpsiEhZ2bfXcWwnSzA4N2polC57zlfuEb9nwAid lrvQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:message-id:in-reply-to:date:mime-version :list-unsubscribe:list-subscribe:list-id:precedence; bh=BIhjoeOynb3lRObJxaxadEdrd7xsN4WBzbWXXiEPgdA=; fh=V9AeBafJgTW96HdC48wsxGAfd7Fe9P2uAL8tLCjpUN4=; b=E3lxxfjez8q0B/JTia0bUGfySy3wDsDSTXihO/6leIi3RnXnsY8oAOXE5bcHhciJ+J Wc8l4llSnU9TNspr4ZU2ECb2Azyo4IXar08juMutClH04y91nY26NnWKFl8IqfPSqtXt LgS4whhD+XHeASFWA1UeBjkX109qeSPtDivVyp8InNoHy2tyeRzHidSYjum6W6pltEkB 5MIZcDpPE6hfw+cOrOohd3qWdKa78nsLK4JGKtSilGZkvuMtCMZIwmpXahn7692Lj5lo 8DEgqxETeUy8tlsCmNEEUiAT/kRs7zdMUe4iHqSbHdQ+tvLmk1EIwoZo4OT0gqy10XJz P4mg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=m3kw2wvrgufz5godrsrytgd7.apphosting.bounces.google.com); spf=pass (google.com: domain of linux-kernel+bounces-126521-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126521-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=appspotmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q4-20020a17090a938400b002a028c3b3e3si10888791pjo.73.2024.04.01.01.36.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 01:36:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-126521-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=m3kw2wvrgufz5godrsrytgd7.apphosting.bounces.google.com); spf=pass (google.com: domain of linux-kernel+bounces-126521-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126521-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=appspotmail.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 531DAB20E2D for ; Mon, 1 Apr 2024 08:36:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B3FB749F; Mon, 1 Apr 2024 08:36:21 +0000 (UTC) Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52D2A1113 for ; Mon, 1 Apr 2024 08:36:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.69 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711960580; cv=none; b=hcww1R53zXn4y1xQKmiFj8HK1eJ4ut9zxDM6C3W2kujyLH8EhtbBuNqRo7YACuXu/w3Dz3pa8bpBee+MlnzraPHgpn2Mqr0fNSLbBOGEGeIcx9e88Uol/YGc45bXmm4etP1U5PMy+5hDckN7KUr4J0Q7A0uwO+962/C66EwMa6Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711960580; c=relaxed/simple; bh=atTYbdmCAY25zl1jksRR2HFkj9lyqDiWX5HEGlQUorQ=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=h7KfsM4JQRwlZuC61Sq+tGPIYcW3hdD1elYWK98eTCpKAlNGrnUQOOzIV9e6DbHS3FvJvP+zRVJCYgFjSVTzEAJBGbnVaioD5K67ufRemLn3U7m0GkzuIBrjLevDcI2ccKNzHWnD6SEP1GnqLtAlaZrOwVj3W1IvdtHkZhld0fc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.166.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-io1-f69.google.com with SMTP id ca18e2360f4ac-7d0330ce3d4so442415439f.1 for ; Mon, 01 Apr 2024 01:36:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711960578; x=1712565378; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BIhjoeOynb3lRObJxaxadEdrd7xsN4WBzbWXXiEPgdA=; b=UZyhlAhWue7yC9i1hx2CKp9hAjCLJemhxs8q0bFZYnhgX2KytEjwv3UyNiwJ3pMi/k 6cxfco8umgfKAO+9WGYeMBvrrB2JPi+uJIPMqT5SYgbVPPNehJp+9TMSiZF5JH6vCIce J62kMi3PJEICC8jf6RdAw6QibsmGScs8g1OjnmmCEzc5iH6KHz/zS85pi1pvuINvZBso GU+FQ6iUhtbgD5KQL2/Yuy0LY358LPivWoETWkyHbOzIkmc5VaGIkXiRuB7q51vj042v RIAA2XU9Pv2l+o3gwDDNTBqAqh49RVOIC/1ZmnqAJ8BXBm0PZeKVJbHF4IP/64lb1nkF Wf+A== X-Gm-Message-State: AOJu0YyZsviT5ySyzcoD0ItkSuCrTQ/fG8TDKG+Jrq8NCuQod9V8Q+t0 LTAUYkSVVmF4bMBNkmuOgfjI933BTD+eqB0GvWsQl4f0z5lxhb3PGXGY9r8QJgCwkse95x3Zmog 0fao1d9ecIGoKZuP/hokU5Cu13LBbDpKJD/v4u3KaSIUAlccJKSf2loukLQ== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6638:16c1:b0:47c:561:dbbf with SMTP id g1-20020a05663816c100b0047c0561dbbfmr368843jat.6.1711960578601; Mon, 01 Apr 2024 01:36:18 -0700 (PDT) Date: Mon, 01 Apr 2024 01:36:18 -0700 In-Reply-To: <0000000000003ad27a0614fa0b99@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <0000000000002844af061504e249@google.com> Subject: Re: [syzbot] [syzbot] [kernel?] inconsistent lock state in sock_hash_delete_elem From: syzbot To: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org. *** Subject: [syzbot] [kernel?] inconsistent lock state in sock_hash_delete_elem Author: lizhi.xu@windriver.com #syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git fe46a7dd189e diff --git a/net/core/sock_map.c b/net/core/sock_map.c index 27d733c0f65e..ae8f81b26e16 100644 --- a/net/core/sock_map.c +++ b/net/core/sock_map.c @@ -932,11 +932,12 @@ static long sock_hash_delete_elem(struct bpf_map *map, void *key) 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 bpf_map *map, void *key) sock_hash_free_elem(htab, elem); ret = 0; } - spin_unlock_bh(&bucket->lock); + spin_unlock_irqrestore(&bucket->lock, flags); return ret; } @@ -1136,6 +1137,7 @@ static void sock_hash_free(struct bpf_map *map) struct bpf_shtab_elem *elem; struct hlist_node *node; int i; + unsigned long flags; /* After the sync no updates or deletes will be in-flight so it * is safe to walk map and remove entries without risking a race @@ -1151,11 +1153,11 @@ static void sock_hash_free(struct bpf_map *map) * 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 -- 2.43.0