Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp553470lqt; Fri, 19 Apr 2024 04:03:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXjcfSNCXw8IrfNQb/CuK1DzcVD2zyQcbRgUSddyl5/nqvlVf7A1AF3W3v9P+nwFdM7nj6shgB4FedM3NhjaxLmYeNbaY5AfYZdPfXWDQ== X-Google-Smtp-Source: AGHT+IGNGCkeyYZ6eNyFCdvLyOQ1OsbIa2uklM/gtlvhLU+wDg863isxbqIJeIWlvrU5Yc0kzDgs X-Received: by 2002:a17:906:b24c:b0:a51:b49e:473e with SMTP id ce12-20020a170906b24c00b00a51b49e473emr1803749ejb.19.1713524630398; Fri, 19 Apr 2024 04:03:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713524630; cv=pass; d=google.com; s=arc-20160816; b=sB+OmkeTxbp8eemRHmvnCqvnQCJUkGpxClUiErNuQEun2+Zy2qygrK5NzuvJBINrNC BHvNB72GsjOly13VpcfT9glWnXStkdEAzzL3ufwBSqfiGs1bs+yP4VpfeiO/gOShRBFB 2ubp2lsFrBrrRNjutspMH54/X6KMKyjO8hNFFAzrM3SwOHDKnvavKN01skOPd/Hnn8+R BUeIhJnE+kh2hOAiJBaYeAuRFxgSVYFKNegu+Qp4E53GdEgZ0C0WYsyph7hcX1Qcaq3C jG3vxgoqqVGZFbZZKxXpTTtIC32NqnH1WvO/trLBx8HOvvB9+BoGGAwR8VhvhYzGzIwn u6QA== 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=l9vdoJJOxoGeuedGlZm9BwZrynnr1CGXHROVAzKjvgE=; fh=NPhgz18nS0/kcktD85Hx4xfR6krwqNmBpFJd6LCBHMw=; b=XstN8Dkpg189nP7tHOGA/9qegaZ7VkkwtuVR4TsUq7fwylXL+hVmpWsRchdnjQIr0s bnHOBYYXN9cwr0DCvgflC1bVvCxDULOOtvvBCVtBT/cctrc0qoZO9+1rAh/grVqHXjSm MLYqm737xV4Nm91wH6hPV703qvGcqs1w9L3LnXPak0kXOEoDH4tqXS87lQMTmimNwMtK zM9MQpLi4Fyjd3JnAWiVvhfz1dRXit9a16rcjBYItEh4YosL6oXoFkf2rrDxCCyb7/7F MFPy7+/RhISGx/7XU77SZt16BRdl78cEf5Jvi9i9NvjwqIWduwxqOq/+bXdYLlu9C7vG VccQ==; 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-151344-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151344-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 l3-20020a1709065a8300b00a524307d5a5si2075728ejq.983.2024.04.19.04.03.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 04:03:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151344-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-151344-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151344-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 173191F21D69 for ; Fri, 19 Apr 2024 11:03:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D3B3E82D62; Fri, 19 Apr 2024 11:03:13 +0000 (UTC) Received: from mail115-76.sinamail.sina.com.cn (mail115-76.sinamail.sina.com.cn [218.30.115.76]) (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 DE5B680629 for ; Fri, 19 Apr 2024 11:03:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.115.76 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713524593; cv=none; b=mRb23CCbeZmX/6Hseb0lDTMRzphZPcZyLy4WKjJdJfTH7Pvb7pUYYuVFLGtOn42rGfLviW166v40DdiiWRTcYKARkM4dkDS0YE/PBgXiR04Ei9ISgmfK46qid3x0GlyWM3JhHnk5xLExIdrnxqYOqEsiRK1oZjce/wRtcQWvU5E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713524593; c=relaxed/simple; bh=EA2I8c3ppVC1x+EQitfhhfZDOkuv79dfnWWAKMXjulk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nglGBmmt7Tp8DW3vXwvLAM5NqsgZzIKxpvMmPuytkreMPbvCl7OzHhlkXSDiZpjV5UO6YzhPFo0EWh3aksY+3uxHqDc3fQH1RPPhxIHYpK3kW5dWzqBqWS/glQaI1AexjRyxogE0LxGs5gKRRboCFkrsw/FtrGvqkjS6LP65ELw= 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.115.76 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.253]) by sina.com (10.75.12.45) with ESMTP id 66224F5F00000946; Fri, 19 Apr 2024 19:02:58 +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: 3018731457733 X-SMAIL-UIID: 226EC22C9F59408E96BA531040139487-20240419-190258-1 From: Hillf Danton To: syzbot Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [bpf?] possible deadlock in __stack_map_get Date: Fri, 19 Apr 2024 18:44:38 +0800 Message-Id: <20240419104438.2747-1-hdanton@sina.com> In-Reply-To: <0000000000003f81750616646cb8@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 On Thu, 18 Apr 2024 13:00:28 -0700 > syzbot found the following issue on: > > HEAD commit: f99c5f563c17 Merge tag 'nf-24-03-21' of git://git.kernel.o.. > git tree: net > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12f1f7cb180000 #syz test https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git f99c5f563c17 --- x/kernel/bpf/queue_stack_maps.c +++ y/kernel/bpf/queue_stack_maps.c @@ -124,7 +124,7 @@ out: return err; } - +static DEFINE_PER_CPU(int, map_depth); static long __stack_map_get(struct bpf_map *map, void *value, bool delete) { struct bpf_queue_stack *qs = bpf_queue_stack(map); @@ -132,12 +132,18 @@ static long __stack_map_get(struct bpf_m int err = 0; void *ptr; u32 index; + int dumy; + int *depth = &dumy; if (in_nmi()) { if (!raw_spin_trylock_irqsave(&qs->lock, flags)) return -EBUSY; } else { - raw_spin_lock_irqsave(&qs->lock, flags); + preempt_disable_notrace(); + depth = this_cpu_ptr(&map_depth); + *depth += 1; + raw_spin_lock_irqsave_nested(&qs->lock, flags, *depth); + preempt_enable_notrace(); } if (queue_stack_map_is_empty(qs)) { @@ -157,6 +163,7 @@ static long __stack_map_get(struct bpf_m qs->head = index; out: + *depth -= 1; raw_spin_unlock_irqrestore(&qs->lock, flags); return err; } --