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 E7413D5A6EC for ; Tue, 26 Nov 2024 08:11:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 52E1B6B0088; Tue, 26 Nov 2024 03:11:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4B6066B0089; Tue, 26 Nov 2024 03:11:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32F306B008C; Tue, 26 Nov 2024 03:11:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 11DD36B0088 for ; Tue, 26 Nov 2024 03:11:37 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id BDFAC1A08D7 for ; Tue, 26 Nov 2024 08:11:36 +0000 (UTC) X-FDA: 82827526908.05.A4AA10D Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf03.hostedemail.com (Postfix) with ESMTP id E237020010 for ; Tue, 26 Nov 2024 08:11:32 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=iAKqnXTQ; dkim=pass header.d=linutronix.de header.s=2020e header.b=4+BUyeva; spf=pass (imf03.hostedemail.com: domain of t-8ch@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=t-8ch@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=1732608692; 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=5GpAmMAZCucWPeDiq8mLR20xNnMwG7bVAX/MvW6+Uuw=; b=4ymBfwaDoPojXGC/b8XFtROHothnLB9ms1zhwNWUFezmWLhjKJlNjgRUD9Ia42RkIiapud NUBQB+6LTLduLVen/3WyVQTOsI4k6U51WCDQCZ6s5FEYY2rBKeDyVQuh4i8hya5lwWl1Z2 1XprMDsyzufKK/BMonAp3ZMVbbaUY4o= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732608692; a=rsa-sha256; cv=none; b=ZYO+dmGx8yNJvacs258WwfogxPF80miaB6VlxnQ/R1TF2BMA+qytVZDdcdJ2ad2UHoGS/z INuRBAXblD3BIF6RLavAfxteNpda0gF/PtE8iv2qbfuuyTIFv2O9J6om2fdt/UfS3oaOzG F36Ps1lKI/eiNZEyOyaRwCygouGK7kA= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=iAKqnXTQ; dkim=pass header.d=linutronix.de header.s=2020e header.b=4+BUyeva; spf=pass (imf03.hostedemail.com: domain of t-8ch@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=t-8ch@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de Date: Tue, 26 Nov 2024 09:11:31 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1732608692; 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=5GpAmMAZCucWPeDiq8mLR20xNnMwG7bVAX/MvW6+Uuw=; b=iAKqnXTQajhI4kjjTB/anN12F6qChlZ0p9i+DtgtsQgzx6tlVkkuRDYjg6GeqpHnbtqEP9 IeJ4bS7T7MIalLBXP+cinMznxIqjBwP574gySERomDpRCI3VCZs4H2x4GcrVk6OriPKgSy k0IttScrm51JFPmD3LVdT9M/4THKGKeXmX2kt/IW8zDBKroqr3cKGOhx5Ag8rvzB4tLm/O EUQepAfChebPSO1GV3csc5PfpyF5jKHryCDvvk3oMhGqGkzQIQY8mP8J/rcKK2N1vnTGZX saL2SNzcDzFOiquuFocu6logxEl2L1zj2KjNuI7VJK6NORznFX8Zi9y23f9+VQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1732608692; 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=5GpAmMAZCucWPeDiq8mLR20xNnMwG7bVAX/MvW6+Uuw=; b=4+BUyevajUdVU0h0msD6cmfDlTg3d4v7zmmLwmGjqSuXWQgeIMgJAhY/hYzkKzilhtRjec a6cxRnX9+HB2P6AQ== From: Thomas Weissschuh To: Alessandro Carminati Cc: Sebastian Andrzej Siewior , Steven Rostedt , Catalin Marinas , Andrew Morton , Clark Williams , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, Alessandro Carminati , Juri Lelli , Gabriele Paoloni , Eric Chanudet Subject: Re: [PATCH] mm/kmemleak: Fix sleeping function called from invalid context in kmemleak_seq_show Message-ID: <20241126090438-dfd305cb-3736-4d31-a690-4d00208783d5@linutronix.de> References: <20241120102325.3538-1-acarmina@redhat.com> <20241120102602.3e17f2d5@gandalf.local.home> <20241120164043.T1JuBALe@linutronix.de> <20241121170356.eC7f3-1v@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Stat-Signature: esqftkybwic34eszywruuzg7hxjpy8ud X-Rspam-User: X-Rspamd-Queue-Id: E237020010 X-Rspamd-Server: rspam02 X-HE-Tag: 1732608692-243470 X-HE-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BpbIaU67sIZHo4NErEHeCR0jALHC9SSQbc5YWbfckFSWkpABeU0LhJkuh4lyk8NHuXK+kQTBPA30RcJUGZc+J5tZ2Zdk0iyNSxnss4QXUN228EucqCzuMA6twfpeOQ2ML0WlWvqr8rF0cep3FlARVMgvR2IcO6DM9qK4C/m1Plgxl71bb9zYEE4r+mz2vkTwQZdfDlNDtQOmiLfWKWR5TnQBNoF1+/2hi+QSb1+RrgXgenN2t8zntnD0iIZBEoZaeYpz+BDIkY05dihhTLmjoyY/jrsJvKkWD4Poli3ShGtYKOBFWgvsquMJXVRn9PnnHPUxeS66FrMBFxRIW7HWaBdvZFIpK6tNjAH2jdty8W0V9WMIDq/PWQyXReg4ouhT25kWb7xbsb/IQgCM42KSJq/W+czopeU5H8w== 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: Hi Alessandro, On Fri, Nov 22, 2024 at 11:48:04AM +0100, Alessandro Carminati wrote: > On Thu, Nov 21, 2024 at 6:04 PM Sebastian Andrzej Siewior > wrote: > > On 2024-11-21 17:50:06 [+0100], Alessandro Carminati wrote: > > > On Wed, Nov 20, 2024 at 5:40 PM Sebastian Andrzej Siewior > > > wrote: > > > > > > > > On 2024-11-20 10:26:02 [-0500], Steven Rostedt wrote: > > > > > The "%pK" dereferences a pointer and there's some SELinux hooks attached to > > > > > that code. The problem is that the SELinux hooks take spinlocks. This would > > > > > not have been an issue if it wasn't for that "%pK" in the format. > > > > > > > > That is missing check and I think Thomas Weissschuh wanted to add it. So > > > > we don't call into selinux. > > > > > > Your comment confuses me a bit, as I'm unsure what Thomas is actually > > > working on. > > > Am I correct in assuming he's addressing a fix in lib/vsprintf.c to ensure > > > that sleeping functions aren't called, allowing these functions to work in > > > any context? > > > > restricted_pointer() has a check for in_hardirq() among others. This > > needs an additional PREEMPT_RT check. > > I would be actual in favour to get rid of case 1 for kptr_restrict and > > have either 0 or 2. > > > > > However, his mention of "This fix for kmemleak is still needed as the > > > pointers in the kmemleak report are useful" adds to my confusion. > > > Meanwhile, Steven suggests reworking SELinux to resolve the issue. > > > Could you clarify what you mean by "So we don't call into selinux"? > > > > This getting out of hand. By adding the PREEMPT_RT check to > > restricted_pointer() we don't call in selinux so the problem is gone. > > I am really glad that now we have a clear solution, however practically > speaking is Thomas working on such a patch or is he working on something > related that does not fully solve the problem? I am working on a change to lib/vsprintf.c. Something like the following: diff --git a/lib/vsprintf.c b/lib/vsprintf.c index c5e2ec9303c5..54ad175a22bd 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -870,6 +870,9 @@ char *restricted_pointer(char *buf, char *end, const void *ptr, return error_string(buf, end, "pK-error", spec); } + if (IS_ENABLED(CONFIG_PREEMPT_RT) && ...) + return error_string(buf, end, "pK-error", spec); + /* * Only print the real pointer value if the current * process has CAP_SYSLOG and is running with the Hoping to replace the ... with something that can detect actual problematic situations at runtime. I'm fairly new to PREEMPT_RT so need to do some digging. > Even if he is working on a partial solution, I am happy to coordinate > off-list working on his own private branch > (or else I would just give up and review the Thomas' patchset when it is > out...) Given that there is no direct interaction between your kmemleak patches and the vsprintf ones I don't think coordination is necessary. I'll Cc you for review. Please do go ahead with your kmemleak patches. > > kmemleak is not the only problem. printk(), as another of vspritf pointer > > code user, can be called from any place and would also trigger a > > warning here. > > As far as "kmemleak need to be usefull" goes: With kptr_restrict == 0 > > then with or without pointer hashing they will be useful. If we need to > > go via selinux then it ends as a hint. Thomas