lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190814104131.20190-8-mark.rutland@arm.com>
Date:   Wed, 14 Aug 2019 11:41:29 +0100
From:   Mark Rutland <mark.rutland@....com>
To:     linux-kernel@...r.kernel.org
Cc:     ak@...ux.intel.com, akpm@...ux-foundation.org,
        bigeasy@...utronix.de, bp@...e.de, catalin.marinas@....com,
        davem@...emloft.net, hch@....de, kan.liang@...el.com,
        mark.rutland@....com, mingo@...nel.org, peterz@...radead.org,
        riel@...riel.com, will@...nel.org
Subject: [PATCH 7/9] x86/lbr: correctly check for kthreads

The x86 lbr branch_type() functions looks at current->mm, apparently to
determine whether the thread is a kthread without any valid user
context.

In general, a non-NULL current->mm doesn't imply that current is a
kthread, as kthreads can install an mm via use_mm(), and so it's
preferable to use is_kthread() to determine whether a thread is a
kthread.

For consistency, let's use is_kthread() here.

Signed-off-by: Mark Rutland <mark.rutland@....com>
Cc: Andi Kleen <ak@...ux.intel.com>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Kan Liang <kan.liang@...el.com>
Cc: Peter Zijlstra <peterz@...radead.org>
---
 arch/x86/events/intel/lbr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/lbr.c b/arch/x86/events/intel/lbr.c
index 6f814a27416b..ed2b7e57a249 100644
--- a/arch/x86/events/intel/lbr.c
+++ b/arch/x86/events/intel/lbr.c
@@ -857,7 +857,7 @@ static int branch_type(unsigned long from, unsigned long to, int abort)
 		 * can happen if measuring at the user level only
 		 * and we interrupt in a kernel thread, e.g., idle.
 		 */
-		if (!current->mm)
+		if (is_kthread(current))
 			return X86_BR_NONE;
 
 		/* may fail if text not present */
-- 
2.11.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ