Received: by 2002:ab2:715a:0:b0:1fd:c064:50c with SMTP id l26csp8938lqm; Mon, 10 Jun 2024 10:58:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU/xVirVca0lkbkR3SR+KDGVIHzEHw4PTu6hyjKxK4kursVxbngiFVoeKDEjozOIW8b7USYNUwtZ0zB9WI6ajKzipzwLOWGrbtBPLq4zA== X-Google-Smtp-Source: AGHT+IGrH8WJJZtOpllYgqT00mmaxrGlkqlWrTc7WTLxixPXN76UWwolbNvWRduhO0sMTFgCLWAW X-Received: by 2002:a05:651c:550:b0:2ea:8d54:4530 with SMTP id 38308e7fff4ca-2eadce38268mr75671551fa.28.1718042304577; Mon, 10 Jun 2024 10:58:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718042304; cv=pass; d=google.com; s=arc-20160816; b=K5dQw279+mZLuBFIuIKH6QycsawXwDpOAdiOx7aG8HKDEIdgpMoaUc0k5PhZ4TpwJ2 H3rKpmHlZXxfcg/wypvYcFjuLSj0L8VAsIWKGgiTNrY1pKlsYJw220uXv5DuBlgvDSTX zCKOr6vj0Cg7jtpTFyjAINHSpD+Lx6EcSQeiDMarjKzEA1r23GiVl6geXe99cRVloh6r ZwmDNZsDQckwrgVbGt582TPIJCkkHBUI0Q1E9Fnep6Rm7LVBMLNnWMXA4qzl0waTI/pa P3CuWO1sByYsAMyCKkuolF0yDQLffQjslKVNZngPiOqCYivq28Mix3vQiNMWPGTP/DsC 0sBQ== 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=tzE9/qnr4um+VYO+527ypE8v0RW1c1pcyvH5D6izX7c=; fh=Glxpx0+IcowoA1p9CvQCOa33UpNF+CB1NInS2AHST1w=; b=tl5hwWI06CWPwrpWnPFhlxcYHtjnSqlc+CEEXkIkth5SoWG5vTa6aKpQ3NLVFxVnis J/crO1pLDElZ+Zappgpjsfe63gkElFptIW26Ht1JXh+/vaHp6QleK/iIZIJOsiDy34sC ReJP+CEahp4oAbJ9SyD07kp/PPDWczxGDRjh5XPEo9J0X+YMT2Av6z82GcwskT4d+BxK DbY06xGDP9zXt2Cpi82xs9IcSkMGzhhZ48deYfoivIaJ9JSqq20/4m8z5/p0+FUmsuou rx9rJtAENFKgCq+tC8t+PRzrG+cnRXi0FBDhXuTLSoCT93jyJk4Xp/pjyrB3VT48hxz1 oncw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=GIACEFCn; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-208687-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208687-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 4fb4d7f45d1cf-57aae266352si4832184a12.577.2024.06.10.10.58.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 10:58:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208687-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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=GIACEFCn; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-208687-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208687-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 329321F23673 for ; Mon, 10 Jun 2024 17:58:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 78A9914C58C; Mon, 10 Jun 2024 17:58:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="GIACEFCn" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 9913114BF87 for ; Mon, 10 Jun 2024 17:58:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718042283; cv=none; b=Pf1Om7gLJrS4PVwFLJ1lgvbUqY2ZIe6QZb84KBv9OT4GjEw27TnJh3w+JqLGeeRX/M3XGP9lwLjT5vYuKVS7rHX1VTpm4KqbQjeLAYAkCJ1At8b7Ww9NMfZxJXXzkjwi2I3h15ijFdD3+4d6Q4S5rILRj/fKlhzAZwZi8/lMRI4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718042283; c=relaxed/simple; bh=ZEE78fBW4oj/V++IoBCqlsA5SuhniLQAzUs8q7rHGFA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=T6RHypdZN/KcNFfRX+UEnHuvy4E0skVYRePIsUIm13bz+FHH3ef4i0r/3rFp9NbgWLMA7C4N6jfh8kVlsc7W4LydDh/H8dWNFISb3v5sPEk4Fz/7FAdpypqDdaSobQ/btZJghjmz+aPkY5CrG08CjeH66IyCI+SQgjYEzoc45Do= 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=GIACEFCn; arc=none smtp.client-ip=90.155.50.34 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=casper.20170209; 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=tzE9/qnr4um+VYO+527ypE8v0RW1c1pcyvH5D6izX7c=; b=GIACEFCn31GfIWfvsLmy+aurfg u54oICw6bSzxsjtoFFsgI4Y1wFVOIngoKAqiuXsLdZpnX1EaIRzS2CKjal3OHanvY7sJmHHJtQGUN SXAzFGHKuF8fhYthBm0SSuFNilkxt18+RkKSFtoO3UGLKkDlN2oRmvKaLhRXWu19wB0RmeOjjyR1P DPUxgS6vUKitcChuHYFfpdsMx0LloKBaNFEUwGEwvJc5DWJs/3MK16bcrBQ5OYYqcLJpbY2qvMwC7 FRPnJqCPmLMnsugnn3BxW5UJQjlE+nJbeaDVUBkr+eKA7C/Gtpn7P3Q76jDm86CksEqld9Q/rStH8 5EpGTq6A==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGjHI-00000009bYK-3rW4; Mon, 10 Jun 2024 17:57:56 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 38CC2300439; Mon, 10 Jun 2024 19:57:56 +0200 (CEST) Date: Mon, 10 Jun 2024 19:57:56 +0200 From: Peter Zijlstra To: Thomas Gleixner Cc: LKML , Steven Rostedt , Sam Sun , x86@kernel.org, syzkaller-bugs@googlegroups.com, xrivendell7@gmail.com Subject: Re: [patch 2/4] jump_label: Fix concurrency issues in static_key_slow_dec() Message-ID: <20240610175756.GU8774@noisy.programming.kicks-ass.net> References: <87bk49xf15.ffs@tglx> <20240610124258.109097511@linutronix.de> <20240610124406.422897838@linutronix.de> 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: <20240610124406.422897838@linutronix.de> On Mon, Jun 10, 2024 at 02:46:36PM +0200, Thomas Gleixner wrote: > @@ -247,20 +247,25 @@ EXPORT_SYMBOL_GPL(static_key_disable); > > static bool static_key_slow_try_dec(struct static_key *key) > { > + int v; > > /* > + * Go into the slow path if key::enabled is less than or equal than > + * one. One is valid to shut down the key, anything less than one > + * is an imbalance, which is handled at the call site. > + * > + * That includes the special case of '-1' which is set in > + * static_key_slow_inc_cpuslocked(), but that's harmless as it is > + * fully serialized in the slow path below. By the time this task > + * acquires the jump label lock the value is back to one and the > + * retry under the lock must succeed. Harmless yes, but it really should not happen to begin with. If this happens it means someone wants to disable a key that is in the middle of getting enabled for the first time. I'm tempted to want a WARN here instead. Hmm? > */ > + v = atomic_read(&key->enabled); > + do { > + if (v <= 1) > + return false; > + } while (!likely(atomic_try_cmpxchg(&key->enabled, &v, v - 1))); > + > return true; > }