From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 02F193559D3 for ; Thu, 26 Mar 2026 05:13:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774501993; cv=none; b=iIrqqL6F2lSul5a0JASziwo2HQ2rkPII2DAnZHqcD8sTTeT1C76ne4GkdXU8LaxRg9N1K7OKdE1SOihRlUjzy4X6fs9sWbE+qW4TjcwbYoFAwA1qDt0JTyQet0nAaB8ILgY9hP+gCCpFF8IDC0YLaGqzw7llTXJI4eAS/3ekxEc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774501993; c=relaxed/simple; bh=CrCHGvVBKIandtc4VKSowVEgY2CkrtBYx77eJ9fExTs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AavZPrKnXLBch3HfR0lvg/gZDh7sb/rJxqhu75W0vAu9ouIryD8d5CC29jwcVHX4/8HPE9tgKPahXyiSdXAyUc3Nx0MN5brSoG64ZUh+U/SRpnJ1H7spR3NluULREXN/76LOmqNhlfxC5mUiRf5Jru+qY06ejXtBYTftfv1R7dA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ROfx2ipc; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ROfx2ipc" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2ad21f437eeso3113045ad.0 for ; Wed, 25 Mar 2026 22:13:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774501991; x=1775106791; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CrCHGvVBKIandtc4VKSowVEgY2CkrtBYx77eJ9fExTs=; b=ROfx2ipc59etm/OWULJVWDe4sozlD54Sc1YZZbeUCnSZIl5FX03DzAbLvr0qpOhcZ8 xC9DkYrsK01HgWNnPIhwUw+ZrwhdChIcD5xw1pwydJdCECL/XpR9wxzFGHBvHGbhOIb2 uW9g7PL3RP069xoK8jfKDNlUmcoDVBemzKiGN2ujpbWDdu9nf+0qUlIjv4USsbZrGHtN FjwWmHERKbgx5BxBicOgnKgYIzKLsFy0ZdvDuqYlgAAuIR0ayNgpz2/e8zmzBSuZjK2X tejVigyt5qLfkypuRb68NPFf7aLcfvg4Ys6kzeOI8SuPjEGO34atKmIYhe0KjIhcaD/C Offw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774501991; x=1775106791; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=CrCHGvVBKIandtc4VKSowVEgY2CkrtBYx77eJ9fExTs=; b=S6oRhPY2Z+a9XmNxpCpc8wrkn+z+hfBfdyfQWqbmcpRDAudMZlWyxkhJatLokke7ma Et2/U8a6yWlaz3i25o0rDwkns4zDFjy5oOtaZvv3XL/PtG48OI52/reUhdNSR9jzgKtP eglgmV7dn/thqa7E7Vf7CfDz2MfPuZUNl0TtVxmZWnlQ6QASioPHj95uN6YQ1XLpiA8t LbRT4QhFoBMlsEepeOZ9ZsveIz8TvshYEl+UV3/AsA+PBAOxeGPpjVKCT7K/ooYT7Nmy LvNo3Jhmf4n7PM62/OPUM1pj8ZJq5XvIrXdlqOvTKZHKIhh7gfvMhuvPt02lzusA3Uyj J8Zw== X-Forwarded-Encrypted: i=1; AJvYcCUS83UEem8Hzx/1fmKWGlRSzSpD2QjPew9WKwRHA0VnzaNtsJkAZL0XHCWkMPXc0tNeki4f4K0Zy/2ySJ8=@vger.kernel.org X-Gm-Message-State: AOJu0Yxa/W20d2G5PievS/09jQwW5bayhjogaIBSyuBFcidGIwJfJK8M Wi9Yao2yFx1wVK/dVVAuCIoZeC+4h7AW1DFNzOiGPOu3Gi58IuRzPBc9 X-Gm-Gg: ATEYQzxAYhfWUHtexaWkUWr9Noybi1Fkt3JS8OBCM8reEj4OEwQOF2cidhIid5B6Kan Ki69IUlpgNSZR8YcgaCuYtEMkPupspU7i98S0dmoz/k9hoisyxDAyQWIThqwCIvK4KnhfBkwDB5 +d9YlAW+E6P8GFfpKpIanrZ8mJ68TVHuirCbf5VlgseqOJl5kZy/po0CJ1DbqvE11cmGGdNvGNd T5z8SS87Ws6pWg9VKQAeZ+myKu/mQ9itITxsfyt5WRhkL5iaYWEaOUKn4DKzsPkCLjyOGufQVDX Nnhb1zq+s0IFaIrDR7ZdxlEmvVLYPN2rw27e+EywCnBTGu7r6k9ym3U4DjYQeCnzM/TEzC1HLZD ivrJ+9Z65wluGk/vhz53W86zybEVpCUOA/PVxktZBL7AuODEWwKGdbBvROWAVk4OfT/CFOgmt/N bHfCfTjum64AbF6vxpakHeTsHkBINvwa6B6ji3zbrcwdUo14oHPHdAxpZ3MazzLPS2bsvSLWB6T tA= X-Received: by 2002:a17:902:c950:b0:2ae:5ab4:f4c0 with SMTP id d9443c01a7336-2b0c488e16cmr2842315ad.13.1774501991093; Wed, 25 Mar 2026 22:13:11 -0700 (PDT) Received: from mi-HP-ProDesk-680-G6-PCI-Microtower-PC.mioffice.cn ([43.224.245.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b0bc8de61esm20402815ad.65.2026.03.25.22.13.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Mar 2026 22:13:10 -0700 (PDT) From: zhidao su X-Google-Original-From: zhidao su To: tj@kernel.org Cc: sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org, void@manifault.com, arighi@nvidia.com, changwoo@igalia.com, peterz@infradead.org, mingo@redhat.com, suzhidao@xiaomi.com Subject: Re: [PATCH 1/3] sched_ext: fix NULL deref in bpf_scx_unreg() due to ops->priv race Date: Thu, 26 Mar 2026 13:13:05 +0800 Message-ID: <20260326051305.113430-1-suzhidao@xiaomi.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: 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, Mar 26, 2026 at 10:55:08AM +0800, Tejun Heo wrote: > On Thu, Mar 26, 2026 at 10:28:25AM +0800, zhidao su wrote: > > The reload_loop selftest triggers a KASAN null-ptr-deref at > > scx_claim_exit+0x83 when two threads concurrently attach and > > destroy BPF schedulers using the same ops map. > ... > Can you reproduce this? How do you trigger enable on the same ops that has > already been enabled? I investigated further and the analysis in patch 1/3 was wrong. Please do not merge patches 1/3 and 2/3 from this series. Patch 3/3 is still valid and can be applied independently. Patch 1/3 (NULL deref): The race described in the commit message cannot occur. Both bpf_struct_ops_link_create() and bpf_struct_ops_map_link_detach() hold update_mutex when calling reg()/unreg(), so concurrent reg and unreg on the same ops map are serialized. I ran 20 rounds of reload_loop under KASAN with no crashes. The bug was never real. I wrote the patch based on code analysis alone without first obtaining KASAN output confirming the crash. That was wrong. Patch 2/3 (dsq_reenq reliability): I cannot reproduce a failure with the original test (NUM_WORKERS=4). Running 10 iterations locally, all pass. The "reliability fix" had no verified failure to fix and should not be merged. Patch 3/3 (consume_immed reliability): The original test fails consistently because ops.dispatch() moves only one task per call, so dsq->nr never exceeds 1 and the IMMED slow path in dsq_inc_nr() is never triggered. This is a real bug in the test. Patch 3/3 is valid and can be considered independently. Sorry for the noise. zhidao