From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 25F3D3F39EB for ; Fri, 26 Jun 2026 15:53:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782489212; cv=none; b=PKagaNVXg5ZiS/WJu14vNT/NV9fra5tCctlfQCvrdYtRNNGXxx8vCsRsdSIBENBe3Qy+GbkoUEnGe0WoAgKhcLvhEpk4mqs86qBro3aqHVGwJ9qNPCrdwMlKNNnHgjp6nMuQolQRxMmlONlp3JCv5L/IMkNSuvcrsVsIYL7+vNk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782489212; c=relaxed/simple; bh=9RF1KgpRJzVAJ7EKBMOO+N0Mzn9cN7TfE0w9YRWXN+A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YW5uR5dXg096mopuF+ZwoJbdgsLkauokwnbj/cp8Nvt8QFWhu0WY2icuMF9uI0nMfpyK89qVpERZcRw7Dz2xJrFP9nirwRQDNwmoGebUrrXc/0NlbO+McdqzE9ipTuQAtMzcQcFvgUP9MoTxHRyJeDzmC/Zm/eCBX15OCypIbMs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=FFbpXjmd; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="FFbpXjmd" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-46db1eb3100so190445f8f.1 for ; Fri, 26 Jun 2026 08:53:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1782489207; x=1783094007; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=dnmL4YKjQTqsAYZ6FQdKoT9MUZZ6vTkTBWCeGCu3EwY=; b=FFbpXjmdP9TTkHOGdQWAnVm01fDLGYXUg5jvw2TmHF5Aq0v2Zn3Bt917NTQ2iWj4V/ ij66w00zITzmffd0TGJMV8Hyf34fXRsTJK1iWixpiTiJdDYgiaTUU/vJ2lxNoF/KY4f4 Zv9NyylEs2y4aJ7Ka3bdWSseUVNYDMAdf9t/zx0T/wqFc+mo/x3Ew9K3PYei8Tppr9Tw 6UzTrEFKFRhQtEG2Qeix0obZLsQ9jFO6tpQYGAaKYpctzsN9GhuHNDkNJ/tNznVwPnnH PQjp1fpDznHZhXpZQbeZF6PVgaOm7MU23l7lR4RHOYHzkWWXC0adgkzfnJlj9YsMFcUF 3P3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782489207; x=1783094007; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dnmL4YKjQTqsAYZ6FQdKoT9MUZZ6vTkTBWCeGCu3EwY=; b=SpUPxVvmeC1tp7ERtdo3vwKdChC22gbUPijMicKxGdX0wmA2/9NpgvkoyraVdMJr8L K6k8d3XNz0BwiPGKFZy0EhQtQ5RSr1PaTE0UaVRV+5M0vYOPAvZPUwT3GbDUs67KZ6kN 7Xj3kzZ84qwehL/JPfVpKFuiuv7mrPX0J/soLNaTFH53iJ33tNnG0c++ju9kqZwBgC70 EgfskgE58+7eBWZF74IOoCCtomZ/UHqZfnrhRuvwYh1xT3jwk2ojbH5eDfZx8Yatq5dU aXOyK9vvG6MUBPlEWhpWTSnR9Lbyc6e00eIhzkPsT4h8sK8v52D7QetrzC7V+q+pKSKR shGg== X-Forwarded-Encrypted: i=1; AHgh+RpyYfeaM8vwTrdoZzB+BI4nY3YlQD7wRMHMprcP7EWGc2iHOq9c830ahcCM8GwSLyRvGWtAwE63Ifm6rVQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyyKu8DcJboBjML7z9Zq3+7lDkQln2coEyBDsKdS6c3x/7pl0sd BiTEBkFzhwDpG3I1f3kNiFHurcbUWelx5NDp3k/owzrXfcmzCr0wrun1aljU90fNfEo= X-Gm-Gg: AfdE7ckYsDOO+pZNzUGf7C2p2W15QNentvu2pli5vN3X6rBOp+YIM1dzPdmPOwM/Sqa Q7Ng1rQ7FzeRkGIg1GcbcdtWlXaYT0llWHG2toinQxENTiXNHabEzz/fivDruR3x5oFyzT3Iy3G eVHOcJNDPbACMn1KwU/yU9wMImJNcFmF87wV/eWwWEwFayt1KbqvQcrQSgVfok77GUDFxxTM9Lb 6ZJQZSFBzVB2DMDnMhOA1YeizQERhOgoE3DTCYyJT/WGe4gX+6m1fret6pAvhCYSBTvJzN/apwJ axeZlG1fG44cWCwKTPw+VkcJolP/Sprb0h4Oa1gtaF/IDrmF0tvyas39qUHI1Ig+CCIakKYUO2k IC06OO/GdgVjfLqZMnI4GKIKPNKgGGVgDDF9khrlMApaHvytL8stCley1edG2ZYMr4kFg4zEvxB eHbgcMWK8PgHmlVVc= X-Received: by 2002:a05:6000:4692:b0:464:5df5:332a with SMTP id ffacd0b85a97d-46dc14cbd7fmr8903578f8f.34.1782489207418; Fri, 26 Jun 2026 08:53:27 -0700 (PDT) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46c2279b85csm24201068f8f.28.2026.06.26.08.53.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:53:27 -0700 (PDT) Date: Fri, 26 Jun 2026 17:53:24 +0200 From: Petr Mladek To: Sebastian Andrzej Siewior Cc: Thomas =?iso-8859-1?Q?Wei=DFschuh?= , Andrew Morton , Steven Rostedt , Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Clark Williams , Kees Cook , linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev Subject: Re: [PATCH v4 5/5] lib/vsprintf: Validate spinlock context during restricted pointer formatting Message-ID: References: <20260608-restricted-pointers-final-v4-0-9a436615799e@linutronix.de> <20260608-restricted-pointers-final-v4-5-9a436615799e@linutronix.de> <20260611120615-4252b75d-55aa-4bed-b64b-0316b2148d2c@linutronix.de> <20260625145115.KZ9l1-lv@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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260625145115.KZ9l1-lv@linutronix.de> On Thu 2026-06-25 16:51:15, Sebastian Andrzej Siewior wrote: > On 2026-06-11 12:09:08 [+0200], Thomas Weißschuh wrote: > > > @@ -864,7 +864,14 @@ static noinline_for_stack > > > char *restricted_pointer(char *buf, char *end, const void *ptr, > > > struct printf_spec spec) > > > { > > > + /* > > > + * has_capability_noaudit() may use spinlocks. > > > + * Make sure %pK is only used from valid contexts. > > > + */ > > > + static DEFINE_WAIT_ASSERT_MAP(vsprintf_restricted_pointer_map, LD_WAIT_CONFIG); > > > + > > > lockdep_assert(in_task()); > > > + guard(lock_map_acquire)(&vsprintf_restricted_pointer_map); > > > > The kernel test robot found a lockdep violation with this patch: > > https://lore.kernel.org/all/202606110945.d3871219-lkp@intel.com/ > > > > My suspicion is that this is a pre-existing problem that was not visible > > to lockdep so far, exactly what this patch is supposed to mitigate. > > I'll investigate some more and try to reproduce it. > > The annotation is "wrong". What you say "I do spin_lock() here". > Then lockdep figured out that this lock is acquired under a lock which > is used also from within softirq. This in turn can lead to a dependency > problem based on softirq: > > | CPU0 CPU1 > | ---- ---- > | lock(vsprintf_restricted_pointer_map-wait-type-assert); > | local_irq_disable(); > | lock(&ptr[i]); > | lock(vsprintf_restricted_pointer_map-wait-type-assert); > | > | lock(&ptr[i]); > | > | *** DEADLOCK *** > > If I'm not mistaken then this will not happen in real life because the > hook callback does _always_ spin_lock_irqsave() and as such it avoids > the interrupt+lock on CPU0 in this example. Interesting, does the spin_lock_irqsave() even allow sleeping under RT? I mean, does spin_lock_irqsave() violate the raw_spin_lock vs. spin_lock nesting rules? Best Regards, Petr