From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D10CAE77188 for ; Wed, 18 Dec 2024 16:17:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 683146B0099; Wed, 18 Dec 2024 11:17:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 60B476B009A; Wed, 18 Dec 2024 11:17:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AC916B009B; Wed, 18 Dec 2024 11:17:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 284686B0099 for ; Wed, 18 Dec 2024 11:17:58 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 86DB080D9A for ; Wed, 18 Dec 2024 16:17:57 +0000 (UTC) X-FDA: 82908584934.06.12B505A Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf28.hostedemail.com (Postfix) with ESMTP id 2101FC0006 for ; Wed, 18 Dec 2024 16:17:19 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=D0rn+N2Q; dkim=pass header.d=linutronix.de header.s=2020e header.b=FlXJvDHh; spf=pass (imf28.hostedemail.com: domain of bigeasy@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734538640; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gl4PyUXwFPzZyEQNIKCuf8t1ptfccSRsh0pr8uzkPO0=; b=IQ7tNdeyb6geHB39ypIhI1E3Q7FpZoboFn6J/gZVFgdQjTESU3gD+Oh6YWlTEx6by6bVsW T96NUeYKd8nYsxos8pHynlcDauB9BDX1ovprcWiYrf2QTSuqHsK3dk2vlCk/oIvNIEzNeJ n6uUPkB7l2qwi5YcwWdSpCsbIZVhdlk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734538640; a=rsa-sha256; cv=none; b=5PgKLnOYfHoNWHmUlYA168baAzCgBm70HuLPExylS9sLZ899rztuhzXZEFPBPFvbQsJ3ub zB/Jr+gSUZFiG+xYb+Tr9VaUTxPaGLOUTxaGrB8uri88CuS9X4hQJXVMUwmFuGDLWgqwnj 6eW/FZOxDJ7/23VHB/vROqrKlUvvBjw= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=D0rn+N2Q; dkim=pass header.d=linutronix.de header.s=2020e header.b=FlXJvDHh; spf=pass (imf28.hostedemail.com: domain of bigeasy@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de Date: Wed, 18 Dec 2024 17:17:51 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1734538672; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gl4PyUXwFPzZyEQNIKCuf8t1ptfccSRsh0pr8uzkPO0=; b=D0rn+N2QqEHELWpCzcNjZmHZFTPkJkqOLNTZJEcNZI9LFjr4AwanrcW5YIDM4aFRKl140G vvHBNPmQpxORtbxVesVhy5kVVoO+ZJQpYXkGEJNGYWm6D8h9Op3JVjfIqNFfBl8qFST4UM OZtthP6b4zE4SyiI+CKYUYy2vjSGDcxb+3eVsn8w4b0O0DvE4ugjzyq8C+Do7vHpocL0uT MQpRMKYP5/Zz8EjGe2Lka6g/js1uS8v+Cjegbi/+ifm/1f+8eiubxZ4zrJrwFTU+OWzV4W HTVTdX1dC51Pv0dGuO4f+v9SRf2YpYYJYHh7SGn7ByWpzXDBSEI70XqRN4CBgQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1734538672; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gl4PyUXwFPzZyEQNIKCuf8t1ptfccSRsh0pr8uzkPO0=; b=FlXJvDHhAbDiEX47mg/8/f6D279Qd5Za4fjajV7kIoZ1MgKvTMkMx7UUVy476Xp88PCbec Gm5XKedNNLIjcQDw== From: Sebastian Andrzej Siewior To: Alessandro Carminati Cc: Andrew Morton , Catalin Marinas , Clark Williams , Steven Rostedt , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, Alessandro Carminati , Thomas Weissschuh , Juri Lelli , Gabriele Paoloni , Eric Chanudet , clement.leger@bootlin.com Subject: Re: [PATCH v2] mm/kmemleak: Fix sleeping function called from invalid context at print message Message-ID: <20241218161751.gYbwFkzd@linutronix.de> References: <20241217142032.55793-1-acarmina@redhat.com> <20241217095504.ea2a3a24564af4df48cf0b19@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Rspamd-Queue-Id: 2101FC0006 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: fztu3s3xo1ij4f5ipgk17udbjny8x6h6 X-HE-Tag: 1734538639-297212 X-HE-Meta: U2FsdGVkX1+J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jtL2rmw4q55RV1/y6Lx6D50nSQccF604DEtzkG2oV05heJfqamCbMAiKfqTkmCC4bHWtgt0BsSBk0wls7mgWuBXfCTmqoWByxuNBx4WKXum8syy9Ve0KskNanI6V6Ns9qG2ZxvZ/mc+Bn6IgrDvJNnBLIRA3zCZrPB57/fJrecdZ2oYpGUecFZvxPrriJbhlgjXAObA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2024-12-18 09:38:05 [+0100], Alessandro Carminati wrote: > On Tue, Dec 17, 2024 at 6:55=E2=80=AFPM Andrew Morton wrote: > > > > On Tue, 17 Dec 2024 14:20:33 +0000 Alessandro Carminati wrote: > > > > > Address a bug in the kernel that triggers a "sleeping function called= from > > > invalid context" warning when /sys/kernel/debug/kmemleak is printed u= nder > > > specific conditions: > > > - CONFIG_PREEMPT_RT=3Dy > > > - Set SELinux as the LSM for the system > > > - Set kptr_restrict to 1 > > > - kmemleak buffer contains at least one item > > > > > > BUG: sleeping function called from invalid context at kernel/locking/= spinlock_rt.c:48 > > > in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 136, name: cat > > > > -rt is a bit annoying this way. Things which we expect to work OK are > > no longer doing so. Yeah. But lockdep should have complained here earlier. The RT just enforces that part. > > > --- a/mm/kmemleak.c > > > +++ b/mm/kmemleak.c > > > @@ -373,7 +373,7 @@ static void print_unreferenced(struct seq_file *s= eq, > > > > > > for (i =3D 0; i < nr_entries; i++) { > > > void *ptr =3D (void *)entries[i]; > > > - warn_or_seq_printf(seq, " [<%pK>] %pS\n", ptr, ptr); > > > + warn_or_seq_printf(seq, " %pS\n", ptr); > > > } > > > } > > > > Before 3a6f33d86baa we were still printing the address, with plain old > > %p. Should we restore that, or is %p always useless? > > >=20 > The intent of 3a6f33d86baa8 is to make pointers available for debugging > purposes. > My argument for this change is that %pS provides already sufficient > information for debugging purposes. >=20 > We essentially have two scenarios concerning %pS: > 1. When the symbol can be resolved by kallsyms: In this case, a > symbol+offset style pointer is emitted, which I find more useful than > just the address. indeed. With the relocation the information is usually hard to make sense. > 2. When the symbol cannot be resolved by kallsyms: Here, the raw pointer > is emitted. This undermines the original intent of %pK, as both the > masked address and the plain address are exposed. >=20 > If we want to be picky, there's an additional factor to consider: KASLR. > %pS emits its output accounting for randomization, but in most cases, the > randomized offset information is lost. > The exception is when the symbol cannot be resolved by kallsyms, though > this should be rare. It's still worth mentioning. >=20 > Back to your question: %p emits an hashed address that is not > reversible by design. > Therefore, in my opinion, it is not particularly useful in a debug > message. There is still %px if you want your debug message to show the raw pointer regardless of pointer hashing. That is something that you could disable. The %pK format is something that was meant to be used files like proc or sysfs. With the restrictions you already have on dmesg it does not seem necessary to have yet another check. Thank you the patch. Acked-by: Sebastian Andrzej Siewior Sebastian