Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp180355lqp; Sun, 9 Jun 2024 23:47:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWz0/MLn2nYHiWNMAawAgwXruXesJCExaUG6qjNVa926d1dQUKfR/L/HRcBVhJUoZBNc2jEK6t62fKwOBPtlYewxLfjsgJABsxEkDgZQQ== X-Google-Smtp-Source: AGHT+IEI9jX3kMRAwz6gHRVREswvaYCsCE9rt39bOacZaojWFItSH+cn/NB8lQgmzKNOwQBkICsj X-Received: by 2002:a05:6830:1306:b0:6f9:b071:28c6 with SMTP id 46e09a7af769-6f9b07129eamr2551633a34.18.1718002040689; Sun, 09 Jun 2024 23:47:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718002040; cv=pass; d=google.com; s=arc-20160816; b=IxcgSCyj/gYTeT7OCgCpSStQzqKs3gyiOreMk+3BZ4lhKWPXRtUvDbFo+ngoNi6G7+ bRx+tkNw0hlqOry7LBQusTwzKwfCaC157BpLoZSwxyQCnSY1fOLS3Uh0/kkb71r+vebg k5eRTSqKy3q3gSOtQNtbIu7hTmNEERUiXPAS3K6rosKH33JFinXcke7MQLiMbKHtpTKt bbL0ZOQyZHI3hMTsrfr5T/vKHCqaEF8pucO8QYF1eESlyQxxv3mc/VKWvLR6TvSrVHL1 /y3D9jJ6u+pQYHWzOwR8FQPhZ78ZXlTOc8o3gyzpTUlipOs3usZvDyXd1xi5hBs5T6M4 f01w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Y8mq8NFiBXisZKfoul6E8pG6esRWXllJmw5nWndqT/4=; fh=ou4EGoEAHbuNBS9MDoS1zZlGh5u/ZVxbHreYt2Tel/0=; b=xZFP7J212OJX04uJ4EOjvk8LJfyGUsvEkNGC4h1u5zwM3ozcEvxXoWwiCWEirU5QwQ +s4INwzDmzJodoDsWCrXBcd8wbIre1zH3TMBvLEAX/xAolfH1eeqU9Fkrv0lMFghiPvY FjLHDbyMYjgFjdTPa6LnalysEZAxbzcjXkmz85ka5Z5CgkK5ge6PCA1bvuCce2Sj9xf3 9iyF3K4xdlIli6lk037SS0Q1nk8rfVQScSOXp2tUzU1NACXmCPuRxUdLoqHfhJzVdRBZ 44JjEDQ3prZOwhnmKsQg3Ao2y/FYJsdCIpr3uP7utLE2VdUT8UQKOednrc/NXOpec5km p+5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=cvT1k5JL; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-207743-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207743-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de2073c76esi7203712a12.104.2024.06.09.23.47.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 23:47:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207743-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=cvT1k5JL; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-207743-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207743-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 43437281570 for ; Mon, 10 Jun 2024 06:47:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74A341AACA; Mon, 10 Jun 2024 06:47:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="cvT1k5JL" Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 129F42582 for ; Mon, 10 Jun 2024 06:47:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718002033; cv=none; b=VFwazb8/Ia9q/wjC8XXiTVRuPxelKzrSaWHaBHeu7L6KP9fhM5GZjsGtMqDBdWNrGX4GUX9Ls71CrzQYIA7rkb3JQdbp0nqnb+D9h2+mSo/Xq5ywWQyjlekoNxi8QstcZQGAVbudsMlB4+bCsz7uhF7GzGQTSSxKkDOuW6JVJts= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718002033; c=relaxed/simple; bh=bkTdS5UF9BBXXB3SvVtm1jZQ0RuPc/f1jwO5uRomwNc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=N1EzME/MtDc5CXC0Cc1w70A95srZutDZ2ejjWHhbrlr+bog8JDKLwVKO/ejRWQ87wXlOAK+53kX5PbmrKVx9NxE9WstOEWUA5gjjmWjUrqpq8XtS8/8PO67OHVRD7e+MCV0XbP3V/1NSHVdwHL9+P5ejSPD+IFv5oX2AYznhGWk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=cvT1k5JL; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Y8mq8NFiBXisZKfoul6E8pG6esRWXllJmw5nWndqT/4=; b=cvT1k5JLmiMm2dcf78WNc4v1Fz CkBaFdMHmYat4rVhES8RaQOjpshx3n5PqWFT5LUmYKuGSHUzQlNe/NcEf+TgOhzDIF2vi89/tD6mf 74OA4udNwUf9jUPR4md5nQJwWdPvkJE0xIKvaS1o6/ERourIuJHE6c6SPmavZOgHNhTnVSp/SSof8 oM4Ga2tQP0roKeuXlpDvZDXzY2w4jy2fi3Tv+47J0h5XSB3uINnAYPTXdzF3+E+0XDDGGMcf+2OTO b4BAbbrMg+qcwvE1h0lGUrPfVvZLzAOtR9enDp3Draz+aHAooiM27g5GKRY600JEbp0zZL465fi8T 0PE5iO2g==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGYno-00000001Fc8-301b; Mon, 10 Jun 2024 06:46:53 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 4902E300362; Mon, 10 Jun 2024 08:46:51 +0200 (CEST) Date: Mon, 10 Jun 2024 08:46:51 +0200 From: Peter Zijlstra To: Thomas Gleixner Cc: Steven Rostedt , Sam Sun , linux-kernel@vger.kernel.org, x86@kernel.org, syzkaller-bugs@googlegroups.com, jpoimboe@kernel.org, jbaron@akamai.com, ardb@kernel.org, mingo@redhat.com, Borislav Petkov , dave.hansen@linux.intel.com, hpa@zytor.com, xrivendell7@gmail.com, Greg Kroah-Hartman , Tejun Heo Subject: Re: [Linux kernel bug] WARNING in static_key_slow_inc_cpuslocked Message-ID: <20240610064651.GS8774@noisy.programming.kicks-ass.net> References: <20240609090431.3af238bc@gandalf.local.home> <87o78axlbm.ffs@tglx> <20240609102530.0a292b07@rorschach.local.home> <87le3exfx2.ffs@tglx> <87h6e2xdg1.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87h6e2xdg1.ffs@tglx> On Sun, Jun 09, 2024 at 06:56:14PM +0200, Thomas Gleixner wrote: > Ok. Now I found if for real. It's in the jump label core: > > CPU0 CPU1 > > static_key_slow_dec() > static_key_slow_try_dec() > > key->enabled == 1 > val = atomic_fetch_add_unless(&key->enabled, -1, 1); > if (val == 1) > return false; > > jump_label_lock(); > if (atomic_dec_and_test(&key->enabled)) { > --> key->enabled == 0 > __jump_label_update() > > static_key_slow_dec() > static_key_slow_try_dec() > > key->enabled == 0 > val = atomic_fetch_add_unless(&key->enabled, -1, 1); > > --> key->enabled == -1 <- FAIL > > static_key_slow_try_dec() is buggy. It needs similar logic as > static_key_slow_try_inc() to work correctly. > > It's not only the 0, key->enabled can be -1 when the other CPU is in the > slow path of enabling it. Well, the -1 thing is in the 0->1 path, that is, the very first enabler. That *should* not race with a disabler. If it does, there is external confusion. (As I think the follow up email shows..)