From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 B24AD3BD241 for ; Fri, 26 Jun 2026 16:06:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782489975; cv=none; b=K+R56aBA/a+hj+xUKqRDeFiekuRmBdlmNwoS9aphkkkApasZn6WhStmkSDs4QNJpY3MPU35h6TyLW/wFiG4jiD4MbDF6DjtY+g/v5cYbcd4L1N8Vb7u1jz+jj3E2t6X7udMcqJIM7X/+ztLwyDZcFW0h4OajFKRhsxVeuwrHFjY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782489975; c=relaxed/simple; bh=qt5HD8bUfk/9ZmL23t0BwS0aectgMZVMUD7ozrAqS8Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kZ3mdYARcbZ8TYA9+/c8vYmrnmYM+2ch3gbOzyEQO1JfME5TxzAKidEyhpGKAHR9btS0RNg3Dk8T9XhcEY0L9l/XvYIZuTA8OhuOL5KrNcopq1oQzrg4jj8k25mGk1avg1/8kVj9/wI3Jty1g0fsuUfuqfPDUxcaHY1ydQW74eU= 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=JMXpeYJF; arc=none smtp.client-ip=209.85.221.47 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="JMXpeYJF" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-46fe472da0dso188860f8f.1 for ; Fri, 26 Jun 2026 09:06:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1782489972; x=1783094772; 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=2cIyznuCJGHdYtVx6T4GJ4NqPqFSjKnRR9CX5npGDio=; b=JMXpeYJFhjfzIlfFncelO88FKqPXTXKovkYp3jotivo2a40zvatJdOXFW58Wh047OP J08hpF+z5bYnDt7ZBboStsD7S7fOuV9FJc+1iB/PO9GoniwMFqBCZWZ0RITylRyshJ8U S3LOzyk0uR5iroZ3e0HjsB24IPy4MDWeTb9ZhwLQvgkZsa6aimMyMG/NgsY7yXEYg03P 6DAIrXpcFXNqDk2oLOrKAzj7t0tftfbReKSHkoe1igrIE9yOPSITA7JT03czR9sW/Eni ig6/lrz9fOlxP+Yl9kro4vT/YBJw2qdz2QLYtn67iAq8PD7nLSqbAebB8ON47a2DBALR Ud/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782489972; x=1783094772; 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=2cIyznuCJGHdYtVx6T4GJ4NqPqFSjKnRR9CX5npGDio=; b=nbfr23FKkqo5BgOBVpTzDY1nkAgiyhK2qKOZZ0AgTVnt4THvUwayEAcAFRHYMkDeDK fBt5FAWRffgNYftiRTlqp1l8S9vJfpDSbyDqHDz/cgchhm77+rAR17Cq2l1Iap7C9wUD BpsV1fTVeJm6tKWfc+FOtU1DuU7UNFhaa+c+C4yvIdqGy+XxocU3R9Ci4NT6dtbn0bFX dnTPGQM9L3jtK+wBQNkHJnNAPNyeP8elrwAtW71PdJq2iVFXHqrAcnmUfs79bH3/M+cW kVrzI4ER5Z7ffB0lDJTCd3tJ2Jfcx19ZQaJWQ03klUMw1RLrQKhkAxGoCtxOVRbBJu8V gN1w== X-Forwarded-Encrypted: i=1; AHgh+Rqtx30C3WyYSWlcXHtgy4Jk6fP4+E+nMgolG6EphVR0ymF1rKddgo3KULhuHirvX+frIxksm8whcGstyN8=@vger.kernel.org X-Gm-Message-State: AOJu0YzRggGjx5RDY6zU3Zfcr0POHF6cUDM4LPT7O/eCtuBdKI2lmyvR X9+zoFl4dAXsqXzHfGuE9Gh0Up/TX8G38i0XQw8N9ddwf+3vT98BWiCd8sqfa0lh060= X-Gm-Gg: AfdE7cnUzxru59O3HT8cD1RPfKmVE+Cg5cPvxwTlDEKRnH1KfultjKeVPtFfyhlMfcx H096xriN//AI1/CIQvCbERnrRDbSyQOh7mL0Pyf6G/G/arRsyzc755rPPba3XgBADvnYXPpZHt4 cFaOZlGFQDFzgNZkN0lP2vGvcf6OQcQwN8Gh9YiG0kP+bT6iF9mwMdmVc9rl2WjdGsOFgUxk9Yz AdkFO+9wupMevIZPOLD1sr8dZEcJv6WUuEkWe90TPGmuEIOvtDNbxcziXUiJVeLymHUxi1B8tBX gvxI5LWVVVRWMpU0G5uSjfyxGkVe8g70zBRETCUBbnQotI3MwqG33b1olhYOVVvLLS8mQw7cquw 6vaBSmZbjvsBkyvedZaruybiSCfBf37U67uOhvZ9ePm04pL/WexM2sjJPF8jF1/83rVMAuvr5ba EKS0HibzjTszl46QU= X-Received: by 2002:a05:6000:41e6:b0:45e:739b:3e3c with SMTP id ffacd0b85a97d-46dbbdd7173mr12681438f8f.0.1782489971984; Fri, 26 Jun 2026 09:06:11 -0700 (PDT) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46fccca2781sm1609955f8f.6.2026.06.26.09.06.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 09:06:11 -0700 (PDT) Date: Fri, 26 Jun 2026 18:06:09 +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: On Fri 2026-06-26 17:53:27, Petr Mladek wrote: > 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? Ignore the silly question, please. Sure, even spin_lock_irqsafe() is a sleeping lock in RT. That said, I am not sure how to effectively pretend the right context to lockdep. It looks a bit ugly to disable interrupts around all the code which is guarded only by a fake lock_map. Best Regards, Petr PS: I am sorry for the rummour. It is Friday evening and a very hot weather here.